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
80ad871d44f6d1c870d694b6ce07e178ee41e5e0
52
py
Python
guild/tests/samples/projects/simple/simple.py
wheatdog/guildai
817cf179d0b6910d3d4fca522045a8139aef6c9e
[ "Apache-2.0" ]
694
2018-11-30T01:06:30.000Z
2022-03-31T14:46:26.000Z
guild/tests/samples/projects/simple/simple.py
wheatdog/guildai
817cf179d0b6910d3d4fca522045a8139aef6c9e
[ "Apache-2.0" ]
323
2018-11-05T17:44:34.000Z
2022-03-31T16:56:41.000Z
guild/tests/samples/projects/simple/simple.py
wheatdog/guildai
817cf179d0b6910d3d4fca522045a8139aef6c9e
[ "Apache-2.0" ]
68
2019-04-01T04:24:47.000Z
2022-02-24T17:22:04.000Z
x = 1.0 print("x: %s" % x) print("y: %s" % (x + 1))
13
24
0.384615
12
52
1.666667
0.5
0.2
0
0
0
0
0
0
0
0
0
0.076923
0.25
52
3
25
17.333333
0.435897
0
0
0
0
0
0.192308
0
0
0
0
0
0
1
0
false
0
0
0
0
0.666667
1
0
1
null
0
0
0
0
0
0
0
0
0
0
0
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
1
0
5
03a7c7b783e0bd7d1e50d7e9ad2a54c007ade91a
232
py
Python
tests/test_meta.py
mskcc/cwl-utils
812d7a7df470bc116fae7f2a43fca2824d623400
[ "Apache-2.0" ]
21
2018-08-15T06:45:29.000Z
2021-11-13T23:31:04.000Z
tests/test_meta.py
mskcc/cwl-utils
812d7a7df470bc116fae7f2a43fca2824d623400
[ "Apache-2.0" ]
112
2019-01-25T08:51:33.000Z
2022-03-22T03:24:47.000Z
tests/test_meta.py
mskcc/cwl-utils
812d7a7df470bc116fae7f2a43fca2824d623400
[ "Apache-2.0" ]
11
2019-05-27T12:34:23.000Z
2021-09-08T14:00:34.000Z
"""Test __meta__ properties.""" from cwl_utils.__meta__ import __version__ def test_graph_split() -> None: """Confirm that __version__ exists and is a string.""" assert __version__ assert isinstance(__version__, str)
23.2
58
0.732759
28
232
5.107143
0.785714
0
0
0
0
0
0
0
0
0
0
0
0.168103
232
9
59
25.777778
0.740933
0.318966
0
0
0
0
0
0
0
0
0
0
0.5
1
0.25
true
0
0.25
0
0.5
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
1
0
1
1
0
0
0
0
0
0
5
03cf77eb00b1fca2f93d6fcc5e07cd97bec2432e
573
py
Python
source/scrapy/klse/main.py
mengwangk/myinvestor-toolkit
3dca9e1accfccf1583dcdbec80d1a0fe9dae2e81
[ "MIT" ]
7
2019-10-13T18:58:33.000Z
2021-08-07T12:46:22.000Z
source/scrapy/klse/main.py
mengwangk/myinvestor-toolkit
3dca9e1accfccf1583dcdbec80d1a0fe9dae2e81
[ "MIT" ]
7
2019-12-16T21:25:34.000Z
2022-02-10T00:11:22.000Z
source/scrapy/klse/main.py
mengwangk/myinvestor-toolkit
3dca9e1accfccf1583dcdbec80d1a0fe9dae2e81
[ "MIT" ]
4
2020-02-01T11:23:51.000Z
2021-12-13T12:27:18.000Z
# -*- coding: utf-8 -*- from scrapy import cmdline #cmdline.execute("scrapy crawl dividend_history".split()) # Grab the stock quotes # cmdline.execute("scrapy crawl quotes_investing".split()) # Grab dividend histories # cmdline.execute("scrapy crawl dividend_history_investing".split()) # Grab historical prices #cmdline.execute("scrapy crawl historical_prices_investing".split()) # Grab dividends history # cmdline.execute("scrapy crawl dividend_history_malaysiastock".split()) # Get OHLC for selected stocks cmdline.execute("scrapy crawl ohlc_investing".split())
26.045455
72
0.776614
70
573
6.228571
0.385714
0.192661
0.275229
0.344037
0.275229
0.275229
0
0
0
0
0
0.001953
0.106457
573
22
73
26.045455
0.849609
0.802792
0
0
0
0
0.264706
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
5
03cfe71025e26d7b739b1a5282c84c4ee77a93f5
39
py
Python
improc/utils/const.py
antsfamily/improc
ceab171b0e61187fa2ced7c58540d5ffde79ebac
[ "MIT" ]
2
2019-09-29T08:43:31.000Z
2022-01-12T09:46:18.000Z
improc/utils/const.py
antsfamily/improc
ceab171b0e61187fa2ced7c58540d5ffde79ebac
[ "MIT" ]
null
null
null
improc/utils/const.py
antsfamily/improc
ceab171b0e61187fa2ced7c58540d5ffde79ebac
[ "MIT" ]
null
null
null
EPS = 1.0e-16 PI = 3.141592653589793
7.8
22
0.666667
7
39
3.714286
1
0
0
0
0
0
0
0
0
0
0
0.645161
0.205128
39
4
23
9.75
0.193548
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
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
5
03d99c746742f5d55164a8acbec96e13619c89b8
230
py
Python
blackfrost_analytics/blackfrost_analytics/doctype/blackfrost_analytics_settings/test_blackfrost_analytics_settings.py
hrazaBFT/blackfrost_analytics
bfe962495fb194e70fe90526871393dcd11097d9
[ "MIT" ]
null
null
null
blackfrost_analytics/blackfrost_analytics/doctype/blackfrost_analytics_settings/test_blackfrost_analytics_settings.py
hrazaBFT/blackfrost_analytics
bfe962495fb194e70fe90526871393dcd11097d9
[ "MIT" ]
null
null
null
blackfrost_analytics/blackfrost_analytics/doctype/blackfrost_analytics_settings/test_blackfrost_analytics_settings.py
hrazaBFT/blackfrost_analytics
bfe962495fb194e70fe90526871393dcd11097d9
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- # Copyright (c) 2021, Hasan Raza and Contributors # See license.txt from __future__ import unicode_literals # import frappe import unittest class TestBlackfrostAnalyticsSettings(unittest.TestCase): pass
20.909091
57
0.778261
27
230
6.444444
0.888889
0
0
0
0
0
0
0
0
0
0
0.025126
0.134783
230
10
58
23
0.849246
0.430435
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
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
1
1
0
1
0
0
5
03f11f7531b9746d3a44d588e157a254de3f9722
36
py
Python
npose_util_pyrosetta/__init__.py
bcov77/npose
0b448b8a5d0ee18f991c9dc00c914def351af548
[ "MIT" ]
1
2021-12-10T02:02:22.000Z
2021-12-10T02:02:22.000Z
npose_util_pyrosetta/__init__.py
bcov77/npose
0b448b8a5d0ee18f991c9dc00c914def351af548
[ "MIT" ]
null
null
null
npose_util_pyrosetta/__init__.py
bcov77/npose
0b448b8a5d0ee18f991c9dc00c914def351af548
[ "MIT" ]
2
2020-05-05T20:03:41.000Z
2020-06-13T15:31:35.000Z
from .npose_util_pyrosetta import *
18
35
0.833333
5
36
5.6
1
0
0
0
0
0
0
0
0
0
0
0
0.111111
36
1
36
36
0.875
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
0
0
0
5
ff0ba4a03cfcf2e9dbfb67474a4a1086f650ea91
52
py
Python
Dreya/Security/Capture.py
esemve/Dreya
76900d1bdf93fa3f8af35013c897c6f888e7619f
[ "MIT" ]
1
2017-02-05T22:33:37.000Z
2017-02-05T22:33:37.000Z
Dreya/Security/Capture.py
esemve/Dreya
76900d1bdf93fa3f8af35013c897c6f888e7619f
[ "MIT" ]
null
null
null
Dreya/Security/Capture.py
esemve/Dreya
76900d1bdf93fa3f8af35013c897c6f888e7619f
[ "MIT" ]
null
null
null
class Capture: def capture(self): pass
10.4
22
0.576923
6
52
5
0.833333
0
0
0
0
0
0
0
0
0
0
0
0.346154
52
4
23
13
0.882353
0
0
0
0
0
0
0
0
0
0
0
0
1
0.333333
false
0.333333
0
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
0
1
0
0
1
0
0
5
ff0e80cad9d0a7793279a546c98f06acbbd6cbcc
393
py
Python
unicode_escape_decode.py
DazEB2/SimplePyScripts
1dde0a42ba93fe89609855d6db8af1c63b1ab7cc
[ "CC-BY-4.0" ]
117
2015-12-18T07:18:27.000Z
2022-03-28T00:25:54.000Z
unicode_escape_decode.py
DazEB2/SimplePyScripts
1dde0a42ba93fe89609855d6db8af1c63b1ab7cc
[ "CC-BY-4.0" ]
8
2018-10-03T09:38:46.000Z
2021-12-13T19:51:09.000Z
unicode_escape_decode.py
DazEB2/SimplePyScripts
1dde0a42ba93fe89609855d6db8af1c63b1ab7cc
[ "CC-BY-4.0" ]
28
2016-08-02T17:43:47.000Z
2022-03-21T08:31:12.000Z
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'ipetrash' text = '\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 (username)' import codecs print(codecs.unicode_internal_decode(text)[0]) # Отсутствует обязательный параметр (username)
35.727273
208
0.765903
55
393
5.363636
0.727273
0.067797
0
0
0
0
0
0
0
0
0
0.324176
0.073791
393
10
209
39.3
0.486264
0.223919
0
0
0
0.25
0.68543
0.615894
0
0
0
0
0
1
0
false
0
0.25
0
0.25
0.25
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
1
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
ff1d4b9fea676310714144507b555a00bf5c91e3
169
py
Python
bookmyslot/admin.py
varunbkk/myportfolio_bookmyslot
bbada313868a8dd164ab04f868470d2b053d401c
[ "MIT" ]
null
null
null
bookmyslot/admin.py
varunbkk/myportfolio_bookmyslot
bbada313868a8dd164ab04f868470d2b053d401c
[ "MIT" ]
null
null
null
bookmyslot/admin.py
varunbkk/myportfolio_bookmyslot
bbada313868a8dd164ab04f868470d2b053d401c
[ "MIT" ]
null
null
null
from django.contrib import admin from bookmyslot.models import Booking,Customer # Register your models here. admin.site.register(Booking) admin.site.register(Customer)
24.142857
46
0.828402
23
169
6.086957
0.565217
0.128571
0.242857
0
0
0
0
0
0
0
0
0
0.094675
169
6
47
28.166667
0.915033
0.153846
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
0
1
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
5
2079ced8baa9c10c70de9ff12cf52a4e00493905
54
py
Python
fry.py
webbo89/halloween
cec43974e2ec096afd7368099cd6c18548d372f4
[ "MIT" ]
null
null
null
fry.py
webbo89/halloween
cec43974e2ec096afd7368099cd6c18548d372f4
[ "MIT" ]
2
2018-10-31T20:02:12.000Z
2018-11-04T02:58:34.000Z
fry.py
webbo89/halloween
cec43974e2ec096afd7368099cd6c18548d372f4
[ "MIT" ]
null
null
null
def fry(): print('The eggs have been fried')
6.75
37
0.574074
8
54
3.875
1
0
0
0
0
0
0
0
0
0
0
0
0.296296
54
7
38
7.714286
0.815789
0
0
0
0
0
0.489796
0
0
0
0
0
0
1
0.5
true
0
0
0
0.5
0.5
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
1
0
0
0
0
1
0
5
208fd37389401926732c602ead2d7231ce24c5ee
141
py
Python
test-mock/example5.py
Cheukting/pytest-examples
2b30bd375e02b115fb85463584590816e4b9a932
[ "MIT" ]
null
null
null
test-mock/example5.py
Cheukting/pytest-examples
2b30bd375e02b115fb85463584590816e4b9a932
[ "MIT" ]
null
null
null
test-mock/example5.py
Cheukting/pytest-examples
2b30bd375e02b115fb85463584590816e4b9a932
[ "MIT" ]
null
null
null
from unittest import mock from b import some_func @mock.patch('a.SomeClass') def test_some_func(mock_func): some_func() assert False
20.142857
30
0.758865
23
141
4.434783
0.608696
0.235294
0.235294
0
0
0
0
0
0
0
0
0
0.156028
141
7
31
20.142857
0.857143
0
0
0
0
0
0.077465
0
0
0
0
0
0.166667
1
0.166667
false
0
0.333333
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
0
0
1
0
0
0
0
5
457dd5186a35362450a41027ddabadee9a984e66
83
py
Python
dashboard/models/__init__.py
muttiopenbts/cascade_spit
27b722390977cb9bd677789617cf049fc5b90539
[ "Apache-2.0" ]
null
null
null
dashboard/models/__init__.py
muttiopenbts/cascade_spit
27b722390977cb9bd677789617cf049fc5b90539
[ "Apache-2.0" ]
null
null
null
dashboard/models/__init__.py
muttiopenbts/cascade_spit
27b722390977cb9bd677789617cf049fc5b90539
[ "Apache-2.0" ]
null
null
null
from .job import Job from .rpc import Rpc from .userpublickey import UserPublicKey
20.75
40
0.819277
12
83
5.666667
0.416667
0
0
0
0
0
0
0
0
0
0
0
0.144578
83
3
41
27.666667
0.957746
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
45cd09ca63467383a7bc67fdaadb86eca1454a7c
340
py
Python
chrono/refiners/filter.py
wanasit/chrono-python
2e3bb44f876fc381a73050d9dda58de296306dc0
[ "MIT" ]
20
2016-07-21T11:27:46.000Z
2022-01-30T16:12:46.000Z
chrono/refiners/filter.py
wanasit/chrono-python
2e3bb44f876fc381a73050d9dda58de296306dc0
[ "MIT" ]
2
2016-11-21T05:46:19.000Z
2019-03-23T06:41:21.000Z
chrono/refiners/filter.py
wanasit/chrono-python
2e3bb44f876fc381a73050d9dda58de296306dc0
[ "MIT" ]
5
2015-06-28T07:21:31.000Z
2020-07-28T19:54:29.000Z
#!/usr/bin/env python # -*- coding: utf8 -*- from ..parsed_result import ParsedResult from ..parsed_result import ParsedComponent from refiner import Refiner class Filter (Refiner): def verify(self, result): return True def refine(self, results, text, options): return [r for r in results if self.verify(r)]
22.666667
53
0.685294
45
340
5.133333
0.622222
0.08658
0.138528
0.190476
0
0
0
0
0
0
0
0.003731
0.211765
340
14
54
24.285714
0.858209
0.120588
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.375
0.25
1
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
1
1
1
0
0
5
afd7e3e99c48a97809f791c5d45319f9964b651a
542
py
Python
ABC151-200/ABC195/abc195_c.py
billyio/atcoder
9d16765f91f28deeb7328fcc6c19541ee790941f
[ "MIT" ]
1
2021-02-01T08:48:07.000Z
2021-02-01T08:48:07.000Z
ABC151-200/ABC195/abc195_c.py
billyio/atcoder
9d16765f91f28deeb7328fcc6c19541ee790941f
[ "MIT" ]
null
null
null
ABC151-200/ABC195/abc195_c.py
billyio/atcoder
9d16765f91f28deeb7328fcc6c19541ee790941f
[ "MIT" ]
null
null
null
N = int(input()) ans = 0 if N < 10 ** 3: print(0) elif 10 ** 3 <= N < 10 ** 6: print(N - 10 ** 3 + 1) elif 10 ** 6 <= N < 10 ** 9: print(10 ** 6 - 10 ** 3 + (N - 10 ** 6 + 1)*2) elif 10 ** 9 <= N < 10 ** 12: print(10 ** 6 - 10 ** 3 + (10 ** 9 - 10 ** 6)*2 + (N - 10 ** 9 + 1)*3) elif 10 ** 12 <= N < 10 ** 15: print(10 ** 6 - 10 ** 3 + (10 ** 9 - 10 ** 6)*2 + (10 ** 12 - 10 ** 9)*3 + (N - 10 ** 12 + 1)*4) else: print(10 ** 6 - 10 ** 3 + (10 ** 9 - 10 ** 6)*2 + (10 ** 12 - 10 ** 9)*3 + (10 ** 15 - 10 ** 12)*4 + 5)
36.133333
108
0.361624
107
542
1.831776
0.17757
0.153061
0.163265
0.204082
0.469388
0.357143
0.357143
0.357143
0.357143
0.357143
0
0.347458
0.346863
542
15
108
36.133333
0.206215
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.428571
0
0
1
null
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
5
affefca91e256d401fec78e3110721d28e53e165
66
py
Python
fissix/__main__.py
orsinium/fissix-py35
48914fcb69842c9fe3c97652870c7610a2cc639b
[ "PSF-2.0" ]
32
2018-07-07T23:55:16.000Z
2022-01-31T03:47:51.000Z
fissix/__main__.py
orsinium/fissix-py35
48914fcb69842c9fe3c97652870c7610a2cc639b
[ "PSF-2.0" ]
35
2018-09-18T22:58:16.000Z
2021-11-13T23:28:21.000Z
fissix/__main__.py
orsinium/fissix-py35
48914fcb69842c9fe3c97652870c7610a2cc639b
[ "PSF-2.0" ]
18
2018-09-21T11:46:32.000Z
2021-11-26T18:08:37.000Z
import sys from .main import main sys.exit(main("fissix.fixes"))
13.2
30
0.742424
11
66
4.454545
0.636364
0
0
0
0
0
0
0
0
0
0
0
0.121212
66
4
31
16.5
0.844828
0
0
0
0
0
0.181818
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
b309dd29bad83acb06b9accf489079aaba6588c6
20
py
Python
new.py
pjp8yf/cs3240-labdemo
23e56df20183795065f0d368be4f0b1d6f63bb18
[ "MIT" ]
null
null
null
new.py
pjp8yf/cs3240-labdemo
23e56df20183795065f0d368be4f0b1d6f63bb18
[ "MIT" ]
null
null
null
new.py
pjp8yf/cs3240-labdemo
23e56df20183795065f0d368be4f0b1d6f63bb18
[ "MIT" ]
null
null
null
print ("new branch")
20
20
0.7
3
20
4.666667
1
0
0
0
0
0
0
0
0
0
0
0
0.1
20
1
20
20
0.777778
0
0
0
0
0
0.47619
0
0
0
0
0
0
1
0
true
0
0
0
0
1
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
0
0
0
1
0
5
2fa3d9dca0dd00879209e5fee9cf6e72761fd389
115
py
Python
cloudentries/fusioncompute/lifecycles/fc_rest_client/common/__init__.py
CloudChef/CloudEntries
a890e2eb96cc537db131e7ca8a0e6e1edc0b6ebd
[ "Apache-2.0" ]
null
null
null
cloudentries/fusioncompute/lifecycles/fc_rest_client/common/__init__.py
CloudChef/CloudEntries
a890e2eb96cc537db131e7ca8a0e6e1edc0b6ebd
[ "Apache-2.0" ]
null
null
null
cloudentries/fusioncompute/lifecycles/fc_rest_client/common/__init__.py
CloudChef/CloudEntries
a890e2eb96cc537db131e7ca8a0e6e1edc0b6ebd
[ "Apache-2.0" ]
1
2021-03-26T05:45:00.000Z
2021-03-26T05:45:00.000Z
# Copyright (c) 2021 Qianyun, Inc. All rights reserved. from .client import RestClient, FusionComputeBase # NOQA
28.75
57
0.765217
14
115
6.285714
1
0
0
0
0
0
0
0
0
0
0
0.041237
0.156522
115
3
58
38.333333
0.865979
0.504348
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
2fb7f567bd14d7a071a0487cc4777ee410fb97c6
220
py
Python
receipt_split/helpers.py
isaaclo123/reciept-split
331a6f16c05d2ee77a2668060c062cbd836939e4
[ "CC-BY-3.0" ]
1
2020-06-27T21:43:56.000Z
2020-06-27T21:43:56.000Z
receipt_split/helpers.py
isaaclo123/reciept-split
331a6f16c05d2ee77a2668060c062cbd836939e4
[ "CC-BY-3.0" ]
1
2021-03-27T20:26:04.000Z
2021-03-27T20:26:04.000Z
receipt_split/helpers.py
isaaclo123/reciept-split
331a6f16c05d2ee77a2668060c062cbd836939e4
[ "CC-BY-3.0" ]
null
null
null
def ok(msg): """OK message :msg: TODO :returns: TODO """ return {"message": str(msg)} def err(msg): """Error message :msg: TODO :returns: TODO """ return {"error": str(msg)}
11.578947
32
0.5
26
220
4.230769
0.384615
0.181818
0.254545
0.381818
0.563636
0.563636
0
0
0
0
0
0
0.318182
220
18
33
12.222222
0.733333
0.354545
0
0
0
0
0.116505
0
0
0
0
0.222222
0
1
0.5
false
0
0
0
1
0
1
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
1
0
0
1
0
0
0
0
0
0
0
5
2fb80d725a7ccc6993867726b137062c62503e12
117
py
Python
tests/dependency-classic/setup.py
benbacardi/poetry-dynamic-versioning
343c782ad72ceb42b155adf92b64af01750d4632
[ "MIT" ]
266
2019-06-11T14:49:44.000Z
2022-03-31T16:41:28.000Z
tests/dependency-classic/setup.py
benbacardi/poetry-dynamic-versioning
343c782ad72ceb42b155adf92b64af01750d4632
[ "MIT" ]
70
2019-09-02T17:23:57.000Z
2022-03-18T17:37:13.000Z
tests/dependency-classic/setup.py
benbacardi/poetry-dynamic-versioning
343c782ad72ceb42b155adf92b64af01750d4632
[ "MIT" ]
20
2019-11-28T10:32:15.000Z
2022-02-22T17:19:32.000Z
from setuptools import setup setup(name="dependency-classic", version="0.0.666", py_modules=["dependency_classic"])
29.25
86
0.777778
16
117
5.5625
0.75
0.382022
0
0
0
0
0
0
0
0
0
0.045872
0.068376
117
3
87
39
0.770642
0
0
0
0
0
0.367521
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
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
0
0
0
5
2fecabe320f42d81bb34bf9a720dd120257db319
92
py
Python
setup.py
dheepdatascigit/pdclean
688185d70511094d24db8c7e3043150ea266ce08
[ "MIT" ]
null
null
null
setup.py
dheepdatascigit/pdclean
688185d70511094d24db8c7e3043150ea266ce08
[ "MIT" ]
null
null
null
setup.py
dheepdatascigit/pdclean
688185d70511094d24db8c7e3043150ea266ce08
[ "MIT" ]
null
null
null
from setuptools import setup, find_packages setup(name="pdtools", packages=find_packages())
30.666667
47
0.815217
12
92
6.083333
0.666667
0.328767
0
0
0
0
0
0
0
0
0
0
0.076087
92
3
47
30.666667
0.858824
0
0
0
0
0
0.075269
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
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
0
0
0
5
64234d92ff5b2fb9becec317149789cb18bf7a03
108
py
Python
pysparkle/frontend/__init__.py
macdems/pysparkle
7d6018e5f2010d6a79fe71bc972bd29c61a113bc
[ "MIT" ]
1
2015-12-19T19:25:15.000Z
2015-12-19T19:25:15.000Z
pysparkle/frontend/__init__.py
macdems/pysparkle
7d6018e5f2010d6a79fe71bc972bd29c61a113bc
[ "MIT" ]
null
null
null
pysparkle/frontend/__init__.py
macdems/pysparkle
7d6018e5f2010d6a79fe71bc972bd29c61a113bc
[ "MIT" ]
null
null
null
# Copyright (c) 2015-2016 Maciej Dems <maciej.dems@p.lodz.pl> # See LICENSE file for copyright information.
36
61
0.759259
17
108
4.823529
0.823529
0.243902
0
0
0
0
0
0
0
0
0
0.085106
0.12963
108
2
62
54
0.787234
0.953704
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
642d45a7c0bbac137d56c32f85e8564e4375cfce
5,278
py
Python
tests/apps/slack_integration/slash_command_test.py
BinSquare/busy-beaver
b8063a7e434eb47e638697719896880781f9783f
[ "MIT" ]
null
null
null
tests/apps/slack_integration/slash_command_test.py
BinSquare/busy-beaver
b8063a7e434eb47e638697719896880781f9783f
[ "MIT" ]
null
null
null
tests/apps/slack_integration/slash_command_test.py
BinSquare/busy-beaver
b8063a7e434eb47e638697719896880781f9783f
[ "MIT" ]
null
null
null
import pytest from busy_beaver.apps.slack_integration.slash_command import ( command_not_found, disconnect_github, display_help_text, link_github, next_event, relink_github, upcoming_events, ) from busy_beaver.config import FULL_INSTALLATION_WORKSPACE_IDS from busy_beaver.models import GitHubSummaryUser pytest_plugins = ("tests._utilities.fixtures.slack",) ######################## # Miscellaneous Commands ######################## @pytest.mark.unit def test_command_help(generate_slash_command_request): data = generate_slash_command_request("help") result = display_help_text(**data) assert "/busybeaver help" in result["text"] @pytest.mark.unit def test_command_not_found(generate_slash_command_request): data = generate_slash_command_request(command="blah") result = command_not_found(**data) assert "/busybeaver help" in result["text"] ########################################## # Associate GitHub account with Slack user ########################################## @pytest.mark.unit def test_connect_command_new_user(session, factory, generate_slash_command_request): install = factory.SlackInstallation() data = generate_slash_command_request( "connect", user_id="new_user", team_id=install.workspace_id ) result = link_github(**data) slack_response = result["attachments"][0] assert "Associate GitHub Profile" in slack_response["actions"][0]["text"] @pytest.mark.unit def test_connect_command_existing_user( session, factory, generate_slash_command_request ): user = factory.GitHubSummaryUser(slack_id="existing_user") data = generate_slash_command_request( "connect", user_id=user.slack_id, team_id=user.installation.workspace_id ) result = link_github(**data) assert "/busybeaver reconnect" in result["text"] @pytest.mark.unit def test_reconnect_command_new_user(session, factory, generate_slash_command_request): install = factory.SlackInstallation() data = generate_slash_command_request( "reconnect", user_id="new_user", team_id=install.workspace_id ) result = relink_github(**data) slack_response = result["attachments"][0] assert "Associate GitHub Profile" in slack_response["actions"][0]["text"] @pytest.mark.unit def test_reconnect_command_existing_user( session, factory, generate_slash_command_request ): user = factory.GitHubSummaryUser(slack_id="existing_user") data = generate_slash_command_request( "reconnect", user_id=user.slack_id, team_id=user.installation.workspace_id ) result = relink_github(**data) slack_response = result["attachments"][0] assert "Associate GitHub Profile" in slack_response["actions"][0]["text"] @pytest.mark.unit def test_disconnect_command_unregistered_user( session, factory, generate_slash_command_request ): install = factory.SlackInstallation() data = generate_slash_command_request("disconnect", team_id=install.workspace_id) result = disconnect_github(**data) assert "No GitHub account associated with profile" in result["text"] @pytest.mark.unit def test_disconnect_command_registered_user( session, factory, generate_slash_command_request ): user = factory.GitHubSummaryUser(slack_id="existing_user") data = generate_slash_command_request( "disconnect", user_id=user.slack_id, team_id=user.installation.workspace_id ) result = disconnect_github(**data) assert "Account has been deleted" in result["text"] assert not GitHubSummaryUser.query.get(user.id) ######################### # Upcoming Event Schedule ######################### @pytest.mark.end2end def test_command_next_workspace_not_allowed( session, factory, generate_slash_command_request ): factory.Event.create_batch(size=10) data = generate_slash_command_request("next", team_id="not allowed") result = next_event(**data) assert "command not supported" in result["text"].lower() @pytest.mark.end2end def test_command_next_workspace_allowed( session, factory, generate_slash_command_request ): factory.Event.create_batch(size=10) workspace_id = FULL_INSTALLATION_WORKSPACE_IDS[0] data = generate_slash_command_request("next", team_id=workspace_id) result = next_event(**data) assert result["response_type"] == "ephemeral" assert result["attachments"] assert not result["blocks"] assert not result["text"] @pytest.mark.end2end def test_command_events_workspace_not_allowed( session, factory, generate_slash_command_request ): factory.Event.create_batch(size=10) data = generate_slash_command_request("events", team_id="not_allowed") result = upcoming_events(**data) assert "command not supported" in result["text"].lower() @pytest.mark.end2end def test_command_events_workspace_allowed( session, factory, generate_slash_command_request ): factory.Event.create_batch(size=10) workspace_id = FULL_INSTALLATION_WORKSPACE_IDS[0] data = generate_slash_command_request("events", team_id=workspace_id) result = upcoming_events(**data) assert result["response_type"] == "ephemeral" assert result["blocks"] assert not result["attachments"] assert not result["text"]
29.160221
86
0.730011
633
5,278
5.759874
0.139021
0.082282
0.131651
0.177729
0.834888
0.778387
0.7548
0.709819
0.59819
0.566374
0
0.004409
0.140584
5,278
180
87
29.322222
0.799383
0.016484
0
0.570248
0
0
0.11988
0.006194
0
0
0
0
0.157025
1
0.099174
false
0
0.033058
0
0.132231
0
0
0
0
null
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
643a178b200206705476e101175f6f97ed9e858d
132
py
Python
src/io.py
tbjohns/python-util
b7115f78a12d1dff7227f46a046b9edde28fa2a9
[ "MIT" ]
null
null
null
src/io.py
tbjohns/python-util
b7115f78a12d1dff7227f46a046b9edde28fa2a9
[ "MIT" ]
null
null
null
src/io.py
tbjohns/python-util
b7115f78a12d1dff7227f46a046b9edde28fa2a9
[ "MIT" ]
null
null
null
import cPickle def pickle(obj, path): cPickle.dump(obj, open(path, "w")) def unpickle(path): return cPickle.load(open(path))
14.666667
36
0.69697
20
132
4.6
0.6
0.173913
0
0
0
0
0
0
0
0
0
0
0.143939
132
8
37
16.5
0.814159
0
0
0
0
0
0.007634
0
0
0
0
0
0
1
0.4
false
0
0.2
0.2
0.8
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
5
ff7d241b47059bdafd3cd790fe33c5aab2294ede
149
py
Python
cowsay_app/admin.py
BethanyFolino/cowsay
0608eff760adc29f32db3a4868e9fcfb57c8992b
[ "MIT" ]
null
null
null
cowsay_app/admin.py
BethanyFolino/cowsay
0608eff760adc29f32db3a4868e9fcfb57c8992b
[ "MIT" ]
null
null
null
cowsay_app/admin.py
BethanyFolino/cowsay
0608eff760adc29f32db3a4868e9fcfb57c8992b
[ "MIT" ]
null
null
null
from django.contrib import admin from cowsay_app.models import WhatDoesTheCowSay # Register your models here. admin.site.register(WhatDoesTheCowSay)
29.8
47
0.852349
19
149
6.631579
0.684211
0
0
0
0
0
0
0
0
0
0
0
0.09396
149
5
48
29.8
0.933333
0.174497
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
ff85f65052328b15ec8cb818ec43b859f19cd08c
91
py
Python
src/SEIRcity/cli/ptypes/__init__.py
UT-Covid/compartmental_model_case_studies
324e2c92453c928e64c637d6e6fbe570fb714cdb
[ "BSD-3-Clause-Clear" ]
1
2021-02-04T14:59:32.000Z
2021-02-04T14:59:32.000Z
src/SEIRcity/cli/ptypes/__init__.py
UT-Covid/compartmental_model_case_studies
324e2c92453c928e64c637d6e6fbe570fb714cdb
[ "BSD-3-Clause-Clear" ]
null
null
null
src/SEIRcity/cli/ptypes/__init__.py
UT-Covid/compartmental_model_case_studies
324e2c92453c928e64c637d6e6fbe570fb714cdb
[ "BSD-3-Clause-Clear" ]
null
null
null
"""Parameter types """ from .input import * from .param import * from .composite import *
13
24
0.692308
11
91
5.727273
0.636364
0.31746
0
0
0
0
0
0
0
0
0
0
0.175824
91
6
25
15.166667
0.84
0.164835
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
0
0
0
5
ff9a8bad5cfaa702fb8947ef6c59579a3d784f45
310
py
Python
api/models.py
nikochiko/server
299953687be7adbd35df608b288546c8df90371c
[ "MIT" ]
43
2018-05-23T10:03:40.000Z
2021-09-02T15:55:52.000Z
api/models.py
nikochiko/server
299953687be7adbd35df608b288546c8df90371c
[ "MIT" ]
141
2018-05-24T16:03:12.000Z
2021-04-30T23:47:59.000Z
api/models.py
nikochiko/server
299953687be7adbd35df608b288546c8df90371c
[ "MIT" ]
77
2018-06-13T13:51:31.000Z
2021-06-16T16:10:18.000Z
from api.modules.city.model import City, CityFact, CityImage, CityVisitLog from api.modules.trips.model import Trip from api.modules.feedback.model import Feedback from api.modules.users.model import Profile, PasswordVerification from api.modules.notification.model import Notification, NotificationTypeChoice
51.666667
79
0.854839
40
310
6.625
0.425
0.132075
0.264151
0
0
0
0
0
0
0
0
0
0.080645
310
5
80
62
0.929825
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0.2
1
0
1
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
1
1
0
0
0
0
5
4428743c6625514a61bae6401758d954b54c190f
4,226
py
Python
Testing/test_Timoshenko.py
JWock82/PyNite
4338f92dd981ca0cc275799ee5727a49d0e3d2d1
[ "MIT" ]
199
2019-04-12T05:30:43.000Z
2022-03-29T23:42:01.000Z
Testing/test_Timoshenko.py
mohashrafy/PyNite
efffccdbff6727d3b271ba2937e35892d9df8c00
[ "MIT" ]
103
2019-07-22T19:41:26.000Z
2022-03-31T22:18:32.000Z
Testing/test_Timoshenko.py
mohashrafy/PyNite
efffccdbff6727d3b271ba2937e35892d9df8c00
[ "MIT" ]
69
2019-02-07T12:02:01.000Z
2022-03-24T13:24:38.000Z
import unittest from PyNite import FEModel3D from PyNite.Mesh import FrustrumMesh, CylinderMesh, RectangleMesh import math import sys from io import StringIO class Test_Timoshenko(unittest.TestCase): # Tests against problems with known solutions from `Theory of Plates & Shells` by Timoshenko def setUp(self): # Suppress printed output temporarily sys.stdout = StringIO() def tearDown(self): # Reset the print function to normal behavior sys.stdout = sys.__stdout__ def test_hydrostatic_plate(self): # Establish problem parameters t = 1 # ft E = 57000*math.sqrt(4500)*12**2 # psf nu = 1/6 mesh_size = 1 # ft a = 10 # ft b = 15 # ft # Generate the mesh of plates plate_mesh = RectangleMesh(t, E, nu, mesh_size, a, b, element_type='Rect') plate_mesh.generate() # Create the model and add the plates plate_model = FEModel3D() plate_model.add_mesh(plate_mesh) # Add supports to the sides and base of the wall for node in plate_model.Nodes.values(): if node.X == 0 or node.X == a or node.Y == 0: plate_model.def_support(node.Name, True, True, True, True, True, True) # Add hydrostatic loads to the elements for element in plate_model.Plates.values(): Yavg = (element.i_node.Y + element.j_node.Y + element.m_node.Y + element.n_node.Y)/4 p = 62.4*(b - Yavg) plate_model.add_plate_surface_pressure(element.Name, p, 'Hydrostatic') # Add a load combination to the model plate_model.add_load_combo('F', {'Hydrostatic': 1.0}) # Analyze the model plate_model.analyze() # Get the maximum deflection in the model at the top of the wall DZ_calcd = max([node.DZ['F'] for node in plate_model.Nodes.values() if node.Y == b]) # Find the maximum deflection at the top of the wall from Timoshenko's Table 45 q = 62.4*b D = E*t**3/(12*(1 - nu**2)) DZ_expected = 0.00042*q*a**4/D # Check that the PyNite calculated values are within 15% of the Timoshenko calculated # values. self.assertLess(abs(DZ_calcd/DZ_expected - 1), 0.15, 'Failed Timoshenko rectangle hydrostatic test.') def test_hydrostatic_quad(self): # Establish problem parameters t = 1 # ft E = 57000*math.sqrt(4500)*12**2 # psf nu = 1/6 mesh_size = 1 # ft a = 10 # ft b = 15 # ft # Generate the mesh of plates plate_mesh = RectangleMesh(t, E, nu, mesh_size, a, b, element_type='Quad') plate_mesh.generate() # Create the model and add the plates plate_model = FEModel3D() plate_model.add_mesh(plate_mesh) # Add supports to the sides and base of the wall for node in plate_model.Nodes.values(): if node.X == 0 or node.X == a or node.Y == 0: plate_model.def_support(node.Name, True, True, True, True, True, True) # Add hydrostatic loads to the elements for element in plate_model.Quads.values(): Yavg = (element.i_node.Y + element.j_node.Y + element.m_node.Y + element.n_node.Y)/4 p = 62.4*(b - Yavg) plate_model.add_quad_surface_pressure(element.Name, p, 'Hydrostatic') # Add a load combination to the model plate_model.add_load_combo('F', {'Hydrostatic': 1.0}) # Analyze the model plate_model.analyze() # Get the maximum deflection in the model at the top of the wall DZ_calcd = max([node.DZ['F'] for node in plate_model.Nodes.values() if node.Y == b]) # Find the maximum deflection at the top of the wall from Timoshenko's Table 45 q = 62.4*b D = E*t**3/(12*(1 - nu**2)) DZ_expected = 0.00042*q*a**4/D # Check that the PyNite calculated values are within 15% of the Timoshenko calculated # values. self.assertLess(abs(DZ_calcd/DZ_expected - 1), 0.15, 'Failed Timoshenko quadrilateral hydrostatic test.')
37.732143
117
0.605064
607
4,226
4.098847
0.2257
0.072347
0.038585
0.038585
0.799035
0.799035
0.799035
0.799035
0.799035
0.799035
0
0.035581
0.301704
4,226
111
118
38.072072
0.807523
0.267866
0
0.655738
0
0
0.049052
0
0
0
0
0
0.032787
1
0.065574
false
0
0.098361
0
0.180328
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
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
443893a90c52b21bd2c1099c0d7a63d6618d0ef5
38
py
Python
jsnapshot_cron/__init__.py
melianmiko/JustSnapshot
4e0fd76c66c81113f7507944a6719607945be50d
[ "BSD-2-Clause" ]
1
2022-01-25T19:34:30.000Z
2022-01-25T19:34:30.000Z
jsnapshot_cron/__init__.py
melianmiko/JustSnapshot
4e0fd76c66c81113f7507944a6719607945be50d
[ "BSD-2-Clause" ]
null
null
null
jsnapshot_cron/__init__.py
melianmiko/JustSnapshot
4e0fd76c66c81113f7507944a6719607945be50d
[ "BSD-2-Clause" ]
null
null
null
"""This is CLI module for cron job"""
19
37
0.657895
7
38
3.571429
1
0
0
0
0
0
0
0
0
0
0
0
0.184211
38
1
38
38
0.806452
0.815789
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
444524c5ac7008a2aa87fd83dea7dd4325dd8101
39
py
Python
ex02/name.py
CoderDojo-Karlskrona/python-exercises
b22dd8a642b67d1c18790643718f133d7fc470fe
[ "Apache-2.0" ]
null
null
null
ex02/name.py
CoderDojo-Karlskrona/python-exercises
b22dd8a642b67d1c18790643718f133d7fc470fe
[ "Apache-2.0" ]
null
null
null
ex02/name.py
CoderDojo-Karlskrona/python-exercises
b22dd8a642b67d1c18790643718f133d7fc470fe
[ "Apache-2.0" ]
null
null
null
print "Peter Nerg" print "supergammal"
13
19
0.769231
5
39
6
0.8
0
0
0
0
0
0
0
0
0
0
0
0.128205
39
2
20
19.5
0.882353
0
0
0
0
0
0.538462
0
0
0
0
0
0
0
null
null
0
0
null
null
1
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
1
0
0
0
0
0
0
1
0
5
448111ab9c798457c5e1f7c0810b78dc20e53908
6,189
py
Python
tests/test_api_functional.py
Zenlytic/granite
93cc523954b1b900d7893af803a8fb3e5fc7d343
[ "Apache-2.0" ]
null
null
null
tests/test_api_functional.py
Zenlytic/granite
93cc523954b1b900d7893af803a8fb3e5fc7d343
[ "Apache-2.0" ]
null
null
null
tests/test_api_functional.py
Zenlytic/granite
93cc523954b1b900d7893af803a8fb3e5fc7d343
[ "Apache-2.0" ]
null
null
null
import pandas as pd from metrics_layer.core.model import Project from metrics_layer.core.parse import MetricsLayerConfiguration from metrics_layer.core.sql import QueryRunner def test_api_query(client, monkeypatch, models, views, add_user_and_get_auth): _, token = add_user_and_get_auth("query@test.com", "test") repo_config = {"repo_url": "https://github.com", "branch": "dev", "repo_type": "metrics_layer"} connections = [ { "type": "SNOWFLAKE", "name": "sf_name", "account": "sf_account", "username": "sf_username", "password": "sf_password", }, { "type": "BIGQUERY", "name": "bq_name", "credentials": '{"key": "value", "project_id": "test-1234"}', }, ] config = MetricsLayerConfiguration(repo_config=repo_config, connections=connections) # Add reference to snowflake creds sf_models = [{**m, "connection": "sf_name"} for m in models] project = Project(models=sf_models, views=views, looker_env="prod") config._project = project monkeypatch.setattr( MetricsLayerConfiguration, "get_metrics_layer_configuration", lambda *args, **kwargs: config ) correct_df = pd.DataFrame({"dimension": ["cat1", "cat2", "cat3"], "metric": [12, 21, 34]}) monkeypatch.setattr(QueryRunner, "_run_snowflake_query", lambda *args, **kwargs: correct_df) query_args = {"metrics": ["total_item_revenue"], "dimensions": ["channel"]} response = client.post(f"api/v1/query", json=query_args, headers={"Authorization": f"Bearer {token}"}) data = response.get_json() assert data["data"] == correct_df.to_dict("records") def test_api_convert_sql(client, monkeypatch, models, views, add_user_and_get_auth): _, token = add_user_and_get_auth("convert@test.com", "test") repo_config = {"repo_url": "https://github.com", "branch": "dev", "repo_type": "metrics_layer"} connections = [ { "type": "SNOWFLAKE", "name": "sf_name", "account": "sf_account", "username": "sf_username", "password": "sf_password", }, { "type": "BIGQUERY", "name": "bq_name", "credentials": '{"key": "value", "project_id": "test-1234"}', }, ] config = MetricsLayerConfiguration(repo_config=repo_config, connections=connections) # Add reference to snowflake creds sf_models = [{**m, "connection": "sf_name"} for m in models] project = Project(models=sf_models, views=views, looker_env="prod") config._project = project monkeypatch.setattr( MetricsLayerConfiguration, "get_metrics_layer_configuration", lambda *args, **kwargs: config ) mql_query = "SELECT * FROM MQL(total_item_revenue BY channel)" response = client.post( f"api/v1/convert", json={"query": mql_query}, headers={"Authorization": f"Bearer {token}"} ) data = response.get_json() correct = ( "SELECT * FROM (SELECT order_lines.sales_channel as order_lines_channel,SUM(order_lines.revenue) as " "order_lines_total_item_revenue FROM analytics.order_line_items order_lines " "GROUP BY order_lines.sales_channel);" ) assert data["data"] == correct def test_api_list_metrics(client, monkeypatch, project, add_user_and_get_auth): _, token = add_user_and_get_auth("list_metrics@test.com", "test") monkeypatch.setenv("METRICS_LAYER_REPO_URL", "https://github.com") monkeypatch.setenv("METRICS_LAYER_BRANCH", "dev") monkeypatch.setenv("METRICS_LAYER_REPO_TYPE", "metrics_layer") monkeypatch.setattr(MetricsLayerConfiguration, "_get_project", lambda *args, **kwargs: project) response = client.get(f"api/v1/metrics", headers={"Authorization": f"Bearer {token}"}) data = response.get_json() assert len(data["data"]) == 18 def test_api_list_dimensions(client, monkeypatch, project, add_user_and_get_auth): _, token = add_user_and_get_auth("list_dimensions@test.com", "test") monkeypatch.setenv("METRICS_LAYER_REPO_URL", "https://github.com") monkeypatch.setenv("METRICS_LAYER_BRANCH", "dev") monkeypatch.setenv("METRICS_LAYER_REPO_TYPE", "metrics_layer") monkeypatch.setattr(MetricsLayerConfiguration, "_get_project", lambda *args, **kwargs: project) response = client.get(f"api/v1/dimensions", headers={"Authorization": f"Bearer {token}"}) data = response.get_json() assert len(data["data"]) == 27 def test_api_get_metric(client, monkeypatch, project, add_user_and_get_auth): _, token = add_user_and_get_auth("get_metric@test.com", "test") monkeypatch.setenv("METRICS_LAYER_REPO_URL", "https://github.com") monkeypatch.setenv("METRICS_LAYER_BRANCH", "dev") monkeypatch.setenv("METRICS_LAYER_REPO_TYPE", "metrics_layer") monkeypatch.setattr(MetricsLayerConfiguration, "_get_project", lambda *args, **kwargs: project) response = client.get(f"api/v1/metrics/total_item_revenue", headers={"Authorization": f"Bearer {token}"}) data = response.get_json() assert isinstance(data["data"], dict) assert data["data"]["name"] == "total_item_revenue" assert data["data"]["sql_raw"] == "${TABLE}.revenue" assert data["data"]["type"] == "sum" assert data["data"]["field_type"] == "measure" def test_api_get_dimension(client, monkeypatch, project, add_user_and_get_auth): _, token = add_user_and_get_auth("get_dimension@test.com", "test") monkeypatch.setenv("METRICS_LAYER_REPO_URL", "https://github.com") monkeypatch.setenv("METRICS_LAYER_BRANCH", "dev") monkeypatch.setenv("METRICS_LAYER_REPO_TYPE", "metrics_layer") monkeypatch.setattr(MetricsLayerConfiguration, "_get_project", lambda *args, **kwargs: project) response = client.get(f"api/v1/dimensions/new_vs_repeat", headers={"Authorization": f"Bearer {token}"}) data = response.get_json() assert isinstance(data["data"], dict) assert data["data"]["name"] == "new_vs_repeat" assert data["data"]["sql_raw"] == "${TABLE}.new_vs_repeat" assert data["data"]["type"] == "string" assert data["data"]["field_type"] == "dimension"
41.536913
109
0.677169
739
6,189
5.385656
0.163735
0.069347
0.030151
0.039196
0.775879
0.764322
0.742714
0.727136
0.727136
0.714322
0
0.005271
0.172403
6,189
148
110
41.817568
0.771769
0.010503
0
0.495575
0
0
0.319556
0.092959
0
0
0
0
0.123894
1
0.053097
false
0.017699
0.035398
0
0.088496
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
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
926014d93bd038af4a6058f1c5764e6513407f20
71
py
Python
helpers.py
georgknabl/human-password-classifier
14470998e2e05fc5c61776250c4edb0edb397fd0
[ "MIT" ]
5
2018-11-09T08:08:26.000Z
2021-08-09T10:03:36.000Z
helpers.py
georgknabl/human-password-classifier
14470998e2e05fc5c61776250c4edb0edb397fd0
[ "MIT" ]
null
null
null
helpers.py
georgknabl/human-password-classifier
14470998e2e05fc5c61776250c4edb0edb397fd0
[ "MIT" ]
2
2018-11-14T18:47:06.000Z
2020-12-15T07:36:03.000Z
def tokenizer(text): # character-based tokens return list(text)
23.666667
28
0.704225
9
71
5.555556
0.888889
0
0
0
0
0
0
0
0
0
0
0
0.197183
71
3
29
23.666667
0.877193
0.309859
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
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
5
92b47758e4106dc31aea5a6145c188bca6cb114e
358
py
Python
tests/pymath/test_population_growth.py
JASTYN/pythonmaster
46638ab09d28b65ce5431cd0759fe6df272fb85d
[ "Apache-2.0", "MIT" ]
3
2017-05-02T10:28:13.000Z
2019-02-06T09:10:11.000Z
tests/pymath/test_population_growth.py
JASTYN/pythonmaster
46638ab09d28b65ce5431cd0759fe6df272fb85d
[ "Apache-2.0", "MIT" ]
2
2017-06-21T20:39:14.000Z
2020-02-25T10:28:57.000Z
tests/pymath/test_population_growth.py
JASTYN/pythonmaster
46638ab09d28b65ce5431cd0759fe6df272fb85d
[ "Apache-2.0", "MIT" ]
2
2016-07-29T04:35:22.000Z
2017-01-18T17:05:36.000Z
import unittest from pymath.population_growth import nb_year class Tests(unittest.TestCase): def test_1(self): self.assertEqual(nb_year(1500, 5, 100, 5000), 15) def test_2(self): self.assertEqual(nb_year(1500000, 2.5, 10000, 2000000), 10) def test_3(self): self.assertEqual(nb_year(1500000, 0.25, 1000, 2000000), 94)
23.866667
67
0.684358
54
358
4.388889
0.574074
0.101266
0.240506
0.265823
0.375527
0.270042
0
0
0
0
0
0.21875
0.195531
358
14
68
25.571429
0.604167
0
0
0
0
0
0
0
0
0
0
0
0.333333
1
0.333333
false
0
0.222222
0
0.666667
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
5
2ba8442b4c6e36c13ad1f34ad78b9bb605f70fd7
72
py
Python
ex2.py
MayThuHtun/python-exercises
0f4e85aa9d78855bfdb5c04ff9278799c338e0e5
[ "MIT" ]
null
null
null
ex2.py
MayThuHtun/python-exercises
0f4e85aa9d78855bfdb5c04ff9278799c338e0e5
[ "MIT" ]
null
null
null
ex2.py
MayThuHtun/python-exercises
0f4e85aa9d78855bfdb5c04ff9278799c338e0e5
[ "MIT" ]
null
null
null
print("I could have code like this.") print("This will run this text.")
24
37
0.708333
13
72
3.923077
0.769231
0
0
0
0
0
0
0
0
0
0
0
0.152778
72
2
38
36
0.836066
0
0
0
0
0
0.722222
0
0
0
0
0
0
1
0
true
0
0
0
0
1
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
5
2bae6d5aa43b5cc99b94417ab86dbdf6ef7e65cf
159
py
Python
misago/misago/cache/apps.py
vascoalramos/misago-deployment
20226072138403108046c0afad9d99eb4163cedc
[ "MIT" ]
2
2021-03-06T21:06:13.000Z
2021-03-09T15:05:12.000Z
misago/misago/cache/apps.py
vascoalramos/misago-deployment
20226072138403108046c0afad9d99eb4163cedc
[ "MIT" ]
null
null
null
misago/misago/cache/apps.py
vascoalramos/misago-deployment
20226072138403108046c0afad9d99eb4163cedc
[ "MIT" ]
null
null
null
from django.apps import AppConfig class MisagoCacheConfig(AppConfig): name = "misago.cache" label = "misago_cache" verbose_name = "Misago Cache"
19.875
35
0.72327
18
159
6.277778
0.666667
0.292035
0.265487
0
0
0
0
0
0
0
0
0
0.188679
159
7
36
22.714286
0.875969
0
0
0
0
0
0.226415
0
0
0
0
0
0
1
0
false
0
0.2
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
0
0
0
0
1
0
0
5
2bf1ef64588e8705c51f6e684139279d7b319a53
139
py
Python
dvc/dependency/gs.py
kaiogu/dvc
ffa8fe5888dbbb3d37b3874562f99fd77d4bbcb7
[ "Apache-2.0" ]
3
2020-01-31T05:33:14.000Z
2021-05-20T08:19:25.000Z
dvc/dependency/gs.py
kaiogu/dvc
ffa8fe5888dbbb3d37b3874562f99fd77d4bbcb7
[ "Apache-2.0" ]
null
null
null
dvc/dependency/gs.py
kaiogu/dvc
ffa8fe5888dbbb3d37b3874562f99fd77d4bbcb7
[ "Apache-2.0" ]
null
null
null
from dvc.dependency.base import DependencyBase from dvc.output.gs import OutputGS class DependencyGS(DependencyBase, OutputGS): pass
19.857143
46
0.81295
17
139
6.647059
0.705882
0.123894
0
0
0
0
0
0
0
0
0
0
0.129496
139
6
47
23.166667
0.933884
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
0
0
0
5
2bf39b1100e99a03e4f6d672181c864c68370538
46
py
Python
minos/api_gateway/discovery/database/__init__.py
Clariteia/discovery
e1ae93a1e9cc12f345fd01bd7feef46e28de125d
[ "MIT" ]
3
2021-05-14T09:11:21.000Z
2021-10-04T08:37:51.000Z
minos/api_gateway/discovery/database/__init__.py
Clariteia/discovery
e1ae93a1e9cc12f345fd01bd7feef46e28de125d
[ "MIT" ]
45
2021-05-14T08:46:58.000Z
2022-01-27T13:00:45.000Z
minos/api_gateway/discovery/database/__init__.py
Clariteia/discovery
e1ae93a1e9cc12f345fd01bd7feef46e28de125d
[ "MIT" ]
1
2022-03-03T10:32:55.000Z
2022-03-03T10:32:55.000Z
from .client import ( MinosRedisClient, )
11.5
21
0.695652
4
46
8
1
0
0
0
0
0
0
0
0
0
0
0
0.217391
46
3
22
15.333333
0.888889
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
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
0
0
0
5
92180338667153c14f6a78952d4a7a68212e5f2d
7,479
py
Python
velos.py
fsiamp/velos-generator
2faf82a508ab6b1f07edce23a2e3402ff35b165b
[ "MIT" ]
5
2018-01-04T06:46:39.000Z
2018-08-12T08:00:21.000Z
velos.py
fsiamp/velos-generator
2faf82a508ab6b1f07edce23a2e3402ff35b165b
[ "MIT" ]
2
2016-09-17T06:48:44.000Z
2016-09-17T08:10:24.000Z
velos.py
fsiamp/velos
2faf82a508ab6b1f07edce23a2e3402ff35b165b
[ "MIT" ]
null
null
null
#!/usr/bin/python import random import decimal import time from random import randint attack = ['attempted-admin','attempted-user','inappropriate-content','policy-violationn','shellcode-detect','successful-admin','successful-user', 'trojan-activity','unsuccessful-user','web-application-attack','attempted-dos','attempted-recon','bad-unknown','default-login-attempt','denial-of-service','misc-attack','non-standard-protocol','rpc-portmap-decode','successful-dos','successful-recon-largescale', 'successful-recon-limited','suspicious-filename-detect','suspicious-login','system-call-detect','unusual-client-port-connection','web-application-activity','icmp-event','misc-activity','network-scan','not-suspicious','protocol-command-decode','string-detect','unknown','tcp-connection', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal'] protocol = [ 'tcp', 'udp','icmp'] service = ['aol', 'auth', 'bgp', 'courier', 'csnet_ns', 'ctf', 'daytime', 'discard', 'domain', 'domain_u', 'echo', 'eco_i', 'ecr_i', 'efs', 'exec', 'finger', 'ftp', 'ftp_data', 'gopher', 'harvest', 'hostnames', 'http', 'http_2784', 'http_443', 'http_8001', 'imap4', 'IRC', 'iso_tsap', 'klogin', 'kshell', 'ldap', 'link', 'login', 'mtp', 'name', 'netbios_dgm', 'netbios_ns', 'netbios_ssn', 'netstat', 'nnsp', 'nntp', 'ntp_u', 'other', 'pm_dump', 'pop_2', 'pop_3', 'printer', 'private', 'red_i', 'remote_job', 'rje', 'shell', 'smtp', 'sql_net', 'ssh', 'sunrpc', 'supdup', 'systat', 'telnet', 'tftp_u', 'tim_i', 'time', 'urh_i', 'urp_i', 'uucp', 'uucp_path', 'vmnet', 'whois', 'X11', 'Z39_50'] flag = [ 'OTH', 'REJ', 'RSTO', 'RSTOS0', 'RSTR', 'S0', 'S1', 'S2', 'S3', 'SF', 'SH' ] counter2 = randint(100,2000) print '\r' var = randint(3000,8000) print 'Generating Dataset ...' print '\r' time.sleep(1) count = 1 file1 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file2 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file3 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file4 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file5 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file6 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file7 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file8 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file9 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") file10 = random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ0123456789") f = open('datasets/' + file1 + file2 + file3 + file4 + file5 + file6 + file7 + file8 + file9 + file10 + '.data','w') while (count <= var): duration = str(randint(0,255)) src_bytes = str(randint(0,255)) dst_bytes = str(randint(0,255)) land = str(randint(0,1)) wrong_fragment = str(randint(0,255)) urgent = str(randint(0,255)) hot = str(randint(0,255)) num_failed_logins = str(randint(0,255)) logged_in = str(randint(0,1)) num_compromised = str(randint(0,255)) root_shell = str(randint(0,155)) su_attempted = str(randint(0,99255)) num_root = str(randint(0,99255)) num_file_creations = str(randint(0,99255)) num_shells = str(randint(0,99255)) num_access_files = str(randint(0,99255)) num_outbound_cmds = str(randint(0,700)) is_host_login = str(randint(0,1)) is_guest_login = str(randint(0,1)) countz= str(randint(0,1000)) srv_count = str(randint(0,1000)) serror_rate = str(randint(0,100)/100) srv_serror_rate = str(decimal.Decimal(random.randrange(100))/100) rerror_rate = str(decimal.Decimal(random.randrange(100))/100) srv_rerror_rate = str(decimal.Decimal(random.randrange(100))/100) src_port= str(randint(0,65535)) dst_port= str(randint(0,65535)) average_rtt = str(randint(0,500)) iplen = str(randint(0,400)) ethlen = str(randint(0,400)) stan_dev_rtt = str(randint(0,500)) same_srv_rate = str(decimal.Decimal(random.randrange(100))/100) diff_srv_rate = str(decimal.Decimal(random.randrange(100))/100) srv_diff_host_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_count = str(randint(0,1000)) dst_host_srv_count = str(randint(0,1000)) dst_host_same_srv_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_diff_srv_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_same_src_port_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_srv_diff_host_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_serror_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_srv_serror_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_rerror_rate = str(decimal.Decimal(random.randrange(100))/100) dst_host_srv_rerror_rate = str(decimal.Decimal(random.randrange(100))/100) capture = duration + ',' + random.choice(protocol) + ',' + random.choice(flag) + ',' + src_bytes + ',' + dst_bytes + ',' + land + ',' + wrong_fragment + ',' + urgent + ',' + hot + ',' + num_failed_logins + ',' + logged_in + ',' + num_compromised + ',' + root_shell + ',' + su_attempted + ',' + random.choice(service) + ',' + num_root + ',' + num_file_creations + ',' + num_shells + ',' + num_access_files + ',' + num_outbound_cmds + ',' + is_host_login + ',' + is_guest_login + ',' + countz + ',' + srv_count + ',' + serror_rate + ',' + srv_serror_rate + ',' + rerror_rate + ',' + srv_rerror_rate + ',' + src_port + ',' + dst_port + ',' + average_rtt + ',' + iplen + ',' + ethlen + ',' + stan_dev_rtt + ',' + same_srv_rate + ',' + diff_srv_rate + ',' + srv_diff_host_rate + ',' + dst_host_count + ',' + dst_host_srv_count + ',' + dst_host_same_srv_rate + ',' + dst_host_diff_srv_rate + ',' + dst_host_same_src_port_rate + ',' + dst_host_srv_diff_host_rate + ',' + dst_host_serror_rate + ',' + dst_host_srv_serror_rate + ',' + dst_host_rerror_rate + ',' + dst_host_srv_rerror_rate + ',' + random.choice(attack) f.write(capture + '\n') count = count + 1 print 'New dataset was exported successfully to',file1 + file2 + file3 + file4 + file5 + file6 + file7 + file8 + file9 + file10 + '.data' f.close() print '\r'
77.90625
1,744
0.670277
892
7,479
5.419283
0.269058
0.258171
0.383533
0.506413
0.407323
0.341746
0.31899
0.30782
0.30782
0.296649
0
0.061066
0.137318
7,479
95
1,745
78.726316
0.688159
0.002139
0
0.038961
0
0
0.321539
0.113792
0
0
0
0
0
0
null
null
0
0.051948
null
null
0.077922
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
5
a6106143f97e1c868ca5882e4d27a315b1449f80
223
py
Python
scripts/item/consume_2433184.py
G00dBye/YYMS
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
[ "MIT" ]
54
2019-04-16T23:24:48.000Z
2021-12-18T11:41:50.000Z
scripts/item/consume_2433184.py
G00dBye/YYMS
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
[ "MIT" ]
3
2019-05-19T15:19:41.000Z
2020-04-27T16:29:16.000Z
scripts/item/consume_2433184.py
G00dBye/YYMS
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
[ "MIT" ]
49
2020-11-25T23:29:16.000Z
2022-03-26T16:20:24.000Z
# Created by MechAviv # Wicked Witch Damage Skin | (2433184) if sm.addDamageSkin(2433184): sm.chat("'Wicked Witch Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
44.6
111
0.73991
32
223
5.15625
0.65625
0.242424
0.206061
0.254545
0
0
0
0
0
0
0
0.075269
0.165919
223
5
112
44.6
0.811828
0.251121
0
0
0
0
0.581818
0
0
0
0
0
0
1
0
true
0
0
0
0
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
0
0
0
0
0
5
a621225802ebe987ecb3dc6ed861b498df1214f1
91
py
Python
pyogcapi/component/__init__.py
ashleysommer/pyogcapi
9ffac35e76993f2cb5d9929e4b12923f9d767675
[ "Apache-2.0" ]
null
null
null
pyogcapi/component/__init__.py
ashleysommer/pyogcapi
9ffac35e76993f2cb5d9929e4b12923f9d767675
[ "Apache-2.0" ]
null
null
null
pyogcapi/component/__init__.py
ashleysommer/pyogcapi
9ffac35e76993f2cb5d9929e4b12923f9d767675
[ "Apache-2.0" ]
null
null
null
# -*- coding: latin-1 -*- # import pkg_resources pkg_resources.declare_namespace(__name__)
18.2
41
0.758242
11
91
5.636364
0.818182
0.387097
0
0
0
0
0
0
0
0
0
0.012195
0.098901
91
4
42
22.75
0.743902
0.252747
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
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
0
0
0
5
471c7df8223afb6327e2202d7eec49eb4a3e4ad6
48
py
Python
pyeccodes/defs/grib2/template_second_order_def.py
ecmwf/pyeccodes
dce2c72d3adcc0cb801731366be53327ce13a00b
[ "Apache-2.0" ]
7
2020-04-14T09:41:17.000Z
2021-08-06T09:38:19.000Z
pyeccodes/defs/grib2/template_second_order_def.py
ecmwf/pyeccodes
dce2c72d3adcc0cb801731366be53327ce13a00b
[ "Apache-2.0" ]
null
null
null
pyeccodes/defs/grib2/template_second_order_def.py
ecmwf/pyeccodes
dce2c72d3adcc0cb801731366be53327ce13a00b
[ "Apache-2.0" ]
3
2020-04-30T12:44:48.000Z
2020-12-15T08:40:26.000Z
import pyeccodes.accessors as _ def load(h):
8
31
0.729167
7
48
4.857143
1
0
0
0
0
0
0
0
0
0
0
0
0.1875
48
5
32
9.6
0.871795
0
0
0
0
0
0
0
0
0
0
0
0
0
null
null
0
0.5
null
null
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
1
0
0
0
1
0
0
0
0
5
5b64ad63ebd98df5e1a1d1017edcf99d3244a937
93
py
Python
boards/admin.py
lucaswilliamgomes/Beginner-django
db688cc1e2902d7fc0365c8b6d2f9b86f93a3dac
[ "MIT" ]
null
null
null
boards/admin.py
lucaswilliamgomes/Beginner-django
db688cc1e2902d7fc0365c8b6d2f9b86f93a3dac
[ "MIT" ]
null
null
null
boards/admin.py
lucaswilliamgomes/Beginner-django
db688cc1e2902d7fc0365c8b6d2f9b86f93a3dac
[ "MIT" ]
null
null
null
from django.contrib import admin from boards.models import Board admin.site.register(Board)
18.6
32
0.827957
14
93
5.5
0.714286
0
0
0
0
0
0
0
0
0
0
0
0.107527
93
4
33
23.25
0.927711
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
5b64e76b2854b2464955b19aebf27c5b3f567285
19
py
Python
igloader/__init__.py
pvnmurthy/igloader
ad57300f7aaf05706f0dee0735fac449fc512a81
[ "Apache-2.0" ]
4
2021-01-26T01:06:06.000Z
2021-05-26T13:07:34.000Z
igloader/__init__.py
pvnmurthy/igloader
ad57300f7aaf05706f0dee0735fac449fc512a81
[ "Apache-2.0" ]
null
null
null
igloader/__init__.py
pvnmurthy/igloader
ad57300f7aaf05706f0dee0735fac449fc512a81
[ "Apache-2.0" ]
1
2020-11-06T16:59:58.000Z
2020-11-06T16:59:58.000Z
# empty __init__.py
19
19
0.789474
3
19
3.666667
1
0
0
0
0
0
0
0
0
0
0
0
0.105263
19
1
19
19
0.647059
0.894737
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
5b7bc231c2ab5b0cc096f8095cfd25a029faa934
1,187
bzl
Python
source/bazel/deps/glib/get.bzl
luxe/unilang
6c8a431bf61755f4f0534c6299bd13aaeba4b69e
[ "MIT" ]
33
2019-05-30T07:43:32.000Z
2021-12-30T13:12:32.000Z
source/bazel/deps/glib/get.bzl
luxe/unilang
6c8a431bf61755f4f0534c6299bd13aaeba4b69e
[ "MIT" ]
371
2019-05-16T15:23:50.000Z
2021-09-04T15:45:27.000Z
source/bazel/deps/glib/get.bzl
luxe/unilang
6c8a431bf61755f4f0534c6299bd13aaeba4b69e
[ "MIT" ]
6
2019-08-22T17:37:36.000Z
2020-11-07T07:15:32.000Z
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def glib(): http_archive( name="glib" , build_file="//bazel/deps/glib:build.BUILD" , sha256="80753e02bd0baddfa03807dccc6da4e063f272026f07fd0e05e17c6e5353b07e" , strip_prefix="glib-2ba0f14b5298f49dcc3b376d2bdf6505b2c32bd3" , urls = [ "https://github.com/Unilang/glib/archive/2ba0f14b5298f49dcc3b376d2bdf6505b2c32bd3.tar.gz", ], patches = [ "//bazel/deps/glib/patches:glib_config.patch", "//bazel/deps/glib/patches:glib_config2.patch", "//bazel/deps/glib/patches:glib_enums.patch", "//bazel/deps/glib/patches:gio_enums.patch", "//bazel/deps/glib/patches:gnetworking.patch", "//bazel/deps/glib/patches:xdp_dbus.patch", "//bazel/deps/glib/patches:gdbus_daemon.patch", "//bazel/deps/glib/patches:gmoduleconf.patch", "//bazel/deps/glib/patches:gconstructor.patch", ], patch_args = [ "-p1", ], )
38.290323
102
0.627633
120
1,187
6.091667
0.466667
0.123119
0.177839
0.246238
0.331053
0.161423
0
0
0
0
0
0.097374
0.229992
1,187
30
103
39.566667
0.702407
0.085088
0
0.083333
1
0
0.620499
0.522622
0
0
0
0
0
1
0.041667
true
0
0
0
0.041667
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
5bc07fc8f42d256b1d93cc4a76f6d607dbd62ab6
36
py
Python
isleservice_objects/fields.py
illuscio-dev/isleservice_objects-py
76abfe223dcf79847f29d9c0b96873de79cb792a
[ "MIT" ]
null
null
null
isleservice_objects/fields.py
illuscio-dev/isleservice_objects-py
76abfe223dcf79847f29d9c0b96873de79cb792a
[ "MIT" ]
null
null
null
isleservice_objects/fields.py
illuscio-dev/isleservice_objects-py
76abfe223dcf79847f29d9c0b96873de79cb792a
[ "MIT" ]
null
null
null
# custom marshmallow fields go here
18
35
0.805556
5
36
5.8
1
0
0
0
0
0
0
0
0
0
0
0
0.166667
36
1
36
36
0.966667
0.916667
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
5be2dc95f1c0638630850cfd63ccf2a8eb176e61
17,897
py
Python
plaso/winnt/known_folder_ids.py
Defense-Cyber-Crime-Center/plaso
4f3a85fbea10637c1cdbf0cde9fc539fdcea9c47
[ "Apache-2.0" ]
2
2016-02-18T12:46:29.000Z
2022-03-13T03:04:59.000Z
plaso/winnt/known_folder_ids.py
CNR-ITTIG/plasodfaxp
923797fc00664fa9e3277781b0334d6eed5664fd
[ "Apache-2.0" ]
null
null
null
plaso/winnt/known_folder_ids.py
CNR-ITTIG/plasodfaxp
923797fc00664fa9e3277781b0334d6eed5664fd
[ "Apache-2.0" ]
6
2016-12-18T08:05:36.000Z
2021-04-06T14:19:11.000Z
# -*- coding: utf-8 -*- """This file contains the Windows NT Known Folder identifier definitions.""" # For now ignore the line too long errors. # pylint: disable=line-too-long # For now copied from: # https://code.google.com/p/libfwsi/wiki/KnownFolderIdentifiers # TODO: store these in a database or equiv. DESCRIPTIONS = { u'008ca0b1-55b4-4c56-b8a8-4de4b299d3be': u'Account Pictures', u'00bcfc5a-ed94-4e48-96a1-3f6217f21990': u'Roaming Tiles', u'0139d44e-6afe-49f2-8690-3dafcae6ffb8': u'(Common) Programs', u'0482af6c-08f1-4c34-8c90-e17ec98b1e17': u'Public Account Pictures', u'054fae61-4dd8-4787-80b6-090220c4b700': u'Game Explorer (Game Tasks)', u'0762d272-c50a-4bb0-a382-697dcd729b80': u'Users (User Profiles)', u'0ac0837c-bbf8-452a-850d-79d08e667ca7': u'Computer (My Computer)', u'0d4c3db6-03a3-462f-a0e6-08924c41b5d4': u'History', u'0f214138-b1d3-4a90-bba9-27cbc0c5389a': u'Sync Setup', u'15ca69b3-30ee-49c1-ace1-6b5ec372afb5': u'Sample Playlists', u'1777f761-68ad-4d8a-87bd-30b759fa33dd': u'Favorites', u'18989b1d-99b5-455b-841c-ab7c74e4ddfc': u'Videos (My Video)', u'190337d1-b8ca-4121-a639-6d472d16972a': u'Search Results (Search Home)', u'1a6fdba2-f42d-4358-a798-b74d745926c5': u'Recorded TV', u'1ac14e77-02e7-4e5d-b744-2eb1ae5198b7': u'System32 (System)', u'1b3ea5dc-b587-4786-b4ef-bd1dc332aeae': u'Libraries', u'1e87508d-89c2-42f0-8a7e-645a0f50ca58': u'Applications', u'2112ab0a-c86a-4ffe-a368-0de96e47012e': u'Music', u'2400183a-6185-49fb-a2d8-4a392a602ba3': u'Public Videos (Common Video)', u'24d89e24-2f19-4534-9dde-6a6671fbb8fe': u'One Drive Documents', u'289a9a43-be44-4057-a41b-587a76d7e7f9': u'Sync Results', u'2a00375e-224c-49de-b8d1-440df7ef3ddc': u'Localized Resources (Directory)', u'2b0f765d-c0e9-4171-908e-08a611b84ff6': u'Cookies', u'2c36c0aa-5812-4b87-bfd0-4cd0dfb19b39': u'Original Images', u'3214fab5-9757-4298-bb61-92a9deaa44ff': u'Public Music (Common Music)', u'339719b5-8c47-4894-94c2-d8f77add44a6': u'One Drive Pictures', u'33e28130-4e1e-4676-835a-98395c3bc3bb': u'Pictures (My Pictures)', u'352481e8-33be-4251-ba85-6007caedcf9d': u'Internet Cache (Temporary Internet Files)', u'374de290-123f-4565-9164-39c4925e467b': u'Downloads', u'3d644c9b-1fb8-4f30-9b45-f670235f79c0': u'Public Downloads (Common Downloads)', u'3eb685db-65f9-4cf6-a03a-e3ef65729f3d': u'Roaming Application Data (Roaming)', u'43668bf8-c14e-49b2-97c9-747784d784b7': u'Sync Center (Sync Manager)', u'48daf80b-e6cf-4f4e-b800-0e69d84ee384': u'Libraries', u'491e922f-5643-4af4-a7eb-4e7a138d8174': u'Videos', u'4bd8d571-6d19-48d3-be97-422220080e43': u'Music (My Music)', u'4bfefb45-347d-4006-a5be-ac0cb0567192': u'Conflicts', u'4c5c32ff-bb9d-43b0-b5b4-2d72e54eaaa4': u'Saved Games', u'4d9f7874-4e0c-4904-967b-40b0d20c3e4b': u'Internet (The Internet)', u'52528a6b-b9e3-4add-b60d-588c2dba842d': u'Homegroup', u'52a4f021-7b75-48a9-9f6b-4b87a210bc8f': u'Quick Launch', u'56784854-c6cb-462b-8169-88e350acb882': u'Contacts', u'5b3749ad-b49f-49c1-83eb-15370fbd4882': u'Tree Properties', u'5cd7aee2-2219-4a67-b85d-6c9ce15660cb': u'Programs', u'5ce4a5e9-e4eb-479d-b89f-130c02886155': u'Device Metadata Store', u'5e6c858f-0e22-4760-9afe-ea3317b67173': u'Profile (User\'s name)', u'625b53c3-ab48-4ec1-ba1f-a1ef4146fc19': u'Start Menu', u'62ab5d82-fdc1-4dc3-a9dd-070d1d495d97': u'Program Data', u'6365d5a7-0f0d-45e5-87f6-0da56b6a4f7d': u'Common Files (x64)', u'69d2cf90-fc33-4fb7-9a0c-ebb0f0fcb43c': u'Slide Shows (Photo Albums)', u'6d809377-6af0-444b-8957-a3773f02200e': u'Program Files (x64)', u'6f0cd92b-2e97-45d1-88ff-b0d186b8dedd': u'Network Connections', u'724ef170-a42d-4fef-9f26-b60e846fba4f': u'Administrative Tools', u'767e6811-49cb-4273-87c2-20f355e1085b': u'One Drive Camera Roll', u'76fc4e2d-d6ad-4519-a663-37bd56068185': u'Printers', u'7b0db17d-9cd2-4a93-9733-46cc89022e7c': u'Documents', u'7b396e54-9ec5-4300-be0a-2482ebae1a26': u'Default Gadgets (Sidebar Default Parts)', u'7c5a40ef-a0fb-4bfc-874a-c0f2e0b9fa8e': u'Program Files (x86)', u'7d1d3a04-debb-4115-95cf-2f29da2920da': u'Saved Searches (Searches)', u'7e636bfe-dfa9-4d5e-b456-d7b39851d8a9': u'Templates', u'82a5ea35-d9cd-47c5-9629-e15d2f714e6e': u'(Common) Startup', u'82a74aeb-aeb4-465c-a014-d097ee346d63': u'Control Panel', u'859ead94-2e85-48ad-a71a-0969cb56a6cd': u'Sample Videos', u'8983036c-27c0-404b-8f08-102d10dcfd74': u'Send To', u'8ad10c31-2adb-4296-a8f7-e4701232c972': u'Resources (Resources Directory)', u'905e63b6-c1bf-494e-b29c-65b732d3d21a': u'Program Files', u'9274bd8d-cfd1-41c3-b35e-b13f55a758f4': u'Printer Shortcuts (PrintHood)', u'98ec0e18-2098-4d44-8644-66979315a281': u'Microsoft Office Outlook (MAPI)', u'9b74b6a3-0dfd-4f11-9e78-5f7800f2e772': u'User\'s name', u'9e3995ab-1f9c-4f13-b827-48b24b6c7174': u'User Pinned', u'9e52ab10-f80d-49df-acb8-4330f5687855': u'Temporary Burn Folder (CD Burning)', u'a302545d-deff-464b-abe8-61c8648d939b': u'Libraries', u'a305ce99-f527-492b-8b1a-7e76fa98d6e4': u'Installed Updates (Application Updates)', u'a3918781-e5f2-4890-b3d9-a7e54332328c': u'Application Shortcuts', u'a4115719-d62e-491d-aa7c-e74b8be3b067': u'(Common) Start Menu', u'a520a1a4-1780-4ff6-bd18-167343c5af16': u'Local Application Data Low (Local Low)', u'a52bba46-e9e1-435f-b3d9-28daa648c0f6': u'One Drive', u'a63293e8-664e-48db-a079-df759e0509f7': u'Templates', u'a75d362e-50fc-4fb7-ac2c-a8beaa314493': u'Gadgets (Sidebar Parts)', u'a77f5d77-2e2b-44c3-a6a2-aba601054a51': u'Programs', u'a990ae9f-a03b-4e80-94bc-9912d7504104': u'Pictures', u'aaa8d5a5-f1d6-4259-baa8-78e7ef60835e': u'Roamed Tile Images', u'ab5fb87b-7ce2-4f83-915d-550846c9537b': u'Camera Roll', u'ae50c081-ebd2-438a-8655-8a092e34987a': u'Recent (Recent Items)', u'b250c668-f57d-4ee1-a63c-290ee7d1aa1f': u'Sample Music', u'b4bfcc3a-db2c-424c-b029-7fe99a87c641': u'Desktop', u'b6ebfb86-6907-413c-9af7-4fc2abf07cc5': u'Public Pictures (Common Pictures)', u'b7534046-3ecb-4c18-be4e-64cd4cb7d6ac': u'Recycle Bin (Bit Bucket)', u'b7bede81-df94-4682-a7d8-57a52620b86f': u'Screenshots', u'b94237e7-57ac-4347-9151-b08c6c32d1f7': u'(Common) Templates', u'b97d20bb-f46a-4c97-ba10-5e3608430854': u'Startup', u'bcb5256f-79f6-4cee-b725-dc34e402fd46': u'Implicit Application Shortcuts', u'bcbd3057-ca5c-4622-b42d-bc56db0ae516': u'Programs', u'bd85e001-112e-431e-983b-7b15ac09fff1': u'Recorded TV', u'bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968': u'Links', u'c1bae2d0-10df-4334-bedd-7aa20b227a9d': u'(Common) OEM Links', u'c4900540-2379-4c75-844b-64e6faf8716b': u'Sample Pictures', u'c4aa340d-f20f-4863-afef-f87ef2e6ba25': u'Public Desktop (Common Desktop)', u'c5abbf53-e17f-4121-8900-86626fc2c973': u'Network Shortcuts (NetHood)', u'c870044b-f49e-4126-a9c3-b52a1ff411e8': u'Ringtones', u'cac52c1a-b53d-4edc-92d7-6b2e8ac19434': u'Games', u'd0384e7d-bac3-4797-8f14-cba229b392b5': u'(Common) Administrative Tools', u'd20beec4-5ca8-4905-ae3b-bf251ea09b53': u'Network (Places)', u'd65231b0-b2f1-4857-a4ce-a8e7c6ea7d27': u'System32 (x86)', u'd9dc8a3b-b784-432e-a781-5a1130a75963': u'History', u'de61d971-5ebc-4f02-a3a9-6c82895e5c04': u'Add New Programs (Get Programs)', u'de92c1c7-837f-4f69-a3bb-86e631204a23': u'Playlists', u'de974d24-d9c6-4d3e-bf91-f4455120b917': u'Common Files (x86)', u'debf2536-e1a8-4c59-b6a2-414586476aea': u'Game Explorer (Public Game Tasks)', u'df7266ac-9274-4867-8d55-3bd661de872d': u'Programs and Features (Change and Remove Programs)', u'dfdf76a2-c82a-4d63-906a-5644ac457385': u'Public', u'e555ab60-153b-4d17-9f04-a5fe99fc15ec': u'Ringtones', u'ed4824af-dce4-45a8-81e2-fc7965083634': u'Public Documents (Common Documents)', u'ee32e446-31ca-4aba-814f-a5ebd2fd6d5e': u'Offline Files (CSC)', u'f1b32785-6fba-4fcf-9d55-7b8e7f157091': u'Local Application Data', u'f38bf404-1d43-42f2-9305-67de0b28fc23': u'Windows', u'f3ce0f7c-4901-4acc-8648-d5d44b04ef8f': u'User\'s Files', u'f7f1ed05-9f6d-47a2-aaae-29d317c6f066': u'Common Files', u'fd228cb7-ae11-4ae3-864c-16f3910ab8fe': u'Fonts', u'fdd39ad0-238f-46af-adb4-6c85480369c7': u'Documents (Personal)', } PATHS = { u'008ca0b1-55b4-4c56-b8a8-4de4b299d3be': u'%APPDATA%\\Microsoft\\Windows\\AccountPictures', u'00bcfc5a-ed94-4e48-96a1-3f6217f21990': u'%LOCALAPPDATA%\\Microsoft\\Windows\\RoamingTiles', u'0139d44e-6afe-49f2-8690-3dafcae6ffb8': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs', u'0482af6c-08f1-4c34-8c90-e17ec98b1e17': u'%PUBLIC%\\AccountPictures', u'054fae61-4dd8-4787-80b6-090220c4b700': u'%LOCALAPPDATA%\\Microsoft\\Windows\\GameExplorer', u'0762d272-c50a-4bb0-a382-697dcd729b80': u'%SYSTEMDRIVE%\\Users', u'0ac0837c-bbf8-452a-850d-79d08e667ca7': u'', u'0d4c3db6-03a3-462f-a0e6-08924c41b5d4': u'%LOCALAPPDATA%\\Microsoft\\Windows\\ConnectedSearch\\History', u'0f214138-b1d3-4a90-bba9-27cbc0c5389a': u'', u'15ca69b3-30ee-49c1-ace1-6b5ec372afb5': u'%PUBLIC%\\Music\\Sample Playlists', u'1777f761-68ad-4d8a-87bd-30b759fa33dd': u'%USERPROFILE%\\Favorites', u'18989b1d-99b5-455b-841c-ab7c74e4ddfc': u'%USERPROFILE%\\Videos', u'190337d1-b8ca-4121-a639-6d472d16972a': u'', u'1a6fdba2-f42d-4358-a798-b74d745926c5': u'%PUBLIC%\\RecordedTV.library-ms', u'1ac14e77-02e7-4e5d-b744-2eb1ae5198b7': u'%WINDIR%\\System32', u'1b3ea5dc-b587-4786-b4ef-bd1dc332aeae': u'%APPDATA%\\Microsoft\\Windows\\Libraries', u'1e87508d-89c2-42f0-8a7e-645a0f50ca58': u'', u'2112ab0a-c86a-4ffe-a368-0de96e47012e': u'%APPDATA%\\Microsoft\\Windows\\Libraries\\Music.library-ms', u'2400183a-6185-49fb-a2d8-4a392a602ba3': u'%PUBLIC%\\Videos', u'24d89e24-2f19-4534-9dde-6a6671fbb8fe': u'%USERPROFILE%\\OneDrive\\Documents', u'289a9a43-be44-4057-a41b-587a76d7e7f9': u'', u'2a00375e-224c-49de-b8d1-440df7ef3ddc': u'%WINDIR%\\resources\\%CODEPAGE%', u'2b0f765d-c0e9-4171-908e-08a611b84ff6': u'%APPDATA%\\Microsoft\\Windows\\Cookies', u'2c36c0aa-5812-4b87-bfd0-4cd0dfb19b39': u'%LOCALAPPDATA%\\Microsoft\\Windows Photo Gallery\\Original Images', u'3214fab5-9757-4298-bb61-92a9deaa44ff': u'%PUBLIC%\\Music', u'339719b5-8c47-4894-94c2-d8f77add44a6': u'%USERPROFILE%\\OneDrive\\Pictures', u'33e28130-4e1e-4676-835a-98395c3bc3bb': u'%USERPROFILE%\\Pictures', u'352481e8-33be-4251-ba85-6007caedcf9d': u'%LOCALAPPDATA%\\Microsoft\\Windows\\Temporary Internet Files', u'374de290-123f-4565-9164-39c4925e467b': u'%USERPROFILE%\\Downloads', u'3d644c9b-1fb8-4f30-9b45-f670235f79c0': u'%PUBLIC%\\Downloads', u'3eb685db-65f9-4cf6-a03a-e3ef65729f3d': u'%USERPROFILE%\\AppData\\Roaming', u'43668bf8-c14e-49b2-97c9-747784d784b7': u'', u'48daf80b-e6cf-4f4e-b800-0e69d84ee384': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Libraries', u'491e922f-5643-4af4-a7eb-4e7a138d8174': u'%APPDATA%\\Microsoft\\Windows\\Libraries\\Videos.library-ms', u'4bd8d571-6d19-48d3-be97-422220080e43': u'%USERPROFILE%\\Music', u'4bfefb45-347d-4006-a5be-ac0cb0567192': u'', u'4c5c32ff-bb9d-43b0-b5b4-2d72e54eaaa4': u'%USERPROFILE%\\Saved Games', u'4d9f7874-4e0c-4904-967b-40b0d20c3e4b': u'', u'52528a6b-b9e3-4add-b60d-588c2dba842d': u'', u'52a4f021-7b75-48a9-9f6b-4b87a210bc8f': u'%APPDATA%\\Microsoft\\Internet Explorer\\Quick Launch', u'56784854-c6cb-462b-8169-88e350acb882': u'', u'5b3749ad-b49f-49c1-83eb-15370fbd4882': u'', u'5cd7aee2-2219-4a67-b85d-6c9ce15660cb': u'%LOCALAPPDATA%\\Programs', u'5ce4a5e9-e4eb-479d-b89f-130c02886155': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\DeviceMetadataStore', u'5e6c858f-0e22-4760-9afe-ea3317b67173': u'%SYSTEMDRIVE%\\Users\\%USERNAME%', u'625b53c3-ab48-4ec1-ba1f-a1ef4146fc19': u'%APPDATA%\\Microsoft\\Windows\\Start Menu', u'62ab5d82-fdc1-4dc3-a9dd-070d1d495d97': u'%SYSTEMDRIVE%\\ProgramData', u'6365d5a7-0f0d-45e5-87f6-0da56b6a4f7d': u'%PROGRAMFILES%\\Common Files', u'69d2cf90-fc33-4fb7-9a0c-ebb0f0fcb43c': u'%USERPROFILE%\\Pictures\\Slide Shows', u'6d809377-6af0-444b-8957-a3773f02200e': u'%SYSTEMDRIVE%\\Program Files', u'6f0cd92b-2e97-45d1-88ff-b0d186b8dedd': u'', u'724ef170-a42d-4fef-9f26-b60e846fba4f': u'%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Administrative Tools', u'767e6811-49cb-4273-87c2-20f355e1085b': u'%USERPROFILE%\\OneDrive\\Pictures\\Camera Roll', u'76fc4e2d-d6ad-4519-a663-37bd56068185': u'', u'7b0db17d-9cd2-4a93-9733-46cc89022e7c': u'%APPDATA%\\Microsoft\\Windows\\Libraries\\Documents.library-ms', u'7b396e54-9ec5-4300-be0a-2482ebae1a26': u'%PROGRAMFILES%\\Windows Sidebar\\Gadgets', u'7c5a40ef-a0fb-4bfc-874a-c0f2e0b9fa8e': u'%PROGRAMFILES% (%SYSTEMDRIVE%\\Program Files)', u'7d1d3a04-debb-4115-95cf-2f29da2920da': u'%USERPROFILE%\\Searches', u'7e636bfe-dfa9-4d5e-b456-d7b39851d8a9': u'%LOCALAPPDATA%\\Microsoft\\Windows\\ConnectedSearch\\Templates', u'82a5ea35-d9cd-47c5-9629-e15d2f714e6e': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp', u'82a74aeb-aeb4-465c-a014-d097ee346d63': u'', u'859ead94-2e85-48ad-a71a-0969cb56a6cd': u'%PUBLIC%\\Videos\\Sample Videos', u'8983036c-27c0-404b-8f08-102d10dcfd74': u'%APPDATA%\\Microsoft\\Windows\\SendTo', u'8ad10c31-2adb-4296-a8f7-e4701232c972': u'%WINDIR%\\Resources', u'905e63b6-c1bf-494e-b29c-65b732d3d21a': u'%SYSTEMDRIVE%\\Program Files', u'9274bd8d-cfd1-41c3-b35e-b13f55a758f4': u'%APPDATA%\\Microsoft\\Windows\\Printer Shortcuts', u'98ec0e18-2098-4d44-8644-66979315a281': u'', u'9b74b6a3-0dfd-4f11-9e78-5f7800f2e772': u'', u'9e3995ab-1f9c-4f13-b827-48b24b6c7174': u'%APPDATA%\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned', u'9e52ab10-f80d-49df-acb8-4330f5687855': u'%LOCALAPPDATA%\\Microsoft\\Windows\\Burn\\Burn', u'a302545d-deff-464b-abe8-61c8648d939b': u'', u'a305ce99-f527-492b-8b1a-7e76fa98d6e4': u'', u'a3918781-e5f2-4890-b3d9-a7e54332328c': u'%LOCALAPPDATA%\\Microsoft\\Windows\\Application Shortcuts', u'a4115719-d62e-491d-aa7c-e74b8be3b067': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu', u'a520a1a4-1780-4ff6-bd18-167343c5af16': u'%USERPROFILE%\\AppData\\LocalLow', u'a52bba46-e9e1-435f-b3d9-28daa648c0f6': u'%USERPROFILE%\\OneDrive', u'a63293e8-664e-48db-a079-df759e0509f7': u'%APPDATA%\\Microsoft\\Windows\\Templates', u'a75d362e-50fc-4fb7-ac2c-a8beaa314493': u'%LOCALAPPDATA%\\Microsoft\\Windows Sidebar\\Gadgets', u'a77f5d77-2e2b-44c3-a6a2-aba601054a51': u'%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs', u'a990ae9f-a03b-4e80-94bc-9912d7504104': u'%APPDATA%\\Microsoft\\Windows\\Libraries\\Pictures.library-ms', u'aaa8d5a5-f1d6-4259-baa8-78e7ef60835e': u'%LOCALAPPDATA%\\Microsoft\\Windows\\RoamedTileImages', u'ab5fb87b-7ce2-4f83-915d-550846c9537b': u'%USERPROFILE%\\Pictures\\Camera Roll', u'ae50c081-ebd2-438a-8655-8a092e34987a': u'%APPDATA%\\Microsoft\\Windows\\Recent', u'b250c668-f57d-4ee1-a63c-290ee7d1aa1f': u'%PUBLIC%\\Music\\Sample Music', u'b4bfcc3a-db2c-424c-b029-7fe99a87c641': u'%USERPROFILE%\\Desktop', u'b6ebfb86-6907-413c-9af7-4fc2abf07cc5': u'%PUBLIC%\\Pictures', u'b7534046-3ecb-4c18-be4e-64cd4cb7d6ac': u'', u'b7bede81-df94-4682-a7d8-57a52620b86f': u'%USERPROFILE%\\Pictures\\Screenshots', u'b94237e7-57ac-4347-9151-b08c6c32d1f7': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Templates', u'b97d20bb-f46a-4c97-ba10-5e3608430854': u'%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp', u'bcb5256f-79f6-4cee-b725-dc34e402fd46': u'%APPDATA%\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\ImplicitAppShortcuts', u'bcbd3057-ca5c-4622-b42d-bc56db0ae516': u'%LOCALAPPDATA%\\Programs\\Common', u'bd85e001-112e-431e-983b-7b15ac09fff1': u'', u'bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968': u'%USERPROFILE%\\Links', u'c1bae2d0-10df-4334-bedd-7aa20b227a9d': u'%ALLUSERSPROFILE%\\OEM Links', u'c4900540-2379-4c75-844b-64e6faf8716b': u'%PUBLIC%\\Pictures\\Sample Pictures', u'c4aa340d-f20f-4863-afef-f87ef2e6ba25': u'%PUBLIC%\\Desktop', u'c5abbf53-e17f-4121-8900-86626fc2c973': u'%APPDATA%\\Microsoft\\Windows\\Network Shortcuts', u'c870044b-f49e-4126-a9c3-b52a1ff411e8': u'%LOCALAPPDATA%\\Microsoft\\Windows\\Ringtones', u'cac52c1a-b53d-4edc-92d7-6b2e8ac19434': u'', u'd0384e7d-bac3-4797-8f14-cba229b392b5': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Administrative Tools', u'd20beec4-5ca8-4905-ae3b-bf251ea09b53': u'', u'd65231b0-b2f1-4857-a4ce-a8e7c6ea7d27': u'%WINDIR%\\system32', u'd9dc8a3b-b784-432e-a781-5a1130a75963': u'%LOCALAPPDATA%\\Microsoft\\Windows\\History', u'de61d971-5ebc-4f02-a3a9-6c82895e5c04': u'', u'de92c1c7-837f-4f69-a3bb-86e631204a23': u'%USERPROFILE%\\Music\\Playlists', u'de974d24-d9c6-4d3e-bf91-f4455120b917': u'%PROGRAMFILES%\\Common Files', u'debf2536-e1a8-4c59-b6a2-414586476aea': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\GameExplorer', u'df7266ac-9274-4867-8d55-3bd661de872d': u'', u'dfdf76a2-c82a-4d63-906a-5644ac457385': u'%SYSTEMDRIVE%\\Users\\Public', u'e555ab60-153b-4d17-9f04-a5fe99fc15ec': u'%ALLUSERSPROFILE%\\Microsoft\\Windows\\Ringtones', u'ed4824af-dce4-45a8-81e2-fc7965083634': u'%PUBLIC%\\Documents', u'ee32e446-31ca-4aba-814f-a5ebd2fd6d5e': u'', u'f1b32785-6fba-4fcf-9d55-7b8e7f157091': u'%USERPROFILE%\\AppData\\Local', u'f38bf404-1d43-42f2-9305-67de0b28fc23': u'%WINDIR%', u'f3ce0f7c-4901-4acc-8648-d5d44b04ef8f': u'', u'f7f1ed05-9f6d-47a2-aaae-29d317c6f066': u'%PROGRAMFILES%\\Common Files', u'fd228cb7-ae11-4ae3-864c-16f3910ab8fe': u'%WINDIR%\\Fonts', u'fdd39ad0-238f-46af-adb4-6c85480369c7': u'%USERPROFILE%\\Documents', }
70.184314
137
0.728725
2,364
17,897
5.51692
0.335025
0.045392
0.024766
0.029443
0.767444
0.742217
0.738077
0.38284
0.188621
0.053213
0
0.296111
0.09482
17,897
254
138
70.46063
0.508951
0.016148
0
0
0
0
0.806899
0.653407
0
0
0
0.003937
0
1
0
false
0
0
0
0
0
0
0
0
null
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
750c84c56b4d82453bbdb114355eae27fa8f5b9d
86
py
Python
bugtests/test402n.py
jeff5/jython-whinchat
65d8e5268189f8197295ff2d91be3decb1ee0081
[ "CNRI-Jython" ]
577
2020-06-04T16:34:44.000Z
2022-03-31T11:46:07.000Z
bugtests/test402n.py
jeff5/jython-whinchat
65d8e5268189f8197295ff2d91be3decb1ee0081
[ "CNRI-Jython" ]
174
2015-01-08T20:37:09.000Z
2020-06-03T16:48:59.000Z
bugtests/test402n.py
jeff5/jython-whinchat
65d8e5268189f8197295ff2d91be3decb1ee0081
[ "CNRI-Jython" ]
162
2015-02-07T02:14:38.000Z
2020-05-30T16:42:03.000Z
import sys sys.path.append('simplejar/simple.jar') from javapackage import JavaClass
17.2
39
0.813953
12
86
5.833333
0.833333
0
0
0
0
0
0
0
0
0
0
0
0.093023
86
4
40
21.5
0.897436
0
0
0
0
0
0.232558
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
750ff360bf1144e88cb0cfa558c880d530398fc6
83
py
Python
python/testData/completion/classNameFromVarName.after.py
jnthn/intellij-community
8fa7c8a3ace62400c838e0d5926a7be106aa8557
[ "Apache-2.0" ]
2
2019-04-28T07:48:50.000Z
2020-12-11T14:18:08.000Z
python/testData/completion/classNameFromVarName.after.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
173
2018-07-05T13:59:39.000Z
2018-08-09T01:12:03.000Z
python/testData/completion/classNameFromVarName.after.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
2
2020-03-15T08:57:37.000Z
2020-04-07T04:48:14.000Z
class Product: def doStuff(self): pass def foo(product): product.doStuff()
16.6
27
0.686747
11
83
5.181818
0.636364
0
0
0
0
0
0
0
0
0
0
0
0.192771
83
5
28
16.6
0.850746
0
0
0
0
0
0
0
0
0
0
0
0
1
0.5
false
0.25
0
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
1
0
1
0
0
1
0
0
5
75288434d350cf76348664694ff11aad10f29fb4
94
py
Python
test/hello.py
Progyan1997/Machine-Learning
f2231dc53005181c61b13996bc1bbb13bc448354
[ "MIT" ]
null
null
null
test/hello.py
Progyan1997/Machine-Learning
f2231dc53005181c61b13996bc1bbb13bc448354
[ "MIT" ]
null
null
null
test/hello.py
Progyan1997/Machine-Learning
f2231dc53005181c61b13996bc1bbb13bc448354
[ "MIT" ]
null
null
null
# Test Program # This program prints "Hello World!" to Standard Output print('Hello World!')
18.8
55
0.734043
13
94
5.307692
0.769231
0.289855
0
0
0
0
0
0
0
0
0
0
0.159574
94
4
56
23.5
0.873418
0.702128
0
0
0
0
0.48
0
0
0
0
0
0
1
0
true
0
0
0
0
1
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
0
0
0
1
0
5
752e5162bee25cb215ebfbc73df4542830a633c7
19,777
py
Python
python/athena/gpu_ops/Conv2d.py
DMALab/TSplit
8f86f987163aa06521bfeeb174616eb4a0a81b47
[ "Apache-2.0" ]
2
2021-05-29T11:18:14.000Z
2021-09-09T14:29:21.000Z
python/athena/gpu_ops/Conv2d.py
DMALab/TSplit
8f86f987163aa06521bfeeb174616eb4a0a81b47
[ "Apache-2.0" ]
null
null
null
python/athena/gpu_ops/Conv2d.py
DMALab/TSplit
8f86f987163aa06521bfeeb174616eb4a0a81b47
[ "Apache-2.0" ]
1
2021-05-01T16:34:37.000Z
2021-05-01T16:34:37.000Z
from __future__ import absolute_import import numpy as np from .Node import Op, NAME_RULE, PROFILING_MODE from .. import profiler from .._base import get_array_memory class Conv2dOp(Op): # nodeA : x nodeB : filter def __call__(self, node_A, node_B, padding=0, padding2 = None, stride=1, For_ResNet = False): new_node = Op.__call__(self) new_node.inputs = [node_A, node_B] self.padding = padding self.padding2 = padding2 self.For_ResNet = For_ResNet if padding2 is None: self.padding2 = self.padding self.stride = stride new_node.profiler = None if PROFILING_MODE == 1: new_node.profiler = profiler.CreateProfiler() # print "init padding = ", padding if NAME_RULE == 0: new_node.name = "Conv2d(%s, %s)" % (node_A.name, node_B.name) elif NAME_RULE == 1: new_node.name = "Conv2d" else: new_node.name = "conv2d"+str(new_node.id) new_node.desc = new_node.name + \ "(%s, %s)" % (node_A.name, node_B.name) return new_node def im2col(self, X, filter_H, filter_W, padding, stride): N, C, H, W = X.shape assert (H + 2 * padding - filter_H) % stride == 0 assert (W + 2 * padding - filter_W) % stride == 0 out_H = (H + 2 * padding - filter_H) / stride + 1 out_W = (W + 2 * padding - filter_W) / stride + 1 y_row_size = C * filter_H * filter_W y_col_size = out_H * out_W y_shape = (N, y_row_size, y_col_size) Y = np.empty(y_shape, dtype=X.dtype) for batch_index in range(N): for col_index in range(y_col_size): out_y = col_index / out_W out_x = col_index % out_W in_y = out_y * stride - padding in_x = out_x * stride - padding row_idx = 0 for c in range(0, C): for y in range(in_y, in_y + filter_H): for x in range(in_x, in_x + filter_W): if (x < 0 or x >= W or y < 0 or y >= H): Y[batch_index, row_idx, col_index] = 0 else: Y[batch_index, row_idx, col_index] = X[batch_index, c, y, x] row_idx += 1 return Y def np_conv2d(self, X, Filter, padding=0, stride=1): """Implement a conv2d as a matrix multiply after im2col.""" filter_outChannel, filter_inChannel, filter_H, filter_W = Filter.shape N, C, H, W = X.shape assert (H + 2 * padding - filter_H) % stride == 0 assert (W + 2 * padding - filter_W) % stride == 0 out_H = (H + 2 * padding - filter_H) / stride + 1 out_W = (W + 2 * padding - filter_W) / stride + 1 im2col_matrix = self.im2col(X, filter_H, filter_W, padding, stride) filter_matrix = Filter.reshape(filter_outChannel, -1) return np.matmul(filter_matrix, im2col_matrix).reshape(N, filter_outChannel, out_H, out_W) def profile(self, node, input_vals, output_val, is_static = True): assert len(input_vals) == 2 if is_static: # input memory node.profiler.input_memory = get_array_memory(input_vals[0].shape) + \ get_array_memory(input_vals[1].shape) # output memory node.profiler.output_memory = get_array_memory(output_val.shape) # TODO # no workspace node.profiler.workspace_memory = 0 # execute time node.profiler.time = node.profiler.output_memory / 4 * profiler.FLOPS_PER_SECOND else: # import time # start = time.time() from ..gpu_links import CuDNN_conv2d CuDNN_conv2d(input_vals[0], input_vals[1], output_val, self.padding, self.padding2, self.stride, None, node.profiler) # print("time.time: {} ms".format((time.time() - start) * 1000)) # node.profiler.time = time.time() - start def compute(self, node, input_vals, output_val, use_numpy=True, stream_handle=None): assert len(input_vals) == 2 if use_numpy: from .._base import DNNL_LIB if DNNL_LIB['DnnlConv2d']: from ..cpu_links import conv2d as cpu_conv2d from ..ndarray import numpyasdlarrayhandle input_x = numpyasdlarrayhandle(input_vals[0]) input_f = numpyasdlarrayhandle(input_vals[1]) output = numpyasdlarrayhandle(output_val) cpu_conv2d(input_x, input_f, output, self.padding, self.stride) else: output_val[:] = self.np_conv2d( input_vals[0], input_vals[1], self.padding, self.stride) else: from ..gpu_links import CuDNN_conv2d CuDNN_conv2d(input_vals[0], input_vals[1], output_val, self.padding, self.padding2, self.stride, stream_handle, None) def gradient(self, node, output_grad): return [conv2d_gradient_of_data_op(node.inputs[1], output_grad, self.padding, self.padding2, self.stride, self.For_ResNet),\ conv2d_gradient_of_filter_op(node.inputs[0], output_grad, self.padding, self.padding2, self.stride)] def infer_shape(self, node, input_shapes): assert len(input_shapes) == 2 # print "infer padding = ",self.padding N, _, H, W = input_shapes[0] f_O, _, f_H, f_W = input_shapes[1] padding = self.padding padding2 = self.padding2 stride = self.stride filter_H = input_shapes[1][2] filter_W = input_shapes[1][3] out_H = (H + 2 * padding - filter_H) / stride + 1 out_W = (W + 2 * padding2 - filter_W) / stride + 1 # print "conv2d_shape" # print(N, f_O, out_H, out_W) return (N, f_O, out_H, out_W) class Conv2d_Gradient_of_DataOp(Op): # nodeA : filter nodeB : Y_gradient def __call__(self, node_A, node_B, padding=0, padding2 = None, stride=1, For_ResNet = False): new_node = Op.__call__(self) new_node.inputs = [node_A, node_B] self.padding = padding self.padding2 = padding2 self.stride = stride self.For_ResNet = For_ResNet new_node.profiler = None if PROFILING_MODE == 1: new_node.profiler = profiler.CreateProfiler() if NAME_RULE == 0: new_node.name = "Conv2d_Gradient_of_DataOp(%s, %s)" % ( node_A.name, node_B.name) elif NAME_RULE == 1: new_node.name = "Conv2d_Gradient_of_DataOp" else: new_node.name = "Conv2d_Gradient_of_DataOp"+str(new_node.id) new_node.desc = new_node.name + \ "(%s, %s)" % (node_A.name, node_B.name) return new_node def im2col_transpose(self, N, C, H, W, filter_H, filter_W, Y, padding, stride): assert (H + 2 * padding - filter_H) % stride == 0 assert (W + 2 * padding - filter_W) % stride == 0 out_H = (H + 2 * padding - filter_H) / stride + 1 out_W = (W + 2 * padding - filter_W) / stride + 1 _, y_row_size, y_col_size = Y.shape der_X_shape = (N, C, H, W) der_X = np.zeros(der_X_shape, dtype=Y.dtype) # print "batch_size", N for batch_index in range(N): for col_index in range(y_col_size): out_y = col_index / out_W out_x = col_index % out_W in_y = out_y * stride - padding in_x = out_x * stride - padding row_idx = 0 for c in range(0, C): for y in range(in_y, in_y + filter_H): for x in range(in_x, in_x + filter_W): if (x < 0 or x >= W or y < 0 or y >= H): Y[batch_index, row_idx, col_index] = 0 else: der_X[batch_index, c, y, x] += Y[batch_index, row_idx, col_index] row_idx += 1 return der_X def np_Conv2dGradient_data(self, X_N, X_C, X_H, X_W, Filter, Y, padding=0, stride=1): filter_outChannel, filter_inChannel, filter_H, filter_W = Filter.shape Y_N, Y_C, Y_H, Y_W = Y.shape YY = Y.reshape((Y_N, Y_C, Y_H * Y_W)) # transformed to im2col Y F_filter = Filter.reshape((filter_outChannel, -1)) gradient_im2col_XX = np.matmul(F_filter.T, YY) gradient_X = self.im2col_transpose( X_N, X_C, X_H, X_W, filter_H, filter_W, gradient_im2col_XX, padding, stride) # gradient of x return gradient_X def profile(self, node, input_vals, output_val, is_static = True): assert len(input_vals) == 2 if is_static: # input memory node.profiler.input_memory = get_array_memory(input_vals[0].shape) + \ get_array_memory(input_vals[1].shape) # output memory node.profiler.output_memory = get_array_memory(output_val.shape) # no workspace node.profiler.workspace_memory = 0 # execute time node.profiler.time = node.profiler.output_memory / 4 * profiler.FLOPS_PER_SECOND else: # import time # start = time.time() from ..gpu_links import CuDNN_conv2d_gradient_of_data CuDNN_conv2d_gradient_of_data( input_vals[0], input_vals[1], output_val, padding=self.padding, padding2=self.padding2, stride=self.stride, stream = None, profiler = node.profiler) # node.profiler.time = time.time() - start def compute(self, node, input_vals, output_val, use_numpy=True, stream_handle=None): assert len(input_vals) == 2 N = input_vals[1].shape[0] C = input_vals[0].shape[1] H = (input_vals[1].shape[2] - 1) * self.stride + \ input_vals[0].shape[2] - 2 * self.padding W = (input_vals[1].shape[3] - 1) * self.stride + \ input_vals[0].shape[3] - 2 * self.padding if use_numpy: from .._base import DNNL_LIB if DNNL_LIB['DnnlConv2d_Gradient_of_Data']: from ..cpu_links import conv2d_gradient_of_data as cpu_conv2d_gradient_of_data from ..ndarray import numpyasdlarrayhandle input_f = numpyasdlarrayhandle(input_vals[0]) gradient_y = numpyasdlarrayhandle(input_vals[1]) gradient_x = numpyasdlarrayhandle(output_val) cpu_conv2d_gradient_of_data(input_f, gradient_y, gradient_x, self.padding, self.stride) else: output_val[:] = self.np_Conv2dGradient_data( N, C, H, W, input_vals[0], input_vals[1], padding=self.padding, stride=self.stride) else: from ..gpu_links import CuDNN_conv2d_gradient_of_data CuDNN_conv2d_gradient_of_data( input_vals[0], input_vals[1], output_val, padding=self.padding, padding2 = self.padding2, stride=self.stride, stream = stream_handle, profiler = None) def gradient(self, node, output_grad): raise NotImplementedError def infer_shape(self, node, input_shapes): """TODO: Your code here""" # print self.For_ResNet assert len(input_shapes) == 2 N = input_shapes[1][0] C = input_shapes[0][1] H = (input_shapes[1][2] - 1) * self.stride + \ input_shapes[0][2] - 2 * self.padding + (1 if self.For_ResNet and self.stride == 2 else 0) W = (input_shapes[1][3] - 1) * self.stride + \ input_shapes[0][3] - 2 * self.padding2 + (1 if self.For_ResNet and self.stride == 2 else 0) return (N, C, H, W) class Conv2d_Gradient_of_FilterOp(Op): # nodeA : input_x nodeB : gradient_Y def __call__(self, input_X, gradient_Y, padding=0, padding2=None, stride=1): new_node = Op.__call__(self) new_node.inputs = [input_X, gradient_Y] self.padding = padding if padding2 is None: self.padding2 = self.padding else: self.padding2 = padding2 self.stride = stride new_node.profiler = None if PROFILING_MODE == 1: new_node.profiler = profiler.CreateProfiler() if NAME_RULE == 0: new_node.name = "Conv2d_Gradient_of_FilterOp(%s, %s)" % ( input_X.name, gradient_Y.name) elif NAME_RULE == 1: new_node.name = "Conv2d_Gradient_of_FilterOp" else: new_node.name = "Conv2d_Gradient_of_FilterOp"+str(new_node.id) new_node.desc = new_node.name + \ "(%s, %s)" % (input_X.name, gradient_Y.name) return new_node def im2col(self, X, filter_H, filter_W, padding, stride): N, C, H, W = X.shape assert (H + 2 * padding - filter_H) % stride == 0 assert (W + 2 * padding - filter_W) % stride == 0 out_H = (H + 2 * padding - filter_H) / stride + 1 out_W = (W + 2 * padding - filter_W) / stride + 1 y_row_size = C * filter_H * filter_W y_col_size = out_H * out_W y_shape = (N, y_row_size, y_col_size) Y = np.empty(y_shape, dtype=X.dtype) for batch_index in range(N): for col_index in range(y_col_size): out_y = col_index / out_W out_x = col_index % out_W in_y = out_y * stride - padding in_x = out_x * stride - padding row_idx = 0 for c in range(0, C): for y in range(in_y, in_y + filter_H): for x in range(in_x, in_x + filter_W): if (x < 0 or x >= W or y < 0 or y >= H): Y[batch_index, row_idx, col_index] = 0 else: Y[batch_index, row_idx, col_index] = X[batch_index, c, y, x] row_idx += 1 return Y def np_Conv2dGradient_Filter(self, filter_outChannel, filter_inChannel, filter_H, filter_W, X, Y, padding=0, stride=1): """Implement a conv2d_transpose as a matrix multiply after im2col.""" X_N, X_C, X_H, X_W = X.shape Y_N, Y_C, Y_H, Y_W = Y.shape YY = Y.reshape((Y_N, Y_C, Y_H * Y_W)) # transformed to im2col Y # XX = X.reshape((X_N, X_C, X_W * X_H)) # transformed to im2col X im2col_XX = self.im2col(X, filter_H, filter_W, padding, stride) gradient_filter = np.zeros(shape=( filter_outChannel, filter_inChannel * filter_H * filter_W), dtype=Y.dtype) for i in range(X_N): gradient_filter += np.matmul(YY[i], im2col_XX[i].T) gradient_filter = gradient_filter.reshape( (filter_outChannel, filter_inChannel, filter_H, filter_W)) return gradient_filter # out_H = (H + 2 * padding - filter_H) / stride + 1 # out_W = (W + 2 * padding - filter_W) / stride + 1 def profile(self, node, input_vals, output_val, is_static = True): assert len(input_vals) == 2 if is_static: # input memory node.profiler.input_memory = get_array_memory(input_vals[0].shape) # get_array_memory(input_vals[1].shape) # output memory node.profiler.output_memory = get_array_memory(output_val.shape) # no workspace node.profiler.workspace_memory = 0 # execute time node.profiler.time = node.profiler.output_memory / 4 * profiler.FLOPS_PER_SECOND else: # import time # start = time.time() from ..gpu_links import CuDNN_conv2d_gradient_of_filter CuDNN_conv2d_gradient_of_filter( input_vals[0], input_vals[1], output_val, padding=self.padding, padding2=self.padding2, stride=self.stride, stream = None, profiler = node.profiler) # node.profiler.time = time.time() - start def compute(self, node, input_vals, output_val, use_numpy=True, stream_handle=None): assert len(input_vals) == 2 f_N = input_vals[1].shape[1] f_C = input_vals[0].shape[1] f_H = input_vals[1].shape[2] + 2 * self.padding - \ (input_vals[1].shape[2] - 1) * self.stride f_W = input_vals[1].shape[3] + 2 * self.padding - \ (input_vals[1].shape[3] - 1) * self.stride if use_numpy: from .._base import DNNL_LIB if DNNL_LIB['DnnlConv2d_Gradient_of_Filter']: from ..cpu_links import conv2d_gradient_of_filter as cpu_conv2d_gradient_of_filter from ..ndarray import numpyasdlarrayhandle input_x = numpyasdlarrayhandle(input_vals[0]) gradient_y = numpyasdlarrayhandle(input_vals[1]) gradient_f = numpyasdlarrayhandle(output_val) cpu_conv2d_gradient_of_filter(input_x, gradient_y, gradient_f, self.padding, self.stride) else: output_val[:] = self.np_Conv2dGradient_Filter( f_N, f_C, f_H, f_W, input_vals[0], input_vals[1], padding=self.padding, stride=self.stride) else: from ..gpu_links import CuDNN_conv2d_gradient_of_filter CuDNN_conv2d_gradient_of_filter( input_vals[0], input_vals[1], output_val, padding=self.padding, padding2=self.padding2, stride=self.stride, stream = stream_handle, profiler = None) def gradient(self, node, output_grad): raise NotImplementedError def infer_shape(self, node, input_shapes): """TODO: Your code here""" assert len(input_shapes) == 2 f_N = input_shapes[1][1] f_C = input_shapes[0][1] f_H = input_shapes[0][2] + 2 * self.padding - \ (input_shapes[1][2] - 1) * self.stride f_W = input_shapes[0][3] + 2 * self.padding2 - \ (input_shapes[1][3] - 1) * self.stride return (f_N, f_C, f_H, f_W) def conv2d_op(node_A, node_B, padding=0, padding2=None, stride=1, For_ResNet = False): """Conv2d node. Parameters: ---- node_A : Node Input data node. node_B : Node Input filter node. padding : Padding size. stride : Stride size. Returns: ---- A new Node instance created by Op. """ return Conv2dOp()(node_A, node_B, padding, padding2, stride, For_ResNet) def conv2d_gradient_of_data_op(node_A, node_B, padding=0, padding2 = None,stride=1, For_ResNet = False): """Gradient node of data of conv2d. Parameters: ---- node_A : Node Filter node. node_B : Node Previous gradient node. padding : Padding size. stride : Stride size. Returns: ---- A new Node instance created by Op. """ return Conv2d_Gradient_of_DataOp()(node_A, node_B, padding, padding2, stride, For_ResNet) def conv2d_gradient_of_filter_op(input_X, gradient_Y, padding=0, padding2=None, stride=1): """Gradient node of filters of conv2d. Parameters: ---- input_X : Input data of conv2d. gradient_Y : Gradient array. padding : Padding size. stride : Stride size. Returns: ---- A new Node instance created by Op. """ return Conv2d_Gradient_of_FilterOp()(input_X, gradient_Y, padding, padding2, stride)
41.900424
166
0.574809
2,663
19,777
3.993616
0.056327
0.045698
0.042125
0.017113
0.854161
0.789845
0.771415
0.702022
0.652374
0.63244
0
0.024242
0.324215
19,777
471
167
41.989384
0.771493
0.090762
0
0.646154
0
0
0.016241
0.012406
0
0
0
0.002123
0.052308
1
0.073846
false
0
0.061538
0.003077
0.193846
0
0
0
0
null
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
f32f60990485375c0c02caad217c70dd4decf3dc
7,874
py
Python
Classification/models/simple.py
amazon-research/network-deconvolution-pp
99e27ecec7d27c7c4c3fb230e96005bdcbf6f2ce
[ "Apache-2.0" ]
6
2021-10-16T15:29:06.000Z
2022-02-17T12:33:52.000Z
Classification/models/simple.py
amazon-research/network-deconvolution-pp
99e27ecec7d27c7c4c3fb230e96005bdcbf6f2ce
[ "Apache-2.0" ]
3
2021-04-02T19:47:05.000Z
2021-10-12T23:11:18.000Z
Classification/models/simple.py
amazon-research/network-deconvolution-pp
99e27ecec7d27c7c4c3fb230e96005bdcbf6f2ce
[ "Apache-2.0" ]
1
2021-10-30T04:50:14.000Z
2021-10-30T04:50:14.000Z
import torch import torch.nn as nn import torch.nn.functional as F from .deconv import * class SimpleCNN_v1(nn.Module): def __init__(self, channels_in=3,kernel_size=32,num_outputs=10,method=2): super(SimpleCNN_v1, self).__init__() if method==1: self.conv = nn.Conv2d(channels_in, num_outputs, kernel_size) elif method==2: self.conv = nn.Sequential(ChannelDeconv(num_groups=3),nn.Conv2d(channels_in, num_outputs, kernel_size)) elif method==3: self.conv=FastDeconv(channels_in,num_outputs,kernel_size) elif method==4: #1<= num_groups <= kernel_size*kernel_size*channels_in num_groups=32 self.deconv = ChannelDeconv(num_groups=num_groups) self.conv=nn.Conv2d(channels_in, num_outputs, kernel_size) self.method=method def forward(self, x): N, C, H, W = x.shape if self.method==4: x=self.deconv(x.view(N,-1,1,1)).view(N,C,H,W) out=self.conv(x).view(x.shape[0],-1) return out class SimpleCNN_v2(nn.Module): def __init__(self, channels_in=3,kernel_size=3,num_outputs=10,hidden_channels=4,hidden_layers=10,method=2): super(SimpleCNN_v2, self).__init__() self.method=method self.layers=nn.ModuleList() if method==1: self.layers.append(nn.Sequential(nn.Conv2d(channels_in,hidden_channels,kernel_size),nn.BatchNorm2d(hidden_channels),nn.ReLU())) padding = 0 for i in range(hidden_layers): if i>=12: padding=1 self.layers.append(nn.Sequential(nn.Conv2d(hidden_channels,hidden_channels+4,kernel_size,padding=padding),nn.BatchNorm2d(hidden_channels+4),nn.ReLU())) hidden_channels=hidden_channels+4 self.layers.append(nn.Sequential(nn.Conv2d(hidden_channels,num_outputs,kernel_size),nn.BatchNorm2d(num_outputs))) elif method==2: num_groups=16 self.layers.append(nn.Sequential(DeConv2d(channels_in,hidden_channels,kernel_size,mode=3,num_groups=min(num_groups,channels_in)),nn.ReLU())) padding = 0 for i in range(hidden_layers): if i>=12: padding=1 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,hidden_channels+4,kernel_size,padding=padding,mode=3,num_groups=min(num_groups,hidden_channels)),nn.ReLU())) hidden_channels=hidden_channels+4 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,num_outputs,kernel_size,mode=3,num_groups=min(num_groups,hidden_channels)))) """ self.layers.append(nn.Sequential(ChannelDeconv(channels_in),nn.Conv2d(channels_in,hidden_channels,kernel_size),nn.ReLU())) padding = 0 for i in range(hidden_layers): if i>=12: padding=1 self.layers.append(nn.Sequential(ChannelDeconv(min(num_groups,hidden_channels)),nn.Conv2d(hidden_channels,hidden_channels+4,kernel_size,padding=padding),nn.ReLU())) hidden_channels=hidden_channels+4 self.layers.append(nn.Sequential(ChannelDeconv(min(num_groups,hidden_channels)),nn.Conv2d(hidden_channels,num_outputs,kernel_size))) """ elif method==3: num_groups=16 self.layers.append(nn.Sequential(DeConv2d(channels_in,hidden_channels,kernel_size,num_groups=min(num_groups,channels_in)),nn.ReLU())) padding = 0 for i in range(hidden_layers): if i>=12: padding=1 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,hidden_channels+4,kernel_size,padding=padding,num_groups=min(num_groups,hidden_channels)),nn.ReLU())) hidden_channels=hidden_channels+4 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,num_outputs,kernel_size,num_groups=min(num_groups,hidden_channels)))) elif method==4: self.layers.append(nn.Sequential(DeConv2d(channels_in,hidden_channels,kernel_size,mode=2),nn.ReLU())) padding = 0 for i in range(hidden_layers): if i>=12: padding=1 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,hidden_channels+4,kernel_size,padding=padding,mode=2),nn.ReLU())) hidden_channels=hidden_channels+4 self.layers.append(nn.Sequential(DeConv2d(hidden_channels,num_outputs,kernel_size,mode=2))) print(hidden_channels,'hidden channels in the final layer.') def forward(self, x): N, C, H, W = x.shape encode=[x] for i in range(len(self.layers)): x=self.layers[i](x) encode.append(x) out=F.avg_pool2d(x,x.shape[-2:]) #print([e.abs().max().item() for e in encode] ) #print([e.var().item() for e in encode]) return out.view(out.shape[0],-1) class MLP(nn.Module): def __init__(self,input_nodes, num_outputs=10,hidden_nodes=128,hidden_layers=3,method=1): super(MLP, self).__init__() self.layers = nn.ModuleList() if method == 1: self.layers.append( nn.Sequential(nn.Linear(input_nodes, hidden_nodes, bias=True))) for i in range(hidden_layers-2): self.layers.append(nn.Sequential(nn.Sigmoid(),nn.Linear(hidden_nodes, hidden_nodes,bias=True))) self.linear = nn.Sequential(nn.Sigmoid(),nn.Linear(hidden_nodes, num_outputs, bias=True)) if method == 2: self.layers.append( nn.Sequential(nn.Linear(input_nodes, hidden_nodes, bias=False))) for i in range(hidden_layers-2): self.layers.append(nn.Sequential(nn.BatchNorm1d(hidden_nodes),nn.Sigmoid(),nn.Linear(hidden_nodes, hidden_nodes,bias=False))) self.linear = nn.Sequential(nn.BatchNorm1d(hidden_nodes),nn.Sigmoid(),nn.Linear(hidden_nodes, num_outputs, bias=False)) elif method == 3: num_groups=32 self.layers.append( nn.Sequential(ChannelDeconv(num_groups),nn.Linear(input_nodes, hidden_nodes, bias=False))) for i in range(hidden_layers - 2): self.layers.append(nn.Sequential(nn.Sigmoid(),ChannelDeconv(num_groups), nn.Linear(hidden_nodes, hidden_nodes, bias=False))) self.linear = nn.Sequential(nn.Sigmoid(),ChannelDeconv(num_groups), nn.Linear(hidden_nodes, num_outputs, bias=False)) elif method == 4: num_groups=32 self.layers.append( nn.Sequential(ChannelDeconv(num_groups),nn.Linear(input_nodes, hidden_nodes, bias=False))) for i in range(hidden_layers - 2): self.layers.append(nn.Sequential(nn.BatchNorm1d(hidden_nodes),nn.Sigmoid(),ChannelDeconv(num_groups), nn.Linear(hidden_nodes, hidden_nodes, bias=False))) self.linear = nn.Sequential(nn.BatchNorm1d(hidden_nodes),nn.Sigmoid(),ChannelDeconv(num_groups), nn.Linear(hidden_nodes, num_outputs, bias=False)) print(hidden_nodes, ' hidden nodes in each layer.') print(len(self.layers)+1, ' middle layers.') for m in self.modules(): if isinstance(m, nn.Linear): if m.bias is not None: nn.init.constant_(m.bias, 0) def forward(self, x): encode=[x.view(x.shape[0],-1)] encode.append(self.layers[0](encode[-1])) for i, layer in enumerate(self.layers[1:]): encode.append(layer(encode[-1])) encode.append(self.linear(encode[-1])) return encode[-1]
44.485876
182
0.625349
1,027
7,874
4.607595
0.09445
0.121302
0.077768
0.087489
0.776205
0.746619
0.730347
0.719992
0.700549
0.654057
0
0.02294
0.252604
7,874
176
183
44.738636
0.781138
0.017526
0
0.495935
0
0
0.011023
0
0
0
0
0
0
1
0.04878
false
0
0.03252
0
0.130081
0.02439
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
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
f33236b5ee6ac9ea2ecec2c6df7d338d1270dba6
42
py
Python
tests/__init__.py
braedon/oauthlib
6875e3ac513a3828c3328d4f585d4c38b2b2c698
[ "BSD-3-Clause" ]
954
2018-01-27T11:00:51.000Z
2022-03-31T16:04:42.000Z
tests/__init__.py
braedon/oauthlib
6875e3ac513a3828c3328d4f585d4c38b2b2c698
[ "BSD-3-Clause" ]
274
2018-01-27T08:36:01.000Z
2022-03-22T04:40:40.000Z
tests/__init__.py
braedon/oauthlib
6875e3ac513a3828c3328d4f585d4c38b2b2c698
[ "BSD-3-Clause" ]
191
2018-02-15T12:12:45.000Z
2022-03-31T22:38:13.000Z
import oauthlib oauthlib.set_debug(True)
10.5
24
0.833333
6
42
5.666667
0.833333
0
0
0
0
0
0
0
0
0
0
0
0.095238
42
3
25
14
0.894737
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
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
0
0
0
1
0
1
0
0
0
0
5
f36e4fe951b9fad7685cd6a951352d4db7e4f77d
20
py
Python
tests/test_bad_app/telegrambot.py
gassan/django-telegrambot
e38076b4fc0e100700de8640ed3c1a2fa2985fe0
[ "BSD-3-Clause" ]
245
2016-01-26T16:24:41.000Z
2022-03-07T08:00:36.000Z
tests/test_bad_app/telegrambot.py
gassan/django-telegrambot
e38076b4fc0e100700de8640ed3c1a2fa2985fe0
[ "BSD-3-Clause" ]
49
2016-09-17T02:26:50.000Z
2021-12-20T06:53:19.000Z
tests/test_bad_app/telegrambot.py
gassan/django-telegrambot
e38076b4fc0e100700de8640ed3c1a2fa2985fe0
[ "BSD-3-Clause" ]
97
2016-04-17T22:05:19.000Z
2022-03-24T11:04:48.000Z
raise ImportError()
10
19
0.8
2
20
8
1
0
0
0
0
0
0
0
0
0
0
0
0.1
20
1
20
20
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
0
0
0
5
f3897fd1c4851d664df67ce0c53b269e95e4785b
90,167
py
Python
test_main.py
jrmh96/algorithm_toolkit
4a39e26d89973c6d1e229952f46d413b93c27df9
[ "MIT" ]
9
2019-02-25T03:41:14.000Z
2021-02-04T19:47:58.000Z
test_main.py
jrmh96/algorithm_toolkit
4a39e26d89973c6d1e229952f46d413b93c27df9
[ "MIT" ]
24
2019-08-23T17:04:00.000Z
2022-03-11T23:41:08.000Z
test_main.py
jrmh96/algorithm_toolkit
4a39e26d89973c6d1e229952f46d413b93c27df9
[ "MIT" ]
4
2019-03-05T02:14:20.000Z
2020-02-12T20:11:16.000Z
import json import os import re import shutil import subprocess import sys import unittest import warnings from logging import StreamHandler from flask_testing import TestCase from wtforms.fields import core as wtfields from wtforms import widgets as wtwidgets from wtforms.validators import InputRequired, Optional from t_utils import ( get_algorithms, get_chains, get_updated_chain, get_chain_algs, get_test_run_chain, test_algorithm_form_data, get_chain_builder_block_list, get_chain_builder_additional_block, get_chain_builder_block_scripts, get_chain_builder_additional_script, get_chain_builder_chain_blocks ) os.environ['ATK_CONFIG'] = os.path.join(os.path.dirname( os.path.abspath(__file__)), 't_config.py') updated_chain = get_updated_chain() algs = get_algorithms() this_path = os.path.dirname(os.path.abspath(__file__)) test_alg_path = os.path.join(this_path, 'test_project') block_list = get_chain_builder_block_list() block_scripts = get_chain_builder_block_scripts() with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) class ATKTestCase(TestCase): def create_app(self): from algorithm_toolkit import app return app def setUp(self): sys.path.append(test_alg_path) subprocess.call(['alg', 'cp', 'test_project', '-e', '-q']) def tearDown(self): # pass shutil.rmtree(test_alg_path) def test_config_vars(self): print('Ensure environment is set up properly') config = self.app.config self.assertEqual(type(config['LOG_HANDLERS'][0]), StreamHandler) self.assertEqual( config['CORS_ORIGIN_WHITELIST'], [ 'http://localhost', 'https://mytiledriver.com', 'https://tdprocess.com' ] ) self.assertEqual(config['ATK_PATH'], test_alg_path) self.assertEqual( self.app.jinja_loader.searchpath[0], test_alg_path + '/templates') def test_atk_home(self): print('Home page should display correctly') chain_def = get_chains() response = self.client.get('/') self.assert200(response) self.assertTemplateUsed('index.html') self.assertContext('nav', 'index') self.assertContext('docs', False) self.assertContext('chains', chain_def) def test_algorithm_home(self): print('Algorithm list page should display correctly') chain_def = get_chains() response = self.client.get('/algorithms/') self.assert200(response) self.assertTemplateUsed('algorithms.html') self.assertContext('nav', 'algorithms') self.assertContext('docs', False) self.assertContext('chains', chain_def) self.assertContext('algs', sorted(algs, key=lambda a: a['name'])) def test_list_chains_no_key(self): print('List chains should fail if the API key is missing') response = self.client.get('/list_chains/') self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') def test_list_chains(self): print('List chains should ... list the chains') chain_def = get_chains() response = self.client.get('/list_chains/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( chain_def, separators=(',', ':'), sort_keys=True) + '\n') def test_chain_info_no_key(self): print('Chain info should fail if the API key is missing') response = self.client.get('/chain_info/map_tiles/') self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') def test_chain_info(self): print('Chain info should ... provide chain info') chain_def = get_chains() response = self.client.get('/chain_info/map_tiles/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( chain_def['map_tiles'], separators=(',', ':'), sort_keys=True ) + '\n') def test_chain_algs_no_key(self): print('Chain algorithms should fail if the API key is missing') response = self.client.get('/chain_algorithms/map_tiles/') self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') def test_chain_algs(self): print('Chain algorithms should list the algorithms in a chain') chain_algs = get_chain_algs() response = self.client.get( '/chain_algorithms/map_tiles/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( chain_algs, separators=(',', ':'), sort_keys=True ) + '\n') # add a required parameter and ensure it displays in chain_algorithms r_param = { "default_value": "", "field_type": "text", "display_name": "Useless Yet Required Parameter", "name": "useless_required", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything, and yet you must", "custom_validation": None, "description": "A completely useless yet required parameter.", "source": "user" } chain_algs[1]['required_parameters'].append(r_param) json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') chains_file = os.path.join(test_alg_path, 'chains.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: stitch_tiles['required_parameters'].append(r_param) alg_file.write(json.dumps(stitch_tiles)) # new parameter is missing fron chains.json # atk should assume this is a user parameter response = self.client.get( '/chain_algorithms/map_tiles/?api_key=testkey') self.assert200(response) # add param to chains.json chain_def = get_chains() chain_def['map_tiles'][1]['parameters']['useless_required'] = { 'source': 'user' } # print(chain_def) with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) # should now be included response = self.client.get( '/chain_algorithms/map_tiles/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( chain_algs, separators=(',', ':'), sort_keys=True ) + '\n') # add an optional parameter and ensure it displays in chain_algorithms o_param = { "default_value": "", "field_type": "text", "display_name": "Useless Parameter", "name": "useless", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything", "custom_validation": None, "description": "A completely useless parameter.", "source": "user" } chain_algs[1]['optional_parameters'].append(o_param) json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') chains_file = os.path.join(test_alg_path, 'chains.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: stitch_tiles['optional_parameters'].append(o_param) alg_file.write(json.dumps(stitch_tiles)) # new parameter is missing fron chains.json # but should be fine response = self.client.get( '/chain_algorithms/map_tiles/?api_key=testkey') self.assert200(response) # add param to chains.json chain_def['map_tiles'][1]['parameters']['useless'] = { 'source': 'user' } # print(chain_def) with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) # should now be included response = self.client.get( '/chain_algorithms/map_tiles/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( chain_algs, separators=(',', ':'), sort_keys=True ) + '\n') def test_alg_info_no_key(self): print('Algorithm info should fail if the API key is missing') response = self.client.get('/algorithm_info/getmaptiles_roi/') self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') def test_alg_info(self): print('Algorithm info should ... provide algorithm info') alg = [x for x in algs if x['name'] == 'getmaptiles_roi'][0] response = self.client.get( '/algorithm_info/getmaptiles_roi/?api_key=testkey') self.assert200(response) self.assertEqual(response.data, json.dumps( alg, separators=(',', ':'), sort_keys=True ) + '\n') def test_create_algorithms_get(self): from algorithm_toolkit.forms import ( AlgorithmCreateForm, AlgorithmOutputForm, AlgorithmParameterForm ) print('Create algorithm page should display correctly') chain_def = get_chains() response = self.client.get('/algorithms/create/') form = self.get_context_variable('form') o_form = self.get_context_variable('o_form') p_form = self.get_context_variable('p_form') self.assert200(response) self.assertTemplateUsed('create_algorithm.html') self.assertContext('nav', 'algorithms') self.assertContext('docs', False) self.assertContext('chains', chain_def) self.assertContext('algs', sorted([x['name'] for x in algs])) self.assertEqual(type(form), AlgorithmCreateForm) self.assertEqual(type(o_form), AlgorithmOutputForm) self.assertEqual(type(p_form), AlgorithmParameterForm) # test without the private flag json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: del stitch_tiles['private'] alg_file.write(json.dumps(stitch_tiles)) response = self.client.get('/algorithms/create/stitch_tiles/') self.assert200(response) self.assertContext( 'algs', sorted([x['name'] for x in algs if x['name'] != 'stitch_tiles']) ) def test_create_algorithms_post(self): print('Create algorithm page should create an algorithm correctly') data = test_algorithm_form_data() data['parameters'] = json.dumps( data['parameters'], separators=(', ', ': '), sort_keys=True) data['outputs'] = json.dumps( data['outputs'], separators=(', ', ': '), sort_keys=True) data['api_key'] = 'testkey' new_alg_path = os.path.join( test_alg_path, 'algorithms', 'add_numbers') response = self.client.post( '/algorithms/create/', data=data, follow_redirects=True) self.assert200(response) self.assertTrue(os.path.exists(new_alg_path)) response = self.client.get('/algorithms/create/add_numbers/') form = self.get_context_variable('form') self.assertEqual(form.name.data, 'add_numbers') self.assertEqual( form.display_name.data, 'Add two numbers' ) self.assertEqual(form.license.data, 'Proprietary') self.assertEqual(form.private.data, True) self.assertEqual(form.version.data, '0.0.1') self.assertEqual( form.homepage.data, 'google.com') self.assertEqual( form.description.data, 'Add two numbers together to get a result.' ) self.assertEqual( json.loads(form.parameters.data), json.loads(data['parameters'])) self.assertEqual( json.loads(form.outputs.data), json.loads(data['outputs'])) def test_edit_algorithms_get(self): from algorithm_toolkit.forms import ( AlgorithmCreateForm, AlgorithmOutputForm, AlgorithmParameterForm ) print('Edit algorithm page should display correctly') def add_required(p, r): p['required'] = r return p chain_def = get_chains() this_alg = [x for x in algs if x['name'] == 'getmaptiles_roi'][0] r_params = [add_required( x, True) for x in this_alg['required_parameters']] o_params = [add_required( x, False) for x in this_alg['optional_parameters']] params = r_params + o_params response = self.client.get('/algorithms/create/getmaptiles_roi/') form = self.get_context_variable('form') o_form = self.get_context_variable('o_form') p_form = self.get_context_variable('p_form') self.assert200(response) self.assertTemplateUsed('create_algorithm.html') self.assertContext('nav', 'algorithms') self.assertContext('docs', False) self.assertContext('chains', chain_def) self.assertContext( 'algs', sorted([x['name'] for x in algs if x['name'] != 'getmaptiles_roi']) ) self.assertEqual(type(form), AlgorithmCreateForm) self.assertEqual(type(o_form), AlgorithmOutputForm) self.assertEqual(type(p_form), AlgorithmParameterForm) self.assertEqual(form.name.data, 'getmaptiles_roi') self.assertEqual(form.display_name.data, 'Get Map Tiles In ROI') self.assertEqual(form.license.data, 'MIT') self.assertEqual(form.private.data, False) self.assertEqual(form.version.data, '0.0.1') self.assertEqual( form.homepage.data, 'https://tiledriver.com/developer') self.assertEqual( form.description.data, 'This algorithm will gather up map tiles at a given zoom level ' 'that intersect with the provided polygon. The source is the ' 'national map provided by USGS. All tiles will be written out ' 'to disk at a specified location. This location is also saved ' 'onto the chain ledger.' ) temp_params = json.loads(form.parameters.data) for p in temp_params: p.pop('original_name', None) temp_outs = json.loads(form.outputs.data) for out in temp_outs: out.pop('original_name', None) self.assertEqual(temp_params, params) self.assertEqual(temp_outs, this_alg['outputs']) def test_edit_algorithms_post(self): print('Edit algorithm page should modify an algorithm correctly') # get initial algorithm data response = self.client.get('/algorithms/create/getmaptiles_roi/') form = self.get_context_variable('form') this_alg = form.data # modify it this_alg['display_name'] = 'Do something crazy with map tiles' this_alg['license'] = 'GNU LGPLv3' this_alg['private'] = True this_alg['version'] = '0.0.2' this_alg['homepage'] = 'google.com' this_alg['description'] = 'Do some stuff, I dunno.' this_alg['api_key'] = 'testkey' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') # should see new data reflected in the algorithm response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('GNU LESSER GENERAL PUBLIC LICENSE' in lic) self.assertEqual(new_form.name.data, 'getmaptiles_roi') self.assertEqual( new_form.display_name.data, 'Do something crazy with map tiles') self.assertEqual(new_form.license.data, 'GNU LGPLv3') self.assertEqual(new_form.private.data, True) self.assertEqual(new_form.version.data, '0.0.2') self.assertEqual(new_form.homepage.data, 'google.com') self.assertEqual( new_form.description.data, 'Do some stuff, I dunno.') def test_change_algorithm_name(self): print('A user should be able to change the name of an algorithm') # get initial algorithm data response = self.client.get('/algorithms/create/getmaptiles_roi/') form = self.get_context_variable('form') this_alg = form.data # modify it this_alg['name'] = 'thingie_splunge' new_alg_path = os.path.join( test_alg_path, 'algorithms', 'thingie_splunge') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/thingie_splunge/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.name.data, 'thingie_splunge') self.assertTrue(os.path.exists(new_alg_path)) def test_edit_algorithm_not_found(self): print( 'A user trying to edit a non-existing algorithm should get a 404') # get initial algorithm data response = self.client.get('/algorithms/create/thingie_splunge/') self.assert404(response) self.assertEqual(response.data, 'Algorithm not found') def test_edit_algorithm_no_private_field(self): print( 'An algorithm should still be saved if the private flag is missing' ) # get initial algorithm data response = self.client.get('/algorithms/create/getmaptiles_roi/') form = self.get_context_variable('form') this_alg = form.data # modify it del this_alg['private'] response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.private.data, False) def test_edit_algorithm_change_license(self): print('A user should be able to change the license of an algorithm') # get initial algorithm data response = self.client.get('/algorithms/create/getmaptiles_roi/') form = self.get_context_variable('form') this_alg = form.data # modify it to AGPL this_alg['license'] = 'GNU AGPLv3' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'GNU AGPLv3') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('GNU AFFERO GENERAL PUBLIC LICENSE' in lic) # modify it to GPL this_alg['license'] = 'GNU GPLv3' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'GNU GPLv3') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('GNU GENERAL PUBLIC LICENSE' in lic) # modify it to Unlicense this_alg['license'] = 'The Unlicense' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'The Unlicense') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('http://unlicense.org' in lic) # modify it to Apache this_alg['license'] = 'Apache' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'Apache') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('http://www.apache.org/licenses/' in lic) # modify it to Mozilla this_alg['license'] = 'Mozilla' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'Mozilla') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('Mozilla Public License Version 2.0' in lic) # modify it to MIT this_alg['license'] = 'MIT' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'MIT') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue('MIT License' in lic) # modify it to Propietary this_alg['license'] = 'Proprietary' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'Proprietary') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue(lic == '') # modify it to Other this_alg['license'] = 'Other' new_license_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'LICENSE') response = self.client.post( '/algorithms/create/getmaptiles_roi/', data=this_alg, follow_redirects=True ) self.assert200(response) response = self.client.get('/algorithms/create/getmaptiles_roi/') self.assert200(response) new_form = self.get_context_variable('form') self.assertEqual(new_form.license.data, 'Other') with open(new_license_path, 'r') as lic_file: lic = lic_file.read() self.assertTrue(lic == '') def test_copy_algorithms(self): print('Users should be able to copy an algorithm') def add_required(p, r): p['required'] = r return p # make a copy response = self.client.get( '/algorithm/copy/getmaptiles_roi/', follow_redirects=True) self.assert200(response) # ensure we're redirected to algorithms page self.assertTemplateUsed('algorithms.html') new_alg_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi_copy') self.assertTrue(os.path.exists(new_alg_path)) # ensure copy has the right data this_alg = [x for x in algs if x['name'] == 'getmaptiles_roi'][0] r_params = [add_required( x, True) for x in this_alg['required_parameters']] o_params = [add_required( x, False) for x in this_alg['optional_parameters']] params = r_params + o_params response = self.client.get('/algorithms/create/getmaptiles_roi_copy/') form = self.get_context_variable('form') self.assert200(response) self.assertEqual(form.name.data, 'getmaptiles_roi_copy') self.assertEqual(form.display_name.data, 'Get Map Tiles In ROI') self.assertEqual(form.license.data, 'MIT') self.assertEqual(form.private.data, False) self.assertEqual(form.version.data, '0.0.1') self.assertEqual( form.homepage.data, 'https://tiledriver.com/developer') self.assertEqual( form.description.data, 'This algorithm will gather up map tiles at a given zoom level ' 'that intersect with the provided polygon. The source is the ' 'national map provided by USGS. All tiles will be written out ' 'to disk at a specified location. This location is also saved ' 'onto the chain ledger.' ) temp_params = json.loads(form.parameters.data) for p in temp_params: p.pop('original_name', None) temp_outs = json.loads(form.outputs.data) for out in temp_outs: out.pop('original_name', None) self.assertEqual(temp_params, params) self.assertEqual(temp_outs, this_alg['outputs']) # make a second copy response = self.client.get( '/algorithm/copy/getmaptiles_roi/', follow_redirects=True) self.assert200(response) new_alg_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi_copy1') self.assertTrue(os.path.exists(new_alg_path)) def test_delete_algorithms(self): print('Users should be able to delete an algorithm') # set working directory os.chdir(test_alg_path) # delete the algorithm response = self.client.get( '/algorithm/delete/getmaptiles_roi/', follow_redirects=True) self.assert200(response) # ensure we're redirected to algorithms page self.assertTemplateUsed('algorithms.html') new_alg_path = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi') self.assertFalse(os.path.exists(new_alg_path)) # ensure references are removed from chains.json chain_path = os.path.join(test_alg_path, 'chains.json') with open(chain_path, 'r') as chain_file: chains = chain_file.read() self.assertFalse('getmaptiles_roi' in chains) # reset working directory os.chdir(this_path) def test_chain_builder(self): print('Chain builder page should display correctly') chain_def = get_chains() additional_block = get_chain_builder_additional_block() additional_script = get_chain_builder_additional_script() response = self.client.get('/chain_builder/') blocks = self.get_context_variable('block_list') scripts = self.get_context_variable('block_scripts') self.assert200(response) self.assertTemplateUsed('chain_builder.html') self.assertContext('nav', 'chain_builder') self.assertContext('docs', False) self.assertContext('chains', chain_def) for idx, block in enumerate(blocks): temp_block = re.sub(r'colour="(\d+)"', 'colour="222"', block) self.assertEqual(temp_block, block_list[idx]) for idx, script in enumerate(scripts): temp_script = re.sub( r'setColour\((\d+)\)', 'setColour(222)', script) self.assertEqual(temp_script, block_scripts[idx]) self.assertContext('chain_obj', json.dumps(chain_def)) # add additional algorithm data = test_algorithm_form_data() data['name'] = 'beamio/add_numbers' data['parameters'] = json.dumps( data['parameters'], separators=(', ', ': '), sort_keys=True) data['outputs'] = json.dumps( data['outputs'], separators=(', ', ': '), sort_keys=True) data['api_key'] = 'testkey' response = self.client.post( '/algorithms/create/', data=data, follow_redirects=True) response = self.client.get('/chain_builder/') blocks = self.get_context_variable('block_list') scripts = self.get_context_variable('block_scripts') for idx, block in enumerate(blocks): temp_block = re.sub(r'colour="(\d+)"', 'colour="222"', block) self.assertEqual(temp_block, additional_block[idx]) for idx, script in enumerate(scripts): temp_script = re.sub( r'setColour\((\d+)\)', 'setColour(222)', script) self.assertEqual(temp_script, additional_script[idx]) # test removing parameters json_file = os.path.join( test_alg_path, 'algorithms', 'beamio', 'add_numbers', 'algorithm.json' ) with open(json_file, 'r') as alg_file: add_numbers = json.load(alg_file) with open(json_file, 'w') as alg_file: add_numbers['required_parameters'] = [] alg_file.write(json.dumps(add_numbers)) response = self.client.get('/chain_builder/') temp_script = self.get_context_variable('block_scripts')[3] self.assert200(response) self.assertFalse('Required Input Fields:' in temp_script) self.assertTrue('Optional Input Fields:' in temp_script) with open(json_file, 'w') as alg_file: del add_numbers['required_parameters'] del add_numbers['optional_parameters'] alg_file.write(json.dumps(add_numbers)) response = self.client.get('/chain_builder/') temp_script = self.get_context_variable('block_scripts')[3] self.assert200(response) self.assertFalse('Required Input Fields:' in temp_script) self.assertFalse('Optional Input Fields:' in temp_script) def test_chain_builder_get_blocks(self): print( 'When a user requests a chain in chain builder, ' 'the chain blocks should display correctly.' ) chain_blocks = get_chain_builder_chain_blocks() response = self.client.get('/chain_builder/get_blocks/map_tiles/') temp_blocks = re.sub( r'<block type="(\w+)" id="\w+"', r'<block type="\1" id="testid"', response.data ) self.assert200(response) self.assertEqual(temp_blocks, chain_blocks) # add an optional parameter o_param = { "default_value": "", "field_type": "text", "display_name": "Useless Parameter", "name": "useless", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything", "custom_validation": None, "description": "A completely useless parameter.", } json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') chains_file = os.path.join(test_alg_path, 'chains.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: stitch_tiles['optional_parameters'].append(o_param) alg_file.write(json.dumps(stitch_tiles)) # add param to chains.json chain_def = get_chains() chain_def['map_tiles'][1]['parameters']['useless'] = { 'source': 'user' } with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) new_block = ( '<value name="useless">\n' '<block type="user_input" id="testid">\n' '<data>input</data>\n' ) response = self.client.get('/chain_builder/get_blocks/map_tiles/') temp_blocks = re.sub( r'<block type="(\w+)" id="\w+"', r'<block type="\1" id="testid"', response.data ) self.assert200(response) self.assertTrue(new_block in temp_blocks) def test_update_chains_error(self): print( 'If update_chains is called without a chains ' 'value, atk should throw an error' ) response = self.client.post('/chain_builder/update_chains/', data={}) self.assert400(response) self.assertEqual(response.data, 'Missing chain definitions') def test_update_chains(self): print('Update chains should ... update the chains') chain_list = '<a class="dropdown-item" href="' chain_list += '/test_run/map_tiles/">map_tiles</a>' chain_list += '<a class="dropdown-item" href="' chain_list += '/test_run/do_some_math/">do_some_math</a>' new_chain_path = os.path.join(test_alg_path, 'chains.json') response = self.client.post( '/chain_builder/update_chains/', data={'chains': json.dumps(updated_chain)} ) with open(new_chain_path) as new_chain_file: new_chains = new_chain_file.read() self.assert200(response) self.assertEqual(json.loads(new_chains), updated_chain) self.assertEqual(response.data, chain_list) def test_main_errors(self): print( 'If main is called without proper request ' 'values, atk should throw an error' ) # no api key response = self.client.post('/main/', data={}) self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') # no chain parameter response = self.client.post('/main/', data={'api_key': 'testkey'}) self.assert400(response) self.assertEqual(response.data, 'Missing chain parameter in request') # chain parameter is not json serializable response = self.client.post( '/main/', data={'chain': 'splunge', 'api_key': 'testkey'}) self.assert400(response) self.assertEqual( response.data, 'Chain parameter not properly formatted') # no key for chain name in chain parameter response = self.client.post( '/main/', data={ 'chain': '{"thingie": "splunge"}', 'api_key': 'testkey'}) self.assert400(response) self.assertEqual(response.data, 'Chain name not defined') # no key for algorithms response = self.client.post( '/main/', data={ 'chain': '{"chain_name": "splunge"}', 'api_key': 'testkey'}) self.assert400(response) self.assertEqual(response.data, 'Algorithms not defined') # chain name does not exist response = self.client.post( '/main/', data={ 'chain': '{"chain_name": "splunge", "algorithms": []}', 'api_key': 'testkey' }) self.assert404(response) self.assertEqual(response.data, 'Chain name not found') # non-existent algorithm name test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 extra_alg = { "name": "thingie", "parameters": {} } test_run_chain['algorithms'].append(extra_alg) data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } response = self.client.post('/main/', data=data) self.assert400(response) self.assertEqual( json.loads(response.data), { "error_list": { "error": "Algorithm not found", "parameter": "" }, "message": "Error in parameters", "output_type": "error" } ) def test_main_run(self): print( 'Calling the main endpoint should execute a chain' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 retval = { "output_type": "geo_raster", "output_value": { "extent": "[[39.095962936305476, -77.34374999999999], " "[38.54816542304656, -76.640625]]" } } data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } response = self.client.post('/main/', data=data) self.assert200(response) resp_json = json.loads(response.data) self.assertEqual(resp_json['output_type'], retval['output_type']) self.assertEqual( resp_json['output_value']['extent'], retval['output_value']['extent']) self.assertTrue('raster' in resp_json['output_value']) def test_main_run_no_chain_output(self): print( 'Calling the main endpoint without adding chain_output_value ' ' to the chain ledger should output a default message' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 del test_run_chain['algorithms'][2] retval = { "output_type": "string", "output_value": 'Chain run complete.' } data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } response = self.client.post('/main/', data=data) self.assert200(response) self.assertEqual(json.loads(response.data), retval) def test_main_run_missing_parameters(self): print( 'Calling the main endpoint without parameters should execute ' 'a chain or throw an error, depending' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 retval = { "output_type": "geo_raster", "output_value": { "extent": "[[39.095962936305476, -77.34374999999999], " "[38.54816542304656, -76.640625]]" } } # removing a chain_ledger parameter should proceed normally del test_run_chain['algorithms'][1]['parameters'] data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } response = self.client.post('/main/', data=data) self.assert200(response) resp_json = json.loads(response.data) self.assertEqual(resp_json['output_type'], retval['output_type']) self.assertEqual( resp_json['output_value']['extent'], retval['output_value']['extent']) self.assertTrue('raster' in resp_json['output_value']) # removing a user parameter should fail del test_run_chain['algorithms'][0]['parameters'] data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } errors = { "output_type": "error", "error_list": [ { "error": "Parameter missing", "parameter": "roi" }, { "error": "roi", "parameter": "roi" }, { "error": "Parameter missing", "parameter": "zoom" }, { "error": "zoom", "parameter": "zoom" } ], "message": "Error in parameters" } response = self.client.post('/main/', data=data) self.assert400(response) self.assertEqual(json.loads(response.data), errors) def test_main_run_get(self): print( 'Applications should be able to call the main endpoint using GET' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 response = self.client.get( '/main/?api_key=testkey&chain=' + json.dumps(test_run_chain)) self.assert200(response) # add a required parameter and ensure chain still runs r_param = { "default_value": "", "field_type": "text", "display_name": "Useless Yet Required Parameter", "name": "useless_required", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything, and yet you must", "custom_validation": None, "description": "A completely useless yet required parameter.", "source": "user" } json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') chains_file = os.path.join(test_alg_path, 'chains.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: stitch_tiles['required_parameters'].append(r_param) alg_file.write(json.dumps(stitch_tiles)) # add param to chains.json chain_def = get_chains() chain_def['map_tiles'][1]['parameters']['useless_required'] = { 'source': 'user' } with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) # remove 'source' key from parameter in chain test_run_chain['algorithms'][1]['parameters']['useless_required'] = '1' response = self.client.get( '/main/?api_key=testkey&chain=' + json.dumps(test_run_chain)) self.assert200(response) chain_def['map_tiles'][1]['parameters']['useless_required'] = {} with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) response = self.client.get( '/main/?api_key=testkey&chain=' + json.dumps(test_run_chain)) self.assert200(response) # remove 'occurrence' key in chain parameter del chain_def['map_tiles'][1][ 'parameters']['image_filenames']['occurrence'] with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) response = self.client.get( '/main/?api_key=testkey&chain=' + json.dumps(test_run_chain)) self.assert200(response) # remove 'source_algorithm' key in chain parameter # should fail this time del chain_def['map_tiles'][1][ 'parameters']['image_filenames']['source_algorithm'] with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) response = self.client.get( '/main/?api_key=testkey&chain=' + json.dumps(test_run_chain)) self.assert400(response) self.assertEqual( json.loads(response.data), { "output_type": "error", "error_list": [ { "error": "Parameter missing", "parameter": "image_filenames" }, { "error": "image_filenames", "parameter": "image_filenames" } ], "message": "Error in parameters" } ) def test_main_run_not_integer(self): print( 'ATK should return appropriate errors if ' 'a string is submitted for an integer field' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 'zoom' data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } zoom_errors = { "output_type": "error", "message": "Error in parameters", "error_list": [ { "error": "Not a valid integer", "parameter": "zoom" } ], } response = self.client.post('/main/', data=data) self.assert400(response) self.assertEqual(json.loads(response.data), zoom_errors) def test_main_run_integer_too_large(self): print( 'ATK should return appropriate errors if ' 'an integer value is larger than the max value' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 20 data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } zoom_errors = { "output_type": "error", "error_list": [ { "error": "Value too large", "parameter": "zoom" } ], "message": "Error in parameters" } response = self.client.post('/main/', data=data) self.assert400(response) self.assertEqual(json.loads(response.data), zoom_errors) def test_main_run_integer_too_small(self): print( 'ATK should return appropriate errors if ' 'an integer value is smaller than the min value' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 2 data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain) } zoom_errors = { "output_type": "error", "error_list": [ { "error": "Value too small", "parameter": "zoom" } ], "message": "Error in parameters" } response = self.client.post('/main/', data=data) self.assert400(response) self.assertEqual(json.loads(response.data), zoom_errors) def test_main_run_status_key(self): print( 'Applications should be able to supply a ' 'status key to the main endpoint' ) # TODO: see if we can make this more reliable # because of USGS web TMS test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 retval = { 'all_msg': 'Starting chain run... \nRunning algorithm: ' 'getmaptiles_roi \nstarting to fetch 3 tiles \n' 'fetched tile: /tmp/throatwarblermangrove/temp/' '292_392_10.png \nfetched tile: /tmp/throatwarblermangrove/' 'temp/292_391_10.png \nfetched tile: /tmp/' 'throatwarblermangrove/temp/293_391_10.png \n' 'Running algorithm: stitch_tiles \n' 'Stitching tile: /tmp/throatwarblermangrove/temp/' '292_392_10.png \nStitching tile: /tmp/throatwarblermangrove/' 'temp/292_391_10.png \nStitching tile: /tmp/' 'throatwarblermangrove/temp/293_391_10.png \n' 'writing out stitched image to disk \n' 'Running algorithm: output_image_to_client \n' 'Chain run complete', 'batch_percent_complete': 0, 'chain_percent_complete': 100, 'latest_msg': 'Chain run complete', 'algorithm_percent_complete': 100 } data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain), 'status_key': 'throatwarblermangrove' } response = self.client.post('/main/', data=data) if response.status_code != 200: print(response.data) self.assert200(response) response = self.client.post( '/chain_run_status/throatwarblermangrove/?api_key=testkey') resp_json = json.loads(response.data) self.assert200(response) self.assertEqual(resp_json, retval) def test_get_status_errors(self): print( 'Calling the chain_run_status endpoint ' 'improperly should return errors' ) test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['zoom'] = 10 data = { 'api_key': 'testkey', 'chain': json.dumps(test_run_chain), 'status_key': 'johangambolputty' } response = self.client.post('/main/', data=data) # GET instead of POST response = self.client.get('/chain_run_status/johangambolputty/') self.assert405(response) self.assertTrue('405 Method Not Allowed' in response.data) # no api key response = self.client.post('/chain_run_status/johangambolputty/') self.assert401(response) self.assertEqual(response.data, 'API key wrong or missing') # wrong status key response = self.client.post( '/chain_run_status/ofulm/', data={'api_key': 'testkey'}) self.assert404(response) self.assertEqual(response.data, 'Invalid status key') def test_test_run(self): print('test_run endpoint should display correctly') chain_def = get_chains() # no chain name response = self.client.get('/test_run/') self.assert404(response) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) self.assertTemplateUsed('test_run.html') self.assertContext('nav', 'test_run') self.assertContext('docs', False) self.assertContext('chains', chain_def) self.assertContext('chain', {}) this_field = form._fields['getmaptiles_roi__roi_0'] self.assertTrue('getmaptiles_roi__roi_0' in form._fields) self.assertEqual(type(this_field), wtfields.StringField) self.assertEqual(type(this_field.widget), wtwidgets.core.TextInput) self.assertEqual(this_field.description, '') self.assertEqual(this_field.short_name, 'getmaptiles_roi__roi_0') self.assertEqual(this_field.id, 'getmaptiles_roi__roi_0') self.assertEqual(this_field.name, 'getmaptiles_roi__roi_0') self.assertEqual( this_field.default, 'POLYGON((-77.0419692993164 38.9933585922412,-77.17311859130861 ' '38.891887936025896,-77.03853607177736 38.790272111428706,' '-76.91013336181642 38.891887936025896,-77.0419692993164 ' '38.9933585922412))' ) self.assertEqual(this_field.default, this_field.data) self.assertEqual(this_field.default, this_field.object_data) self.assertEqual(this_field.type, 'StringField') self.assertEqual(type(this_field.validators[0]), InputRequired) self.assertEqual(this_field.render_kw, {'required': True}) self.assertEqual( this_field.label.__str__(), '<label for="getmaptiles_roi__roi_0">Polygon WKT</label>' ) this_field = form._fields['getmaptiles_roi__zoom_0'] self.assertTrue('getmaptiles_roi__zoom_0' in form._fields) self.assertEqual(type(this_field), wtfields.IntegerField) self.assertEqual(type(this_field.widget), wtwidgets.html5.NumberInput) self.assertEqual(this_field.description, '') self.assertEqual(this_field.short_name, 'getmaptiles_roi__zoom_0') self.assertEqual(this_field.id, 'getmaptiles_roi__zoom_0') self.assertEqual(this_field.name, 'getmaptiles_roi__zoom_0') self.assertEqual(this_field.default, 14) self.assertEqual(this_field.default, this_field.data) self.assertEqual(this_field.default, this_field.object_data) self.assertEqual(this_field.type, 'IntegerField') self.assertEqual(type(this_field.validators[0]), InputRequired) self.assertEqual(this_field.render_kw, {'required': True}) self.assertEqual( this_field.label.__str__(), '<label for="getmaptiles_roi__zoom_0">Zoom level</label>' ) this_field = form._fields['api_key'] self.assertTrue('api_key' in form._fields) self.assertEqual(type(this_field), wtfields.StringField) self.assertEqual(type(this_field.widget), wtwidgets.TextInput) self.assertEqual(this_field.description, '') self.assertEqual(this_field.short_name, 'api_key') self.assertEqual(this_field.id, 'api_key') self.assertEqual(this_field.name, 'api_key') self.assertEqual(this_field.default, None) self.assertEqual(this_field.default, this_field.data) self.assertEqual(this_field.default, this_field.object_data) self.assertEqual(this_field.type, 'StringField') self.assertEqual(type(this_field.validators[0]), InputRequired) self.assertEqual(this_field.render_kw, None) self.assertEqual( this_field.label.__str__(), '<label for="api_key">API Key</label>' ) self.assertFalse(self.get_context_variable('fetching_results')) def test_test_run_optional_parameter(self): print('test_run endpoint should display optional parameters') # add an optional parameter o_param = { "default_value": "", "field_type": "text", "display_name": "Useless Parameter", "name": "useless", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything", "custom_validation": None, "description": "A completely useless parameter.", } json_file = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'algorithm.json') with open(json_file, 'r') as alg_file: roi = json.load(alg_file) with open(json_file, 'w') as alg_file: roi['optional_parameters'].append(o_param) alg_file.write(json.dumps(roi)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) this_field = form._fields['getmaptiles_roi__useless_0'] self.assertEqual(type(this_field), wtfields.StringField) self.assertEqual(type(this_field.widget), wtwidgets.core.TextInput) self.assertEqual(this_field.description, '') self.assertEqual(this_field.short_name, 'getmaptiles_roi__useless_0') self.assertEqual(this_field.id, 'getmaptiles_roi__useless_0') self.assertEqual(this_field.name, 'getmaptiles_roi__useless_0') self.assertEqual(this_field.default, '') self.assertEqual(this_field.default, this_field.data) self.assertEqual(this_field.default, this_field.object_data) self.assertEqual(this_field.type, 'StringField') self.assertEqual(type(this_field.validators[0]), Optional) self.assertEqual(this_field.render_kw, {}) self.assertEqual( this_field.label.__str__(), '<label for="getmaptiles_roi__useless_0">Useless Parameter</label>' ) # add optional parameter to stitch_tiles json_file = os.path.join( test_alg_path, 'algorithms', 'stitch_tiles', 'algorithm.json') chains_file = os.path.join(test_alg_path, 'chains.json') with open(json_file, 'r') as alg_file: stitch_tiles = json.load(alg_file) with open(json_file, 'w') as alg_file: stitch_tiles['optional_parameters'].append(o_param) alg_file.write(json.dumps(stitch_tiles)) # if you don't specify a source, assume it's user input response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) self.assertTrue('stitch_tiles__useless_1' in form._fields) # add param to chains.json chain_def = get_chains() chain_def['map_tiles'][1]['parameters']['useless'] = { "source": "chain_ledger", "source_algorithm": "getmaptiles_roi", "key": "image_chips_dir", "occurrence": "first" } with open(chains_file, 'w') as c_file: c_file.write(json.dumps(chain_def)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) self.assertFalse('stitch_tiles__useless_1' in form._fields) # execute chain with additional parameter data = { 'api_key': 'testkey', 'getmaptiles_roi__roi_0': 'POLYGON((-77.0419692993164 38.9933585922412,' '-77.17311859130861 38.891887936025896,' '-77.03853607177736 38.790272111428706,' '-76.91013336181642 38.891887936025896,' '-77.0419692993164 38.9933585922412))', 'getmaptiles_roi__zoom_0': 14, 'getmaptiles_roi__cache_path_0': '/tmp/tiles/map_tiles', 'getmaptiles_roi__useless_0': 'crunchyfrog' } test_run_chain = get_test_run_chain() test_run_chain['algorithms'][0]['parameters']['useless'] = ( 'crunchyfrog') response = self.client.post('/test_run/map_tiles/', data=data) page = response.data self.assert200(response) self.assertTrue(self.get_context_variable('fetching_results')) self.assertTrue(json.dumps(test_run_chain), page) self.assertContext('chain', test_run_chain) # remove default value from parameter, make it an int # field and set min and max values del o_param['default_value'] o_param['field_type'] = 'number' o_param['data_type'] = 'integer' o_param['min_value'] = 1 o_param['max_value'] = 100 o_param['name'] = 'useless2' o_param['display_name'] = 'Useless Parameter #2' json_file = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'algorithm.json') with open(json_file, 'w') as alg_file: roi['optional_parameters'][0] = o_param alg_file.write(json.dumps(roi)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) this_field = form._fields['getmaptiles_roi__useless2_0'] self.assertEqual(this_field.default, None) self.assertEqual(this_field.widget.min, 1) self.assertEqual(this_field.widget.max, 100) # make it a float roi['optional_parameters'][0]['data_type'] = 'float' with open(json_file, 'w') as alg_file: alg_file.write(json.dumps(roi)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) this_field = form._fields['getmaptiles_roi__useless2_0'] self.assertEqual(this_field.default, None) self.assertEqual(this_field.widget.step, 'any') # remove min value from parameter del roi['optional_parameters'][0]['min_value'] with open(json_file, 'w') as alg_file: alg_file.write(json.dumps(roi)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) this_field = form._fields['getmaptiles_roi__useless2_0'] self.assertEqual(this_field.widget.min, None) # remove max value from parameter del roi['optional_parameters'][0]['max_value'] with open(json_file, 'w') as alg_file: alg_file.write(json.dumps(roi)) response = self.client.get('/test_run/map_tiles/') form = self.get_context_variable('form') self.assert200(response) this_field = form._fields['getmaptiles_roi__useless2_0'] self.assertEqual(this_field.widget.max, None) def test_test_run_submit(self): print('test_run should execute a chain') data = { 'api_key': 'testkey', 'getmaptiles_roi__roi_0': 'POLYGON((-77.0419692993164 38.9933585922412,' '-77.17311859130861 38.891887936025896,' '-77.03853607177736 38.790272111428706,' '-76.91013336181642 38.891887936025896,' '-77.0419692993164 38.9933585922412))', 'getmaptiles_roi__zoom_0': 14 } test_run_chain = get_test_run_chain() response = self.client.post('/test_run/map_tiles/', data=data) page = response.data self.assert200(response) self.assertTrue(self.get_context_variable('fetching_results')) self.assertTrue(json.dumps(test_run_chain), page) self.assertContext('chain', json.loads(json.dumps(test_run_chain))) class ATKTestCaseWithDocs(TestCase): def create_app(self): from algorithm_toolkit import app return app def setUp(self): sys.path.append(test_alg_path) subprocess.call(['alg', 'cp', 'test_project', '-q', '-wd']) def tearDown(self): # pass shutil.rmtree(test_alg_path) def test_atk_home(self): print('Home page should display with docs link') response = self.client.get('/') self.assert200(response) self.assertContext('docs', True) def test_show_docs(self): print('User should be able to see ATK documentation') response = self.client.get('/docs/index.html') self.assert200(response) class ATKTestCaseTestAlgorithm(TestCase): test_alg = {} r_param = {} p_submit = {} def create_app(self): from algorithm_toolkit import app return app def setUp(self): self.test_alg = get_algorithms()[0] self.r_param = { "default_value": '', "field_type": "test", "display_name": "Test parameter", "name": "test", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 99, "parameter_choices": [], "help_text": "Some help text", "custom_validation": None, "description": "A test parameter" } self.p_submit = { "zoom": 14, "roi": "POLYGON((-77.0419692993164 38.99335" "85922412,-77.17311859130861 38.891887936025896," "-77.03853607177736 38.790272111428706,-76.91013336" "181642 38.891887936025896,-77.0419692993164 " "38.9933585922412))", "test": "dinsdale", } def tearDown(self): pass def checkit(self, p, d): from algorithm_toolkit import Algorithm algorithm = Algorithm(test_alg_path, p) valid = algorithm.check_params(d) response = { 'errors': algorithm.errors, 'valid': valid } return response def test_bad_float(self): print('Algorithm should catch malformed floats') self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'float' self.test_alg['required_parameters'].append(self.r_param) response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Not a valid float'}] ) self.p_submit['test'] = 19.3 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_bad_array(self): print('Algorithm should catch malformed arrays') self.r_param['field_type'] = 'text' self.r_param['data_type'] = 'array' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 19.3 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Not a valid array'}] ) self.p_submit['test'] = [0, 1, 2, 3] response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) self.p_submit['test'] = '0, 1, 2, 3' response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) self.p_submit['test'] = '[0, 1, 2, 3]' response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_no_min_max(self): print('Algorithm should allow missing min or max values') self.r_param['data_type'] = 'integer' self.r_param['field_type'] = 'number' del self.r_param['min_value'] del self.r_param['max_value'] self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 42 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_gt(self): print( 'Algorithm should catch custom "greaterthan" validation errors' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'integer' self.r_param['custom_validation'] = 'greaterthan.zoom' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 13 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be greater than 14'}] ) self.p_submit['test'] = 14 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be greater than 14'}] ) self.p_submit['test'] = 19 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_gt_float(self): print( 'Algorithm should catch custom "greaterthan" ' 'validation errors with floats' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'float' self.r_param['custom_validation'] = 'greaterthan.zoom' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 13.1 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be greater than 14.0'}] ) self.p_submit['test'] = 14.0 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be greater than 14.0'}] ) self.p_submit['test'] = 19.7 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_lt(self): print( 'Algorithm should catch custom "lessthan" validation errors' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'integer' self.r_param['custom_validation'] = 'lessthan.zoom' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 19 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be less than 14'}] ) self.p_submit['test'] = 14 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be less than 14'}] ) self.p_submit['test'] = 13 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_even(self): print( 'Algorithm should catch custom "evenonly" validation errors' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'integer' self.r_param['custom_validation'] = 'evenonly' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 19 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be an even number'}] ) self.p_submit['test'] = 14 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_odd(self): print( 'Algorithm should catch custom "oddonly" validation errors' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'integer' self.r_param['custom_validation'] = 'oddonly' self.test_alg['required_parameters'].append(self.r_param) self.p_submit['test'] = 18 response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [{'parameter': 'test', 'error': 'Value must be an odd number'}] ) self.p_submit['test'] = 13 response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_re(self): print( 'Algorithm should catch custom regular ' 'expression validation errors' ) self.r_param['custom_validation'] = '^[0-9][0-9]' self.test_alg['required_parameters'].append(self.r_param) response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [ { 'parameter': 'test', 'error': 'Value does not match expression: "^[0-9][0-9]"' } ] ) self.p_submit['test'] = '1' response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [ { 'parameter': 'test', 'error': 'Value does not match expression: "^[0-9][0-9]"' } ] ) self.p_submit['test'] = '13' response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_custom_no_custom(self): print( 'Algorithm should proceed if "custom_validation" is missing' ) self.r_param['field_type'] = 'number' self.r_param['data_type'] = 'integer' del self.r_param['custom_validation'] self.p_submit['test'] = 13 self.test_alg['required_parameters'].append(self.r_param) response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_no_choices(self): print( 'Algorithm should proceed if "parameter_choices" is missing' ) del self.r_param['parameter_choices'] self.test_alg['required_parameters'].append(self.r_param) response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) def test_value_in_list(self): print( 'Algorithm should catch "value in list" validation errors' ) self.r_param['parameter_choices'] = ['thing1', 'thing2'] self.test_alg['required_parameters'].append(self.r_param) response = self.checkit(self.p_submit, self.test_alg) self.assertFalse(response['valid']) self.assertEqual( response['errors'], [ { 'parameter': 'test', 'error': "Value not in list of valid choices: " "['thing1', 'thing2']" } ] ) self.p_submit['test'] = 'thing1' response = self.checkit(self.p_submit, self.test_alg) self.assertTrue(response['valid']) self.assertEqual(response['errors'], []) class ATKTestCaseTestAlgorithmChain(TestCase): chain_name = 'map_tiles' test_chain = {} ac = None cl = None alg_data = {} def create_app(self): from algorithm_toolkit import app return app def setUp(self): from algorithm_toolkit import AlgorithmChain self.test_chain = get_chains()['map_tiles'] self.ac = AlgorithmChain(test_alg_path, get_test_run_chain()) self.cl = self.ac.ChainLedger('tim') self.alg_data = { "zoom": 14, "roi": "POLYGON((-77.0419692993164 38.99335" "85922412,-77.17311859130861 38.891887936025896," "-77.03853607177736 38.790272111428706,-76.91013336" "181642 38.891887936025896,-77.0419692993164 " "38.9933585922412))" } def tearDown(self): try: shutil.rmtree(test_alg_path) except OSError: pass def test_add_to_metadata(self): print( 'A developer should be able to add a ' 'key-value pair to the chain ledger' ) self.cl.add_to_metadata('hedgehog', 'Spiny Norman') self.assertTrue('hedgehog' in self.cl.metadata) def test_get_from_metadata(self): print( 'A developer should be able to retrieve a ' 'key-value pair from the chain ledger' ) self.cl.add_to_metadata('hedgehog', 'Spiny Norman') m_key = self.cl.get_from_metadata('hedgehog') self.assertEqual(m_key, 'Spiny Norman') def test_archive_metadata(self): print('Test archiving ledger metadata') self.cl.archive_metadata('getmaptiles_roi', self.alg_data) history = self.cl.history self.assertEqual(history[0]['algorithm_name'], 'getmaptiles_roi') self.assertEqual(history[0]['algorithm_params'], self.alg_data) def test_clear_current_metadata(self): print('Test clearing ledger metadata') self.cl.metadata = self.alg_data self.assertEqual(self.cl.metadata, self.alg_data) self.cl.archive_metadata('getmaptiles_roi', self.alg_data) self.cl.clear_current_metadata() self.assertEqual(self.cl.metadata, {}) def test_get_history_size(self): print('Test retrieving size of chain ledger metadata history') self.cl.archive_metadata('getmaptiles_roi', self.alg_data) self.cl.clear_current_metadata() self.cl.add_to_metadata('hedgehog', 'Spiny Norman') history = self.cl.history self.assertEqual(len(history), 1) self.assertEqual(self.cl.get_history_size(), 1) self.cl.archive_metadata( 'piranha_brothers', {'hedgehog': 'Spiny Norman'}) self.assertEqual(self.cl.get_history_size(), 2) def test_get_from_history(self): print('Test retrieving from chain ledger metadata history') self.cl.archive_metadata('getmaptiles_roi', self.alg_data) alg_name = self.cl.get_from_history(0, 'algorithm_name') alg_params = self.cl.get_from_history(0, 'algorithm_params') self.assertEqual(alg_name, 'getmaptiles_roi') self.assertEqual(alg_params, self.alg_data) def test_search_history(self): print('Test searching chain ledger metadata history') self.cl.metadata = self.alg_data self.cl.archive_metadata('getmaptiles_roi', self.alg_data) h_list = self.cl.search_history('zoom', 'getmaptiles_roi') self.assertEqual(h_list, [14]) h_list = self.cl.search_history('thingie', 'getmaptiles_roi') self.assertEqual(h_list, [None]) def test_chain_ledger_status(self): print('Test setting chain ledger status') msg1 = 'I... am an enchanter.' msg2 = "There are some who call me... 'Tim'?" self.cl.set_status(msg1) self.cl.set_status(msg2) latest_msg = self.app.config['tim']['latest_msg'].__str__() all_msg = self.app.config['tim']['all_msg'].__str__() self.assertEqual(latest_msg, msg2.replace("'", "&#39;")) self.assertEqual( all_msg, msg1 + ' \n' + msg2.replace("'", "&#39;") ) def test_params_to_json(self): print('Test creating a JSON object from chain ledger history') self.cl.archive_metadata('getmaptiles_roi', self.alg_data) self.cl.clear_current_metadata() self.cl.archive_metadata( 'piranha_brothers', {'hedgehog': 'Spiny Norman'}) self.cl.clear_current_metadata() json_obj = self.cl.params_to_json() test_obj_list = [ { 'algorithm_name': 'getmaptiles_roi', 'algorithm_params': self.alg_data }, { 'algorithm_name': 'piranha_brothers', 'algorithm_params': {'hedgehog': 'Spiny Norman'} } ] test_obj = { 'atk_chain_metadata': test_obj_list } self.assertEqual(json_obj, test_obj) def test_params_to_json_not_json(self): print('AlgorithmChain should catch non JSON-serializable objects') class TestClass(): pass self.cl.archive_metadata('getmaptiles_roi', self.alg_data) self.cl.clear_current_metadata() self.cl.archive_metadata( 'piranha_brothers', {'hedgehog': TestClass()}) self.cl.clear_current_metadata() json_obj = self.cl.params_to_json() test_obj_list = [ { 'algorithm_name': 'getmaptiles_roi', 'algorithm_params': self.alg_data }, { 'algorithm_name': 'piranha_brothers', 'algorithm_params': {'hedgehog': 'Value not JSON serializable'} } ] test_obj = { 'atk_chain_metadata': test_obj_list } self.assertEqual(json_obj, test_obj) def test_params_to_json_save_to_file(self): print( 'Test creating a JSON object from chain ' 'ledger history and saving to file' ) tmp_path = '/tmp/testtest.json' self.cl.archive_metadata('getmaptiles_roi', self.alg_data) self.cl.clear_current_metadata() self.cl.archive_metadata( 'piranha_brothers', {'hedgehog': 'Spiny Norman'}) self.cl.clear_current_metadata() self.cl.save_params_to_json(tmp_path) test_obj_list = [ { 'algorithm_name': 'getmaptiles_roi', 'algorithm_params': self.alg_data }, { 'algorithm_name': 'piranha_brothers', 'algorithm_params': {'hedgehog': 'Spiny Norman'} } ] test_obj = { 'atk_chain_metadata': test_obj_list } with open(tmp_path, 'r') as json_file: json_obj = json_file.read() self.assertEqual(json_obj, json.dumps(test_obj)) self.cl.save_params_to_json(tmp_path, pretty=True) with open(tmp_path, 'r') as json_file: json_obj = json_file.read() self.assertEqual( json_obj, json.dumps(test_obj, separators=(',', ': '), indent=4) ) def test_get_request_dict(self): print( 'Test returning a dictionary containing ' 'chain parameters with defaults' ) sys.path.append(test_alg_path) subprocess.call(['alg', 'cp', 'test_project', '-e', '-q']) from algorithm_toolkit import AlgorithmChain self.ac = AlgorithmChain(test_alg_path, get_test_run_chain()) self.cl = self.ac.ChainLedger('tim') check_dict = { 'chain_name': 'map_tiles', 'algorithms': [ { 'parameters': self.alg_data, 'algorithm': 'getmaptiles_roi' }, { 'parameters': { 'image_filenames': None }, 'algorithm': 'stitch_tiles' }, { 'parameters': { 'image_bounds': None, 'image_path': None }, 'algorithm': 'output_image_to_client' } ] } test_dict = self.ac.get_request_dict() self.assertEqual(check_dict, test_dict) # add an optional parameter o_param = { "default_value": "", "field_type": "text", "display_name": "Useless Parameter", "name": "useless", "data_type": "string", "max_value": None, "min_value": None, "sort_order": 2, "parameter_choices": [], "help_text": "Don't bother entering anything", "custom_validation": None, "description": "A completely useless parameter.", } json_file = os.path.join( test_alg_path, 'algorithms', 'getmaptiles_roi', 'algorithm.json') with open(json_file, 'r') as alg_file: roi = json.load(alg_file) with open(json_file, 'w') as alg_file: roi['optional_parameters'].append(o_param) alg_file.write(json.dumps(roi)) check_dict['algorithms'][0]['parameters']['useless'] = '' test_dict = self.ac.get_request_dict() self.assertEqual(check_dict, test_dict) # remove default value del o_param['default_value'] with open(json_file, 'w') as alg_file: roi['optional_parameters'].append(o_param) alg_file.write(json.dumps(roi)) check_dict['algorithms'][0]['parameters']['useless'] = None test_dict = self.ac.get_request_dict() self.assertEqual(check_dict, test_dict) # remove default value from required param del roi['required_parameters'][0]['default_value'] with open(json_file, 'w') as alg_file: alg_file.write(json.dumps(roi)) check_dict['algorithms'][0]['parameters']['roi'] = None test_dict = self.ac.get_request_dict() self.assertEqual(check_dict, test_dict) class ATKTestCaseFileUtils(TestCase): def create_app(self): from algorithm_toolkit import app return app def setUp(self): pass def tearDown(self): pass def test_make_dir_if_not_exists(self): from algorithm_toolkit import utils print('Ensure we can create multiple folders if needed') test_dir = 'test_project/algorithms' utils.file_utils.make_dir_if_not_exists(test_dir) self.assertTrue(os.path.exists(test_dir)) # don't recreate if path exists utils.file_utils.make_dir_if_not_exists(test_dir) self.assertTrue(os.path.exists(test_dir)) shutil.rmtree(test_alg_path) self.assertFalse(os.path.exists(test_dir)) def test_get_algorithms_valueerror(self): from algorithm_toolkit import utils print( 'Ensure ValueError conditions are handled when ' 'getting an algorithm definition' ) with open('testalgorithm.json', 'w') as json_file: json_file.write('{[1, 2 , 3]: "splunge"}') response = utils.file_utils.get_algorithm('testalgorithm.json') self.assertEqual(response, {}) os.remove('testalgorithm.json') def test_get_chain_def_valueerror(self): from algorithm_toolkit import utils print( 'Ensure ValueError conditions are handled when ' 'getting a chain definition' ) os.makedirs(test_alg_path) chain_path = os.path.join(test_alg_path, 'chains.json') with open(chain_path, 'w') as json_file: json_file.write('{[1, 2 , 3]: "splunge"}') response = utils.file_utils.get_chain_def(test_alg_path) self.assertEqual(response, {}) shutil.rmtree(test_alg_path) def test_get_chain_def_ioerror(self): from algorithm_toolkit import utils print( 'Ensure IOError conditions are handled when ' 'getting a chain definition' ) response = utils.file_utils.get_chain_def(test_alg_path) self.assertEqual(response, {}) class ATKTestCaseDataUtils(TestCase): def create_app(self): from algorithm_toolkit import app return app def setUp(self): pass def tearDown(self): pass def test_text2int_not_in_mapping(self): from algorithm_toolkit import utils print('Return -1 if text is not found in word_to_number_mapping') response = utils.data_utils.text2int('deadparrot') self.assertEqual(response, -1) def test_create_random_string_all_chars(self): from algorithm_toolkit import utils print( 'If desired, random string can include symbols ' '(i.e.: not just http-safe characters)' ) symbols = '`~!@#$%*()-_=+[]{}|;:,./?' for x in range(100): response = utils.data_utils.create_random_string(http_safe=False) # TODO: rewrite this test # self.assertTrue(any(s for s in symbols if s in response)) for x in range(100): response = utils.data_utils.create_random_string(http_safe=True) self.assertFalse(any(s for s in symbols if s in response)) class ATKTestCaseDecorators(TestCase): def create_app(self): from algorithm_toolkit import app return app def setUp(self): self.app.config['TESTING'] = False def tearDown(self): self.app.config['TESTING'] = True self.app.config['DEBUG'] = True def test_not_debug(self): print( 'debug-only views should be blocked if ' 'not in debug or testing mode' ) self.app.config['DEBUG'] = False response = self.client.get('/') self.assert400(response) self.assertEqual(response.data, 'This view is not accessible') if __name__ == '__main__': unittest.main()
38.368936
79
0.598257
10,194
90,167
5.071218
0.060624
0.059773
0.034123
0.025186
0.816698
0.768899
0.736072
0.706186
0.674056
0.649509
0
0.023666
0.283463
90,167
2,349
80
38.38527
0.776483
0.026451
0
0.610254
0
0
0.246229
0.043741
0
0
0
0.000426
0.197113
1
0.047287
false
0.003484
0.015928
0
0.076157
0.035839
0
0
0
null
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
f38c106cc17e94aaa22774b0a12f3e2216fd12f8
223
py
Python
elif_bayindir/phase_1/python_basic_1/day_8/q10.py
CodedLadiesInnovateTech/-python-challenge-solutions
430cd3eb84a2905a286819eef384ee484d8eb9e7
[ "MIT" ]
6
2020-05-23T19:53:25.000Z
2021-05-08T20:21:30.000Z
elif_bayindir/phase_1/python_basic_1/day_8/q10.py
CodedLadiesInnovateTech/-python-challenge-solutions
430cd3eb84a2905a286819eef384ee484d8eb9e7
[ "MIT" ]
8
2020-05-14T18:53:12.000Z
2020-07-03T00:06:20.000Z
elif_bayindir/phase_1/python_basic_1/day_8/q10.py
CodedLadiesInnovateTech/-python-challenge-solutions
430cd3eb84a2905a286819eef384ee484d8eb9e7
[ "MIT" ]
39
2020-05-10T20:55:02.000Z
2020-09-12T17:40:59.000Z
# Question 10 # Sort files by date import os import time from pprint import pprint pprint([(x[0], time.ctime(x[1].st_ctime)) for x in sorted([(fn, os.stat(fn)) for fn in os.listdir(".")], key = lambda x: x[1].st_ctime)])
24.777778
137
0.672646
43
223
3.44186
0.55814
0.027027
0.054054
0.121622
0
0
0
0
0
0
0
0.026455
0.152466
223
8
138
27.875
0.756614
0.134529
0
0
0
0
0.005263
0
0
0
0
0
0
1
0
true
0
0.75
0
0.75
0.5
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
1
0
5
f39dd6127b925fced9de3ed35ce8f00f12f55551
1,631
py
Python
kw_sorter/interfaces.py
alex-kalanis/sorter
d6349c3eac16ebaa039d9b558ba85fdf33074074
[ "BSD-3-Clause" ]
null
null
null
kw_sorter/interfaces.py
alex-kalanis/sorter
d6349c3eac16ebaa039d9b558ba85fdf33074074
[ "BSD-3-Clause" ]
null
null
null
kw_sorter/interfaces.py
alex-kalanis/sorter
d6349c3eac16ebaa039d9b558ba85fdf33074074
[ "BSD-3-Clause" ]
null
null
null
class ISortEntry: """ * Basic necessity to sort anything """ DIRECTION_ASC = 'ASC' DIRECTION_DESC = 'DESC' def set_key(self, key: str): """ * Set by which key the entry will be sorted """ raise NotImplementedError('TBA') def get_key(self) -> str: """ * Sort by which key """ raise NotImplementedError('TBA') def set_direction(self, direction: str): """ * Set direction of sort * Preferably use constants above """ raise NotImplementedError('TBA') def get_direction(self) -> str: """ * Sorting direction * Preferably use constants above """ raise NotImplementedError('TBA') class ISorter: """ * Basic interface * Make your app dependent on this interface """ def get_entries(self): """ * Get entries in sorting """ raise NotImplementedError('TBA') def add(self, entry: ISortEntry): """ * Add single entry from input which will be used for sorting """ raise NotImplementedError('TBA') def remove(self, entry_key: str): """ * Remove all entries containing that key """ raise NotImplementedError('TBA') def clear(self): """ * Clear sorting entries, be ready for another set """ raise NotImplementedError('TBA') def get_default_item(self) -> ISortEntry: """ * Return new entry usable for sorting """ raise NotImplementedError('TBA')
22.652778
69
0.545677
159
1,631
5.534591
0.377358
0.245455
0.276136
0.238636
0.409091
0.122727
0.122727
0
0
0
0
0
0.352544
1,631
71
70
22.971831
0.833333
0.297364
0
0.409091
0
0
0.038946
0
0
0
0
0
0
1
0.409091
false
0
0
0
0.590909
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
0
1
0
0
5
45fd1d73b6a04f0f3a7ca674ade4ce18ec945084
3,652
py
Python
zotapaysdk/tests/local/test_client_configuration.py
zotapay/python-sdk
8d8a426679263222a3f805bbb56ebb3087b17c2c
[ "Apache-2.0" ]
null
null
null
zotapaysdk/tests/local/test_client_configuration.py
zotapay/python-sdk
8d8a426679263222a3f805bbb56ebb3087b17c2c
[ "Apache-2.0" ]
null
null
null
zotapaysdk/tests/local/test_client_configuration.py
zotapay/python-sdk
8d8a426679263222a3f805bbb56ebb3087b17c2c
[ "Apache-2.0" ]
null
null
null
import pytest from zotapaysdk.client import MGClient from zotapaysdk.config import CredentialsKeys, MGCredentialsManager from zotapaysdk.exceptions import MGMissingCredentialsException def test_client_environment_configuration_fail_request_url(monkeypatch): """ Checks if env var test fails for missing request url Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.ENDPOINT_ID, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_SECRET_KEY, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_ID, "test") with pytest.raises(MGMissingCredentialsException): MGClient() def test_client_environment_configuration_fail_endpoint_id(monkeypatch): """ Checks if env var test fails for missing endpoint_id Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.REQUEST_URL, "www.test.com") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_SECRET_KEY, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_ID, "test") with pytest.raises(MGMissingCredentialsException): MGClient() def test_client_environment_configuration_fail_merchant_secret_key(monkeypatch): """ Checks if env var test fails for missing merchant secret key Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.REQUEST_URL, "www.test.com") monkeypatch.setenv(CredentialsKeys.Env.ENDPOINT_ID, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_ID, "test") with pytest.raises(MGMissingCredentialsException): MGClient() def test_client_environment_configuration_fail_merchant_id(monkeypatch): """ Checks if env var test fails for missing merchant id Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.REQUEST_URL, "www.test.com") monkeypatch.setenv(CredentialsKeys.Env.ENDPOINT_ID, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_SECRET_KEY, "test") with pytest.raises(MGMissingCredentialsException): MGClient() def test_client_environment_configuration_ok(monkeypatch): """ Asserts MGClient instance is created ok with proper credentials Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.REQUEST_URL, "www.test.com") monkeypatch.setenv(CredentialsKeys.Env.ENDPOINT_ID, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_SECRET_KEY, "test") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_ID, "test") MGClient() def test_client_environment_configuration_with_bad_creds(monkeypatch): """ Extra test for bad credentials. Args: monkeypatch: Returns: """ monkeypatch.setenv(CredentialsKeys.Env.REQUEST_URL, " ") monkeypatch.setenv(CredentialsKeys.Env.ENDPOINT_ID, " ") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_SECRET_KEY, " ") monkeypatch.setenv(CredentialsKeys.Env.MERCHANT_ID, " ") with pytest.raises(MGMissingCredentialsException): MGClient() def test_credentials_manager(): with pytest.raises(MGMissingCredentialsException): MGCredentialsManager(merchant_id="a", merchant_secret_key="a", endpoint_id="a", request_url="a") with pytest.raises(MGMissingCredentialsException): MGCredentialsManager(merchant_id="teststestse", merchant_secret_key="testets", endpoint_id="testests") with pytest.raises(MGMissingCredentialsException): MGCredentialsManager(merchant_id="testsetes", merchant_secret_key="testestes", request_url="testsetes")
31.482759
111
0.737404
371
3,652
7.053908
0.148248
0.12992
0.244555
0.267482
0.816202
0.816202
0.748949
0.611769
0.611769
0.594956
0
0
0.170865
3,652
115
112
31.756522
0.864267
0.140471
0
0.6
0
0
0.052862
0
0
0
0
0
0
1
0.14
false
0
0.08
0
0.22
0
0
0
0
null
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
34097bf03a9e6f511e570fde14ccc907538f2773
224
py
Python
c3d/demo_load_file.py
johndpope/FacialRetargeting
5fb0c1da6af6c3d59aef264f567bfa7a244d0764
[ "MIT" ]
21
2020-08-19T02:52:16.000Z
2022-02-25T12:35:04.000Z
c3d/demo_load_file.py
johndpope/FacialRetargeting
5fb0c1da6af6c3d59aef264f567bfa7a244d0764
[ "MIT" ]
3
2020-10-16T07:11:25.000Z
2021-06-30T10:26:04.000Z
c3d/demo_load_file.py
johndpope/FacialRetargeting
5fb0c1da6af6c3d59aef264f567bfa7a244d0764
[ "MIT" ]
7
2020-08-24T08:30:53.000Z
2022-03-28T15:55:24.000Z
from pyc3d import pyC3D from maya import cmds if __name__ == '__main__': c3dFile = pyC3D.C3DReader('C:\Users\David\Documents\Viccon_david\FacialExpressionsTracking\Test\NewSession_labeled\m_test.c3d', normalize=True)
28
147
0.794643
29
224
5.758621
0.793103
0
0
0
0
0
0
0
0
0
0
0.029851
0.102679
224
7
148
32
0.800995
0
0
0
0
0
0.477477
0.441441
0
0
0
0
0
0
null
null
0
0.5
null
null
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
null
0
0
0
0
1
0
0
0
1
0
0
0
0
5
340aae16602bc8cf9891372e068ff495ad234aa3
135
py
Python
__init__.py
at86/cefpython3wx
f1a07f7e071360b39d7baccb201c2e6a582c4cf0
[ "BSD-3-Clause" ]
1
2019-10-02T21:22:44.000Z
2019-10-02T21:22:44.000Z
__init__.py
at86/cefpython3wx
f1a07f7e071360b39d7baccb201c2e6a582c4cf0
[ "BSD-3-Clause" ]
null
null
null
__init__.py
at86/cefpython3wx
f1a07f7e071360b39d7baccb201c2e6a582c4cf0
[ "BSD-3-Clause" ]
null
null
null
# This dummy file is overwritten by "__init__.py.template", see: # cefpython/cef3/windows/installer/ # cefpython/cef3/linux/installer/
33.75
64
0.777778
18
135
5.611111
0.833333
0.257426
0
0
0
0
0
0
0
0
0
0.016393
0.096296
135
3
65
45
0.811475
0.948148
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
cab9d915121b29376b5abbd35405538d28ece776
37
py
Python
tests/__init__.py
kevihiiin/kpm-api
65d14fa380b45dc9237a7f4460c8c3db9ba2be93
[ "MIT" ]
null
null
null
tests/__init__.py
kevihiiin/kpm-api
65d14fa380b45dc9237a7f4460c8c3db9ba2be93
[ "MIT" ]
null
null
null
tests/__init__.py
kevihiiin/kpm-api
65d14fa380b45dc9237a7f4460c8c3db9ba2be93
[ "MIT" ]
null
null
null
"""Unit test package for kpm_api."""
18.5
36
0.675676
6
37
4
1
0
0
0
0
0
0
0
0
0
0
0
0.135135
37
1
37
37
0.75
0.810811
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
cad8038feab53f82622c91e3b95c2accd4213bf1
160
py
Python
eogrow/core/area/__init__.py
sentinel-hub/eo-grow
458202fc55c01cc95a17b442144ef2c935103c80
[ "MIT" ]
17
2022-01-27T11:50:23.000Z
2022-02-12T10:01:03.000Z
eogrow/core/area/__init__.py
sentinel-hub/eo-grow
458202fc55c01cc95a17b442144ef2c935103c80
[ "MIT" ]
5
2022-02-10T11:15:09.000Z
2022-02-28T10:46:47.000Z
eogrow/core/area/__init__.py
sentinel-hub/eo-grow
458202fc55c01cc95a17b442144ef2c935103c80
[ "MIT" ]
null
null
null
""" A subfolder for area management """ from .batch import BatchAreaManager from .custom_grid import CustomGridAreaManager from .utm import UtmZoneAreaManager
20
46
0.81875
18
160
7.222222
0.777778
0
0
0
0
0
0
0
0
0
0
0
0.125
160
7
47
22.857143
0.928571
0.19375
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
1b07584e42f0918265ba1e5d736e2b85c1ece379
85
py
Python
server/imageProcessor/common/__init__.py
perryjiang/similo
48866f5c619efb6a11130f59daa15456f2c1ee1a
[ "MIT" ]
null
null
null
server/imageProcessor/common/__init__.py
perryjiang/similo
48866f5c619efb6a11130f59daa15456f2c1ee1a
[ "MIT" ]
1
2021-03-31T18:51:37.000Z
2021-03-31T18:51:37.000Z
server/imageProcessor/common/__init__.py
vimmada/similo
48866f5c619efb6a11130f59daa15456f2c1ee1a
[ "MIT" ]
1
2018-08-01T23:57:33.000Z
2018-08-01T23:57:33.000Z
""" Common functions and constants across application """ from .util import Response
17
49
0.776471
10
85
6.6
1
0
0
0
0
0
0
0
0
0
0
0
0.141176
85
4
50
21.25
0.90411
0.576471
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
1b11f7bd01670ee36cfc5b95c3a1994cc652787e
83
py
Python
src/static/code_stubs/python/blood_types.py
basimr/lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
28
2019-01-06T11:39:13.000Z
2022-02-28T03:35:55.000Z
src/static/code_stubs/python/blood_types.py
basimr/project-lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
88
2017-04-01T15:18:36.000Z
2021-09-22T19:41:11.000Z
src/static/code_stubs/python/blood_types.py
basimr/project-lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
4
2019-08-11T14:51:16.000Z
2021-04-30T16:37:52.000Z
def survive(blood_type, donated_blood): # Your code goes here! return True
20.75
39
0.710843
12
83
4.75
0.916667
0
0
0
0
0
0
0
0
0
0
0
0.216867
83
3
40
27.666667
0.876923
0.240964
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
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
5
1b20533e6dda035be18d3fb03be028d43a6bee93
43
py
Python
recipes/fiji/hello.py
corneliusroemer/bioconda-recipes
e1eced9063e15f6a97ab2b8e42cf3e38af4c93ba
[ "MIT" ]
null
null
null
recipes/fiji/hello.py
corneliusroemer/bioconda-recipes
e1eced9063e15f6a97ab2b8e42cf3e38af4c93ba
[ "MIT" ]
null
null
null
recipes/fiji/hello.py
corneliusroemer/bioconda-recipes
e1eced9063e15f6a97ab2b8e42cf3e38af4c93ba
[ "MIT" ]
null
null
null
#!/usr/bin/env python print "Hello Bjoern"
14.333333
21
0.72093
7
43
4.428571
1
0
0
0
0
0
0
0
0
0
0
0
0.116279
43
2
22
21.5
0.815789
0.465116
0
0
0
0
0.545455
0
0
0
0
0
0
0
null
null
0
0
null
null
1
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
1
0
0
0
0
0
0
1
0
5
1b532bcaa012e2ea57788f1c801bd03a3be11828
76
py
Python
ftp2http/__init__.py
brn73/ftp2http
441530c02fb328b9b41247134f39194a9ab1a895
[ "MIT" ]
4
2015-08-13T08:41:59.000Z
2021-04-23T14:00:48.000Z
ftp2http/__init__.py
brn73/ftp2http
441530c02fb328b9b41247134f39194a9ab1a895
[ "MIT" ]
1
2015-08-30T22:53:37.000Z
2015-08-30T22:53:37.000Z
ftp2http/__init__.py
brn73/ftp2http
441530c02fb328b9b41247134f39194a9ab1a895
[ "MIT" ]
3
2016-08-01T23:16:43.000Z
2020-02-13T00:53:50.000Z
from . import * # noqa from .version import version as __version__ # noqa
25.333333
51
0.723684
10
76
5.1
0.5
0
0
0
0
0
0
0
0
0
0
0
0.210526
76
2
52
38
0.85
0.118421
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
1b604a63fd33c9f9a0eda23549de4fb3e911e1e5
314
py
Python
website/sharedgames/views.py
14gaby14/sharedgames
9102b1d6cb18f69383486e6db2e45141d0da5d2f
[ "Apache-2.0" ]
null
null
null
website/sharedgames/views.py
14gaby14/sharedgames
9102b1d6cb18f69383486e6db2e45141d0da5d2f
[ "Apache-2.0" ]
null
null
null
website/sharedgames/views.py
14gaby14/sharedgames
9102b1d6cb18f69383486e6db2e45141d0da5d2f
[ "Apache-2.0" ]
null
null
null
from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse("This should be the shared games index.") def detail(request, group_id): return HttpResponse("The code is %s." % group_id) def example(request): return HttpResponse("This is an example")
28.545455
65
0.754777
44
314
5.340909
0.568182
0.229787
0.212766
0.246809
0
0
0
0
0
0
0
0
0.156051
314
11
66
28.545455
0.886792
0
0
0
0
0
0.225397
0
0
0
0
0
0
1
0.375
false
0
0.25
0.375
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
0
0
0
5
1b9abafbad973d033641b205497922d24a496623
42
py
Python
telegramcleaner/errors.py
Abstract-X/telegram-cleaner
dc3ae6597722f7369e3b092652a705417a337b63
[ "MIT" ]
1
2022-03-16T08:34:32.000Z
2022-03-16T08:34:32.000Z
telegramcleaner/errors.py
Abstract-X/telegram-cleaner
dc3ae6597722f7369e3b092652a705417a337b63
[ "MIT" ]
1
2022-03-18T18:12:36.000Z
2022-03-18T18:12:36.000Z
telegramcleaner/errors.py
Abstract-X/telegram-cleaner
dc3ae6597722f7369e3b092652a705417a337b63
[ "MIT" ]
1
2022-03-16T09:36:58.000Z
2022-03-16T09:36:58.000Z
class ParsingError(Exception): pass
8.4
30
0.714286
4
42
7.5
1
0
0
0
0
0
0
0
0
0
0
0
0.214286
42
4
31
10.5
0.909091
0
0
0
0
0
0
0
0
0
0
0
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
0
0
0
0
1
1
0
0
0
0
0
5
1bb628e1c8a6d39dd3e698e77d7115a8eca72204
1,483
py
Python
general/erode_and_dilate.py
j-lazo/lumen_segmentation
442b6e642b4743e6b7bf56ab77e11e8e95062ed7
[ "CC0-1.0" ]
null
null
null
general/erode_and_dilate.py
j-lazo/lumen_segmentation
442b6e642b4743e6b7bf56ab77e11e8e95062ed7
[ "CC0-1.0" ]
null
null
null
general/erode_and_dilate.py
j-lazo/lumen_segmentation
442b6e642b4743e6b7bf56ab77e11e8e95062ed7
[ "CC0-1.0" ]
null
null
null
import os import numpy as np import cv2 def dilate(folder, output_folder, kernel_size=3): kernel = np.ones((kernel_size, kernel_size), np.uint8) img_list = sorted(os.listdir(folder)) if not(os.path.isdir(output_folder)): os.mkdir(output_folder) for j, image in enumerate(img_list[:]): print(j, image) img = cv2.imread(os.path.join(folder, image), 1) dilation = cv2.dilate(img, kernel, iterations=1) new_name = ''.join([output_folder, image]) cv2.imwrite(new_name, dilation) def erode(folder, output_folder, kernel_size=3): kernel = np.ones((kernel_size, kernel_size), np.uint8) img_list = sorted(os.listdir(folder)) if not(os.path.isdir(output_folder)): os.mkdir(output_folder) for j, image in enumerate(img_list[:]): print(j, image) img = cv2.imread(os.path.join(folder, image), 1) erosion = cv2.erode(img, kernel, iterations=1) new_name = ''.join([output_folder, image]) cv2.imwrite(new_name, erosion) def main(): path_directory = '/home/nearlab/Jorge/current_work/' \ 'lumen_segmentation/data/lumen_data/' \ 'test/test_02/label/' ouput_folder = '/home/nearlab/Jorge/current_work/' \ 'lumen_segmentation/data/' \ 'lumen_data/test/test_02/label_dilate_3/' dilate(path_directory, ouput_folder, kernel_size=3) if __name__ == "__main__": main()
28.519231
60
0.632502
198
1,483
4.510101
0.272727
0.107503
0.053751
0.057111
0.788354
0.788354
0.788354
0.788354
0.788354
0.788354
0
0.018502
0.234659
1,483
52
61
28.519231
0.768282
0
0
0.457143
0
0
0.128706
0.110512
0
0
0
0
0
1
0.085714
false
0
0.085714
0
0.171429
0.057143
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
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
1bb930321e027db025ca444dbdb0094865d71bed
115
py
Python
openforcefield/typing/chemistry/__init__.py
jaimergp/openforcefield
0e8bfd55730f585a5215ef3fb836f023c71ebfb0
[ "MIT" ]
1
2020-04-15T05:24:22.000Z
2020-04-15T05:24:22.000Z
openforcefield/typing/chemistry/__init__.py
jaimergp/openforcefield
0e8bfd55730f585a5215ef3fb836f023c71ebfb0
[ "MIT" ]
null
null
null
openforcefield/typing/chemistry/__init__.py
jaimergp/openforcefield
0e8bfd55730f585a5215ef3fb836f023c71ebfb0
[ "MIT" ]
1
2020-03-29T04:19:37.000Z
2020-03-29T04:19:37.000Z
# Tools dealing with chemical environments or chemistry from openforcefield.typing.chemistry.environment import *
28.75
57
0.843478
13
115
7.461538
0.923077
0
0
0
0
0
0
0
0
0
0
0
0.113043
115
3
58
38.333333
0.95098
0.46087
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
848c5f5566d980a9e8daacb6057d3cd0a2bd3e88
146
py
Python
docx_microreader/translators/html/marks.py
DudaEugen/docx_microreader
cc524ff5233b0c074786f2a5c378ea542607359a
[ "MIT" ]
null
null
null
docx_microreader/translators/html/marks.py
DudaEugen/docx_microreader
cc524ff5233b0c074786f2a5c378ea542607359a
[ "MIT" ]
null
null
null
docx_microreader/translators/html/marks.py
DudaEugen/docx_microreader
cc524ff5233b0c074786f2a5c378ea542607359a
[ "MIT" ]
null
null
null
from enum import Enum, unique, auto @unique class ParagraphMark(Enum): FIRST_ELEMENT_NUMBERING = auto() LAST_ELEMENT_NUMBERING = auto()
18.25
36
0.746575
18
146
5.833333
0.611111
0.304762
0.380952
0
0
0
0
0
0
0
0
0
0.171233
146
7
37
20.857143
0.867769
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.2
0
0.8
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
0
0
1
0
0
5
84a7c758d3de718046aafc38a92c589d0036fa24
1,000
py
Python
tests/kyu_7_tests/test_power_of_two.py
the-zebulan/CodeWars
1eafd1247d60955a5dfb63e4882e8ce86019f43a
[ "MIT" ]
40
2016-03-09T12:26:20.000Z
2022-03-23T08:44:51.000Z
tests/kyu_7_tests/test_power_of_two.py
akalynych/CodeWars
1eafd1247d60955a5dfb63e4882e8ce86019f43a
[ "MIT" ]
null
null
null
tests/kyu_7_tests/test_power_of_two.py
akalynych/CodeWars
1eafd1247d60955a5dfb63e4882e8ce86019f43a
[ "MIT" ]
36
2016-11-07T19:59:58.000Z
2022-03-31T11:18:27.000Z
import unittest from katas.kyu_7.power_of_two import power_of_two class PowerOfTwoTestCase(unittest.TestCase): def test_true(self): self.assertTrue(power_of_two(1)) def test_true_2(self): self.assertTrue(power_of_two(2)) def test_true_3(self): self.assertTrue(power_of_two(4096)) def test_true_4(self): self.assertTrue(power_of_two(33554432)) def test_true_5(self): self.assertTrue(power_of_two(8388608)) def test_true_6(self): self.assertTrue(power_of_two(16777216)) def test_true_7(self): self.assertTrue(power_of_two(8388608)) def test_true_8(self): self.assertTrue(power_of_two(4194304)) def test_false(self): self.assertFalse(power_of_two(5)) def test_false_2(self): self.assertFalse(power_of_two(4194305)) def test_false_3(self): self.assertFalse(power_of_two(16777217)) def test_false_4(self): self.assertFalse(power_of_two(16777215))
23.809524
49
0.696
147
1,000
4.387755
0.231293
0.151938
0.217054
0.285271
0.582946
0.582946
0.142636
0.142636
0.142636
0.142636
0
0.097744
0.202
1,000
41
50
24.390244
0.710526
0
0
0.074074
0
0
0
0
0
0
0
0
0.444444
1
0.444444
false
0
0.074074
0
0.555556
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
1
0
1
0
0
0
0
1
0
0
5
84c62c6d03db99b9540590a39b2cfc72168fada4
137
py
Python
archive/MCQ/utils/__init__.py
dreinq/DeepQ
abb6d8b492f802fefbc0095e8719377dc708069c
[ "Apache-2.0" ]
null
null
null
archive/MCQ/utils/__init__.py
dreinq/DeepQ
abb6d8b492f802fefbc0095e8719377dc708069c
[ "Apache-2.0" ]
null
null
null
archive/MCQ/utils/__init__.py
dreinq/DeepQ
abb6d8b492f802fefbc0095e8719377dc708069c
[ "Apache-2.0" ]
1
2020-11-23T09:13:58.000Z
2020-11-23T09:13:58.000Z
from .runtime import LoggingDisabler, ConfigLogging, QueryGPU, SplitToVirtualGPUs, RotateItems, HotPatch from .ckpt import SaveAndRestore
68.5
104
0.861314
13
137
9.076923
0.846154
0
0
0
0
0
0
0
0
0
0
0
0.087591
137
2
105
68.5
0.944
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
84d526f82006b70e737dcc45ff66841cd9cf508f
72
py
Python
run_server.py
scherniavsky/lizzy
b2bca022967042032aa5e4c3226d760cadc8db49
[ "Apache-2.0" ]
21
2015-06-01T13:54:04.000Z
2017-06-04T01:04:25.000Z
run_server.py
scherniavsky/lizzy
b2bca022967042032aa5e4c3226d760cadc8db49
[ "Apache-2.0" ]
187
2015-06-02T06:29:35.000Z
2017-05-27T12:37:54.000Z
run_server.py
scherniavsky/lizzy
b2bca022967042032aa5e4c3226d760cadc8db49
[ "Apache-2.0" ]
12
2017-06-09T01:10:24.000Z
2019-05-16T10:44:34.000Z
#!/usr/bin/env python3 import lizzy.wsgi lizzy.wsgi.application.run()
12
28
0.75
11
72
4.909091
0.818182
0.333333
0
0
0
0
0
0
0
0
0
0.015385
0.097222
72
5
29
14.4
0.815385
0.291667
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
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
0
0
0
5
84e463cf96981c635d024aa6cdd59a5eacb47c26
12,058
py
Python
tests/test_cz_customize.py
TheNomet/commitizen
5f973989a81660c78f7b2077220ba0beb0022129
[ "MIT" ]
95
2017-10-09T16:36:48.000Z
2020-03-14T18:54:25.000Z
tests/test_cz_customize.py
TheNomet/commitizen
5f973989a81660c78f7b2077220ba0beb0022129
[ "MIT" ]
108
2017-11-04T11:09:22.000Z
2020-03-17T13:34:48.000Z
tests/test_cz_customize.py
TheNomet/commitizen
5f973989a81660c78f7b2077220ba0beb0022129
[ "MIT" ]
25
2017-11-06T10:29:31.000Z
2020-01-23T09:06:30.000Z
import pytest from commitizen.config import BaseConfig, JsonConfig, TomlConfig, YAMLConfig from commitizen.cz.customize import CustomizeCommitsCz from commitizen.exceptions import MissingCzCustomizeConfigError TOML_STR = r""" [tool.commitizen.customize] message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example = "feature: this feature enable customize through config file" schema = "<type>: <body>" schema_pattern = "(feature|bug fix):(\\s.*)" commit_parser = "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?" changelog_pattern = "^(feature|bug fix)?(!)?" change_type_map = {"feature" = "Feat", "bug fix" = "Fix"} bump_pattern = "^(break|new|fix|hotfix)" bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"} change_type_order = ["perf", "BREAKING CHANGE", "feat", "fix", "refactor"] info = "This is a customized cz." [[tool.commitizen.customize.questions]] type = "list" name = "change_type" choices = [ {value = "feature", name = "feature: A new feature."}, {value = "bug fix", name = "bug fix: A bug fix."} ] message = "Select the type of change you are committing" [[tool.commitizen.customize.questions]] type = "input" name = "message" message = "Body." [[tool.commitizen.customize.questions]] type = "confirm" name = "show_message" message = "Do you want to add body message in commit?" """ JSON_STR = r""" { "commitizen": { "name": "cz_jira", "version": "1.0.0", "version_files": [ "commitizen/__version__.py", "pyproject.toml" ], "customize": { "message_template": "{{change_type}}:{% if show_message %} {{message}}{% endif %}", "example": "feature: this feature enable customize through config file", "schema": "<type>: <body>", "schema_pattern": "(feature|bug fix):(\\s.*)", "bump_pattern": "^(break|new|fix|hotfix)", "bump_map": { "break": "MAJOR", "new": "MINOR", "fix": "PATCH", "hotfix": "PATCH" }, "commit_parser": "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?", "changelog_pattern": "^(feature|bug fix)?(!)?", "change_type_map": {"feature": "Feat", "bug fix": "Fix"}, "change_type_order": ["perf", "BREAKING CHANGE", "feat", "fix", "refactor"], "info": "This is a customized cz.", "questions": [ { "type": "list", "name": "change_type", "choices": [ { "value": "feature", "name": "feature: A new feature." }, { "value": "bug fix", "name": "bug fix: A bug fix." } ], "message": "Select the type of change you are committing" }, { "type": "input", "name": "message", "message": "Body." }, { "type": "confirm", "name": "show_message", "message": "Do you want to add body message in commit?" } ] } } } """ YAML_STR = """ commitizen: name: cz_jira version: 1.0.0 version_files: - commitizen/__version__.py - pyproject.toml customize: message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example: 'feature: this feature enable customize through config file' schema: "<type>: <body>" schema_pattern: "(feature|bug fix):(\\s.*)" bump_pattern: "^(break|new|fix|hotfix)" bump_map: break: MAJOR new: MINOR fix: PATCH hotfix: PATCH change_type_order: ["perf", "BREAKING CHANGE", "feat", "fix", "refactor"] info: This is a customized cz. questions: - type: list name: change_type choices: - value: feature name: 'feature: A new feature.' - value: bug fix name: 'bug fix: A bug fix.' message: Select the type of change you are committing - type: input name: message message: Body. - type: confirm name: show_message message: Do you want to add body message in commit? """ TOML_STR_INFO_PATH = """ [tool.commitizen.customize] message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example = "feature: this feature enable customize through config file" schema = "<type>: <body>" bump_pattern = "^(break|new|fix|hotfix)" bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"} info_path = "info.txt" """ JSON_STR_INFO_PATH = r""" { "commitizen": { "customize": { "message_template": "{{change_type}}:{% if show_message %} {{message}}{% endif %}", "example": "feature: this feature enable customize through config file", "schema": "<type>: <body>", "bump_pattern": "^(break|new|fix|hotfix)", "bump_map": { "break": "MAJOR", "new": "MINOR", "fix": "PATCH", "hotfix": "PATCH" }, "info_path": "info.txt" } } } """ YAML_STR_INFO_PATH = """ commitizen: customize: message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example: 'feature: this feature enable customize through config file' schema: "<type>: <body>" bump_pattern: "^(break|new|fix|hotfix)" bump_map: break: MAJOR new: MINOR fix: PATCH hotfix: PATCH info_path: info.txt """ TOML_STR_WITHOUT_INFO = """ [tool.commitizen.customize] message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example = "feature: this feature enable customize through config file" schema = "<type>: <body>" bump_pattern = "^(break|new|fix|hotfix)" bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"} """ JSON_STR_WITHOUT_PATH = r""" { "commitizen": { "customize": { "message_template": "{{change_type}}:{% if show_message %} {{message}}{% endif %}", "example": "feature: this feature enable customize through config file", "schema": "<type>: <body>", "bump_pattern": "^(break|new|fix|hotfix)", "bump_map": { "break": "MAJOR", "new": "MINOR", "fix": "PATCH", "hotfix": "PATCH" } } } } """ YAML_STR_WITHOUT_PATH = """ commitizen: customize: message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}" example: 'feature: this feature enable customize through config file' schema: "<type>: <body>" bump_pattern: "^(break|new|fix|hotfix)" bump_map: break: MAJOR new: MINOR fix: PATCH hotfix: PATCH """ @pytest.fixture( params=[ TomlConfig(data=TOML_STR, path="not_exist.toml"), JsonConfig(data=JSON_STR, path="not_exist.json"), ] ) def config(request): """Parametrize the config fixture This fixture allow to test multiple config formats, without add the builtin parametrize decorator """ return request.param @pytest.fixture( params=[ TomlConfig(data=TOML_STR_INFO_PATH, path="not_exist.toml"), JsonConfig(data=JSON_STR_INFO_PATH, path="not_exist.json"), YAMLConfig(data=YAML_STR_INFO_PATH, path="not_exist.yaml"), ] ) def config_info(request): return request.param @pytest.fixture( params=[ TomlConfig(data=TOML_STR_WITHOUT_INFO, path="not_exist.toml"), JsonConfig(data=JSON_STR_WITHOUT_PATH, path="not_exist.json"), YAMLConfig(data=YAML_STR_WITHOUT_PATH, path="not_exist.yaml"), ] ) def config_without_info(request): return request.param def test_initialize_cz_customize_failed(): with pytest.raises(MissingCzCustomizeConfigError) as excinfo: config = BaseConfig() _ = CustomizeCommitsCz(config) assert MissingCzCustomizeConfigError.message in str(excinfo.value) def test_bump_pattern(config): cz = CustomizeCommitsCz(config) assert cz.bump_pattern == "^(break|new|fix|hotfix)" def test_bump_map(config): cz = CustomizeCommitsCz(config) assert cz.bump_map == { "break": "MAJOR", "new": "MINOR", "fix": "PATCH", "hotfix": "PATCH", } def test_change_type_order(config): cz = CustomizeCommitsCz(config) assert cz.change_type_order == [ "perf", "BREAKING CHANGE", "feat", "fix", "refactor", ] def test_questions(config): cz = CustomizeCommitsCz(config) questions = cz.questions() expected_questions = [ { "type": "list", "name": "change_type", "choices": [ {"value": "feature", "name": "feature: A new feature."}, {"value": "bug fix", "name": "bug fix: A bug fix."}, ], "message": "Select the type of change you are committing", }, {"type": "input", "name": "message", "message": "Body."}, { "type": "confirm", "name": "show_message", "message": "Do you want to add body message in commit?", }, ] assert list(questions) == expected_questions def test_answer(config): cz = CustomizeCommitsCz(config) answers = { "change_type": "feature", "message": "this feature enaable customize through config file", "show_message": True, } message = cz.message(answers) assert message == "feature: this feature enaable customize through config file" cz = CustomizeCommitsCz(config) answers = { "change_type": "feature", "message": "this feature enaable customize through config file", "show_message": False, } message = cz.message(answers) assert message == "feature:" def test_example(config): cz = CustomizeCommitsCz(config) assert "feature: this feature enable customize through config file" in cz.example() def test_schema(config): cz = CustomizeCommitsCz(config) assert "<type>: <body>" in cz.schema() def test_schema_pattern(config): cz = CustomizeCommitsCz(config) assert r"(feature|bug fix):(\s.*)" in cz.schema_pattern() def test_info(config): cz = CustomizeCommitsCz(config) assert "This is a customized cz." in cz.info() def test_info_with_info_path(tmpdir, config_info): with tmpdir.as_cwd(): tmpfile = tmpdir.join("info.txt") tmpfile.write("Test info") cz = CustomizeCommitsCz(config_info) assert "Test info" in cz.info() def test_info_without_info(config_without_info): cz = CustomizeCommitsCz(config_without_info) assert cz.info() is None def test_commit_parser(config): cz = CustomizeCommitsCz(config) assert cz.commit_parser == "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?" def test_changelog_pattern(config): cz = CustomizeCommitsCz(config) assert cz.changelog_pattern == "^(feature|bug fix)?(!)?" def test_change_type_map(config): cz = CustomizeCommitsCz(config) assert cz.change_type_map == {"feature": "Feat", "bug fix": "Fix"}
31.157623
99
0.551501
1,234
12,058
5.230956
0.099676
0.041828
0.060418
0.052363
0.813943
0.769171
0.736948
0.679318
0.636871
0.616731
0
0.000715
0.304362
12,058
386
100
31.238342
0.768836
0.010698
0
0.434251
0
0.009174
0.684551
0.055668
0
0
0
0
0.04893
1
0.055046
false
0
0.012232
0.006116
0.076453
0
0
0
0
null
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
84e9715b67ca2df81ccd5ae034dfaa3e952835d2
77
py
Python
z3py/examples/expr.3.py
rainoftime/rainoftime.github.io
d6316f153db0ed96309d81a5f32af9887c6f1a9a
[ "MIT" ]
1
2021-08-01T07:28:03.000Z
2021-08-01T07:28:03.000Z
z3py/examples/expr.3.py
rainoftime/rainoftime.github.io
d6316f153db0ed96309d81a5f32af9887c6f1a9a
[ "MIT" ]
null
null
null
z3py/examples/expr.3.py
rainoftime/rainoftime.github.io
d6316f153db0ed96309d81a5f32af9887c6f1a9a
[ "MIT" ]
null
null
null
x = Int('x') print (x + 1).hash() print (1 + x).hash() print x.sort().hash()
15.4
21
0.532468
15
77
2.733333
0.4
0.292683
0
0
0
0
0
0
0
0
0
0.03125
0.168831
77
4
22
19.25
0.609375
0
0
0
0
0
0.012987
0
0
0
0
0
0
0
null
null
0
0
null
null
0.75
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
1
0
0
0
0
0
0
1
0
5
ca0bc394a1edaf61588477eb148e5bc80ec18f96
122
py
Python
tcplite/__init__.py
Vincent0700/tcplite
65031b261cd57325403d0663ee92e5fb3f99a19b
[ "MIT" ]
2
2019-01-17T02:16:15.000Z
2019-01-17T02:17:39.000Z
tcplite/__init__.py
Vincent0700/tcplite
65031b261cd57325403d0663ee92e5fb3f99a19b
[ "MIT" ]
null
null
null
tcplite/__init__.py
Vincent0700/tcplite
65031b261cd57325403d0663ee92e5fb3f99a19b
[ "MIT" ]
null
null
null
# coding=utf-8 __author__ = 'wang.yuanqiu007@gmail.com' from .server import * from .client import * from .packet import *
20.333333
40
0.737705
17
122
5.058824
0.764706
0.232558
0
0
0
0
0
0
0
0
0
0.038095
0.139344
122
6
41
20.333333
0.780952
0.098361
0
0
0
0
0.229358
0.229358
0
0
0
0
0
1
0
false
0
0.75
0
0.75
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
5
ca2e2027d5295041decfee9d79576129a733fdcd
182
py
Python
rpi/lcd/__init__.py
irahorecka/rpi-stocks
ecf0e3289d843977e68604a966e71287b7341e8b
[ "MIT" ]
null
null
null
rpi/lcd/__init__.py
irahorecka/rpi-stocks
ecf0e3289d843977e68604a966e71287b7341e8b
[ "MIT" ]
null
null
null
rpi/lcd/__init__.py
irahorecka/rpi-stocks
ecf0e3289d843977e68604a966e71287b7341e8b
[ "MIT" ]
null
null
null
from .lcd import LCD lcd = LCD() def display(*args, **kwargs): lcd.display(*args, **kwargs) def display_datetime(*args, **kwargs): lcd.display_datetime(*args, **kwargs)
15.166667
41
0.659341
24
182
4.916667
0.333333
0.338983
0.288136
0.338983
0
0
0
0
0
0
0
0
0.164835
182
11
42
16.545455
0.776316
0
0
0
0
0
0
0
0
0
0
0
0
1
0.333333
false
0
0.166667
0
0.5
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
5
ca3380c1b537cbe778d572fb4b569286f0719c97
289
py
Python
trading_system/common/__init__.py
djy-git/trading-system
d2e2ba602cad5604710d8f96d914d4268210e730
[ "MIT" ]
null
null
null
trading_system/common/__init__.py
djy-git/trading-system
d2e2ba602cad5604710d8f96d914d4268210e730
[ "MIT" ]
null
null
null
trading_system/common/__init__.py
djy-git/trading-system
d2e2ba602cad5604710d8f96d914d4268210e730
[ "MIT" ]
null
null
null
"""Import all modules in the ``common`` package """ from common.config import * from common.DBHandler import * from common.env import * from common.LoggerFactory import * from common.metrics import * from common.SignalHandler import * from common.Timer import * from common.util import *
24.083333
47
0.768166
39
289
5.692308
0.410256
0.36036
0.504505
0
0
0
0
0
0
0
0
0
0.141869
289
11
48
26.272727
0.895161
0.152249
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
ca8aa97abcc6c959b8987325f11d2c0f5476bf64
7,778
py
Python
icn-scapy/icnscapy/packet.py
westbook1006/H2C-reference
a27f98d7bde313edec09e6da0331e6960c66d44b
[ "BSD-3-Clause-Clear" ]
5
2017-06-02T16:35:02.000Z
2019-12-16T10:59:03.000Z
icn-scapy/icnscapy/packet.py
westbook1006/H2C-reference
a27f98d7bde313edec09e6da0331e6960c66d44b
[ "BSD-3-Clause-Clear" ]
null
null
null
icn-scapy/icnscapy/packet.py
westbook1006/H2C-reference
a27f98d7bde313edec09e6da0331e6960c66d44b
[ "BSD-3-Clause-Clear" ]
1
2016-11-23T06:24:18.000Z
2016-11-23T06:24:18.000Z
""" Lorenzo Saino, Massimo Gallo Copyright (c) 2016 Alcatel-Lucent, Bell Labs ICN packet formats implemented on Scapy and related utility functions """ import zlib import struct from scapy.all import * __all__ = [ 'IcnInterest', 'IcnData', 'interest_over_ip', 'data_over_ip', ] # IP protocol field indicating ICN payload. # In IPv4 specification, 253 is reserved for experimentation IP_PROTO_ICN = 253 # Scapy automatically converts multiple-byte values to big-endian TLV_TYPE_NAME_COMPONENTS_OFFSET = 0x0001 TLV_TYPE_NAME_SEGMENT_IDS_OFFSETS = 0x0002 class IcnInterest(Packet): """Alcatel-Lucent ICN Interest packet format See also: --------- http://www.ietf.org/proceedings/interim/2014/09/27/icnrg/slides/slides-interim-2014-icnrg-2-4.pdf """ name = "ICN_INTEREST" # fmt: B: 1 byte, H: 2bytes, I: 4 bytes fields_desc = [ ShortField("type", 0), ShortField("pkt_len", None), XByteField("hop_limit", 10), ShortField("flags", 0), ShortField("hdr_len", None), FieldLenField("chunk_name_len", None, length_of="chunk_name", fmt="H"), StrLenField("chunk_name", None, length_from=lambda pkt: pkt.chunk_name_len), XShortField("componen_type", TLV_TYPE_NAME_COMPONENTS_OFFSET), FieldLenField("component_offset_len", None, length_of="component_offset", fmt="H"), StrLenField("component_offset", None, length_from=lambda pkt: pkt.component_offset_len) ] def post_build(self, p, pay): """Function called when packet is sent to the wire to generate byte stream This function sets values of header length and packet fields """ hdr_len = self.hdr_len pkt_len = self.pkt_len if not hdr_len: hdr_len = len(p) p = p[:7] + chr(hdr_len >> 8) + chr(hdr_len % 256) + p[9:] if not pkt_len: pkt_len = len(p) + len(pay) p = p[:2] + chr(pkt_len >> 8) + chr(pkt_len % 256) + p[4:] return p + pay def answers(self, other): """Return 1 if other can be an answer to this packet, 0 otherwise""" if not isinstance(other, IcnData): return 0 if other.chunk_name != self.chunk_name: return 0 return 1 class IcnData(Packet): """Alcatel-Lucent ICN Data packet format See also -------- http://www.ietf.org/proceedings/interim/2014/09/27/icnrg/slides/slides-interim-2014-icnrg-2-4.pdf """ # fmt: B: 1 byte, H: 2bytes, I: 4 bytes name = "ICN_DATA" fields_desc = [ ShortField("type", 1), ShortField("pkt_len", None), XByteField("hop_limit", 10), ShortField("flags", 0), ShortField("hdr_len", None), FieldLenField("chunk_name_len", None, length_of="chunk_name", fmt="H"), StrLenField("chunk_name", None, length_from=lambda pkt: pkt.chunk_name_len), XShortField("componen_type", TLV_TYPE_NAME_COMPONENTS_OFFSET), FieldLenField("component_offset_len", None, length_of="component_offset", fmt="H"), StrLenField("component_offset", None, length_from=lambda pkt: pkt.component_offset_len) ] def post_build(self, p, pay): """Function called when packet is sent to the wire to generate byte stream This function sets values of header length and packet fields """ hdr_len = self.hdr_len pkt_len = self.pkt_len if not hdr_len: hdr_len = len(p) p = p[:7] + chr(hdr_len >> 8) + chr(hdr_len % 256) + p[9:] if not pkt_len: pkt_len = len(p) + len(pay) p = p[:2] + chr(pkt_len >> 8) + chr(pkt_len % 256) + p[4:] return p + pay def int_to_ipv4(intval): """Convert an integer (32 bits) value to an IPv4 addressed represented as a *a.b.c.d* string Parameters ---------- intval : int Integer value Returns ------- ipv4 : str The string representation of the IPv6 address """ l = [0, 0, 0, 0] for i in range(4): l[-i] = str(intval % 256) intval >>= 8 return ".".join(l) def compute_offset(name): """Return byte array with offsets of component separators Parameters ---------- name : str The content name Returns ------- offsets : str String of offsets """ offsets = [i for i, ch in enumerate(name) if ch == '/'] return "".join(chr(i >> 8) + chr(i % 256) for i in offsets) def interest_over_ip(name, chunk_id, hash_prefix_only=True, dst_mac_addr=None, dst_ip_addr=None, f_hash=None, component_offset=None): """Return a full ICN over IP Interest packet. The packet contains the CRC32 hash of the name as source IPv4 address and the destination IPv4 address is left blank. Parameters ---------- name : str The ICN object name chunk_id : int The chunk ID hash_prefix_only : bool, optional If True, hash is done on the prefix of the name, i.e. only on the content object name. Otherwise, it is done on the entire object name, comprising also chunk ID dst_mac_addr : str, optional The destination MAC address dst_ip_addr : str, optional The destination IP address f_hash : callable, optional The hash function to use, CRC32 is used if not specified component_offset : str, optional String of component offsets. If None, it is computed by the function """ if not f_hash: f_hash = zlib.crc32 chunk_name = name + "/" if name[-1] != "/" else name chunk_name = chunk_name + struct.pack('>I', chunk_id) eth = Ether() if dst_mac_addr is None else Ether(dst=dst_mac_addr) name_hash = f_hash(name) if hash_prefix_only else f_hash(chunk_name) ip = IP(dst=(dst_ip_addr or "1.1.1.1"), src=int_to_ipv4(name_hash), proto=IP_PROTO_ICN) if not component_offset: component_offset = compute_offset(chunk_name) return eth/ip/IcnInterest(chunk_name=chunk_name, component_offset=component_offset) def data_over_ip(name, chunk_id, payload="", hash_prefix_only=True, dst_mac_addr=None, dst_ip_addr=None, f_hash=None, component_offset=None): """Return a full ICN over IP Data packet. The packet contains the CRC32 hash of the name as source IPv4 address and the destination IPv4 address is left blank. Parameters ---------- name : str The ICN object name chunk_id : int The chunk ID payload : str, optional The payload of the data packet hash_prefix_only : bool, optional If True, hash is done on the prefix of the name, i.e. only on the content object name. Otherwise, it is done on the entire object name, comprising also chunk ID dst_mac_addr : str, optional The destination MAC address dst_ip_addr : str, optional The destination IP address f_hash : callable, optional The hash function to use, CRC32 is used if not specified component_offset : str, optional String of component offsets. If None, it is computed by the function """ if not f_hash: f_hash = zlib.crc32 chunk_name = name + "/" if name[-1] != "/" else name chunk_name = chunk_name + struct.pack('>I', chunk_id) eth = Ether() if dst_mac_addr is None else Ether(dst=dst_mac_addr) name_hash = f_hash(name) if hash_prefix_only else f_hash(chunk_name) ip = IP(dst=(dst_ip_addr or "1.1.1.1"), src=int_to_ipv4(name_hash), proto=IP_PROTO_ICN) if not component_offset: component_offset = compute_offset(chunk_name) return eth/ip/IcnData(chunk_name=chunk_name, component_offset=component_offset)/payload
34.568889
101
0.641939
1,128
7,778
4.245567
0.184397
0.045103
0.016705
0.012529
0.745667
0.73293
0.73293
0.73293
0.712884
0.703278
0
0.023982
0.254821
7,778
224
102
34.723214
0.802277
0.387632
0
0.606061
0
0
0.080983
0
0
0
0.00273
0
0
1
0.070707
false
0
0.030303
0
0.252525
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
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
04c8ebc674f865c2939867088f95f26cdedda054
5,992
py
Python
nevow/test/test_useragent.py
wthie/nevow
e630de8f640f27df85c38bc37ecdaf4e7b931afc
[ "MIT" ]
49
2015-03-18T15:29:16.000Z
2021-11-17T12:30:51.000Z
src/nevow/test/test_useragent.py
winjer/squeal
20401986e0d1698776f5b482b28e14c57b11833c
[ "Apache-2.0" ]
62
2015-01-21T08:48:08.000Z
2021-04-02T17:31:29.000Z
src/nevow/test/test_useragent.py
winjer/squeal
20401986e0d1698776f5b482b28e14c57b11833c
[ "Apache-2.0" ]
30
2015-02-26T09:35:39.000Z
2021-07-24T12:45:04.000Z
""" Tests for L{nevow.useragent}. """ from twisted.trial.unittest import TestCase from nevow.useragent import UserAgent, browsers class UserAgentTests(TestCase): """ Tests for L{UserAgent}. """ def test_parseNetscape71(self): """ L{UserAgent.parse_GECKO} should return a UserAgent instance for a Netscape 7.1 User-Agent string. """ agent = UserAgent.parse_GECKO( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.4) ' 'Gecko/20030624 Netscape/7.1 (ax)') self.assertEqual(agent.browser, browsers.GECKO) self.assertEqual(agent.version, (20030624,)) def test_parseFirefox15(self): """ L{UserAgent.parse_GECKO} should return a UserAgent instance for a Firefox 1.5 User-Agent string. """ agent = UserAgent.parse_GECKO( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.8.0.3) ' 'Gecko/20060426 Firefox/1.5.0.3') self.assertEqual(agent.browser, browsers.GECKO) self.assertEqual(agent.version, (20060426,)) def test_parseBonEcho(self): """ L{UserAgent.parse_GECKO} should return a UserAgent instance for a BonEcho Firefox 2.0 alpha User-Agent string. """ agent = UserAgent.parse_GECKO( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1a2) ' 'Gecko/20060512 BonEcho/2.0a2') self.assertEqual(agent.browser, browsers.GECKO) self.assertEqual(agent.version, (20060512,)) def test_parseFirefox20(self): """ L{UserAgent.parse_GECKO} should return a UserAgent instance for a Firefox 2.0 User-Agent string. """ agent = UserAgent.parse_GECKO( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.4) ' 'Gecko/20070515 Firefox/2.0.0.4') self.assertEqual(agent.browser, browsers.GECKO) self.assertEqual(agent.version, (20070515,)) def test_parseExplorer45(self): """ L{UserAgent.parse_MSIE} should return a UserAgent instance for an Internet Explorer 4.5 User-Agent string. """ agent = UserAgent.parse_MSIE( 'Mozilla/4.0 (compatible; MSIE 4.5; Windows 98; Win 9x 4.8410008)') self.assertEqual(agent.browser, browsers.INTERNET_EXPLORER) self.assertEqual(agent.version, (4, 5)) def test_parseExplorer55(self): """ L{UserAgent.parse_MSIE} should return a UserAgent instance for an Internet Explorer 5.5 User-Agent string. """ agent = UserAgent.parse_MSIE( 'Mozilla/5.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.1704896)') self.assertEqual(agent.browser, browsers.INTERNET_EXPLORER) self.assertEqual(agent.version, (5, 5)) def test_parseExplorer65(self): """ L{UserAgent.parse_MSIE} should return a UserAgent instance for an Internet Explorer 6.5 User-Agent string. """ agent = UserAgent.parse_MSIE( 'Mozilla/5.0 (compatible; MSIE 6.5; Windows 98; Win 9x 4.7654712)') self.assertEqual(agent.browser, browsers.INTERNET_EXPLORER) self.assertEqual(agent.version, (6, 5)) def test_parseOmniWeb607(self): """ L{UserAgent.parse_WEBKIT} should return a UserAgent instance for an OmniWeb User-Agent string. """ agent = UserAgent.parse_WEBKIT( 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ ' '(KHTML, like Gecko, Safari/420) OmniWeb/v607.17') self.assertEqual(agent.browser, browsers.WEBKIT) self.assertEqual(agent.version, (420,)) def test_parseSafari20(self): """ L{UserAgent.parse_WEBKIT} should return a UserAgent instance for a Safari 2.0 User-Agent string. """ agent = UserAgent.parse_WEBKIT( 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/' '418.9.1 (KHTML, like Gecko) Safari/419.3') self.assertEqual(agent.browser, browsers.WEBKIT) self.assertEqual(agent.version, (418, 9, 1)) def test_parseOpera9(self): """ L{UserAgent.parse_OPERA} should return a UserAgent instance for an Opera 9 User-Agent string. """ agent = UserAgent.parse_OPERA('Opera/9.20 (Windows NT 6.0; U; en)') self.assertEqual(agent.browser, browsers.OPERA) self.assertEqual(agent.version, (9, 20)) def test_geckoParser(self): """ It should be possible to invoke the Gecko parser via L{UserAgent.parse} with an appropriate string. """ agent = UserAgent.fromHeaderValue( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.4) ' 'Gecko/20030624 Netscape/7.1 (ax)') self.assertEqual(agent.browser, browsers.GECKO) def test_webkitParser(self): """ It should be possible to invoke the WebKit parser via L{UserAgent.parse} with an appropriate string. """ agent = UserAgent.fromHeaderValue( 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ ' '(KHTML, like Gecko, Safari/420) OmniWeb/v607.17') self.assertEqual(agent.browser, browsers.WEBKIT) def test_msieParser(self): """ It should be possible to invoke the MSIE parser via L{UserAgent.parse} with an appropriate string. """ agent = UserAgent.fromHeaderValue( 'Mozilla/4.0 (compatible; MSIE 4.5; Windows 98; Win 9x 4.8410008)') self.assertEqual(agent.browser, browsers.INTERNET_EXPLORER) def test_operaParser(self): """ It should be possible to invoke the Opera parser via L{UserAgent.parse} with an appropriate string. """ agent = UserAgent.fromHeaderValue('Opera/9.20 (Windows NT 6.0; U; en)') self.assertEqual(agent.browser, browsers.OPERA)
35.455621
79
0.620828
753
5,992
4.889774
0.152722
0.091255
0.130364
0.102662
0.791146
0.791146
0.772678
0.762086
0.725149
0.714557
0
0.064135
0.266188
5,992
168
80
35.666667
0.773254
0.244159
0
0.48
0
0.146667
0.267256
0
0
0
0
0
0.32
1
0.186667
false
0
0.026667
0
0.226667
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
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
04e0bb0adeede79780bab39de27aed691122d532
127
py
Python
tests/test_pipeline.py
germaneduardo/sentiment-classification-models
dee6e74eeea92c79ec4d77b08edf4c3632ec6a98
[ "MIT" ]
null
null
null
tests/test_pipeline.py
germaneduardo/sentiment-classification-models
dee6e74eeea92c79ec4d77b08edf4c3632ec6a98
[ "MIT" ]
null
null
null
tests/test_pipeline.py
germaneduardo/sentiment-classification-models
dee6e74eeea92c79ec4d77b08edf4c3632ec6a98
[ "MIT" ]
null
null
null
from sentiment_analysis_models.data import pipeline def test_process_tweet(): pipeline.process_tweet("a") assert True
21.166667
51
0.787402
17
127
5.588235
0.823529
0.252632
0
0
0
0
0
0
0
0
0
0
0.141732
127
6
52
21.166667
0.87156
0
0
0
0
0
0.007813
0
0
0
0
0
0.25
1
0.25
true
0
0.25
0
0.5
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
1
0
0
0
0
0
0
5
b6f86aa79a9b62e04ad6e807e5611a6d80bfda12
215
py
Python
Learn/30-Days-Of-Code/Day 27/testing.py
Adriel-M/HackerRank
0f361bb7eaa3d2db3dd96de511c4b7fa02efa8c5
[ "MIT" ]
1
2021-11-24T16:43:10.000Z
2021-11-24T16:43:10.000Z
Learn/30-Days-Of-Code/Day 27/testing.py
Adriel-M/HackerRank
0f361bb7eaa3d2db3dd96de511c4b7fa02efa8c5
[ "MIT" ]
null
null
null
Learn/30-Days-Of-Code/Day 27/testing.py
Adriel-M/HackerRank
0f361bb7eaa3d2db3dd96de511c4b7fa02efa8c5
[ "MIT" ]
null
null
null
# https://www.hackerrank.com/challenges/30-testing/forum/comments/138775 print("5") print("5 3\n-1 90 999 100 0") print("4 2\n0 -1 2 1") print("3 3\n-1 0 1") print("6 1\n-1 0 1 -1 2 3") print("7 3\n-1 0 1 2 3 4 5")
26.875
72
0.627907
56
215
2.410714
0.428571
0.059259
0.066667
0.088889
0.074074
0
0
0
0
0
0
0.269231
0.153488
215
7
73
30.714286
0.472527
0.325581
0
0
0
0
0.573427
0
0
0
0
0
0
1
0
true
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
5
8e149b61cb295ace529fdb7658d3201ffb678b2f
105
py
Python
solumdashboard/applications/workflows/__init__.py
openstack/solum-dashboard
8e4c80b91b6bcf724e91b3f102cddbdb15b7369c
[ "Apache-2.0" ]
16
2015-09-24T07:35:11.000Z
2019-01-28T22:11:35.000Z
solumdashboard/applications/workflows/__init__.py
stackforge/solum-dashboard
f2d61f2e0258e30285731cc5fa66e86dacc9cb3e
[ "Apache-2.0" ]
1
2019-12-04T21:50:19.000Z
2019-12-04T21:50:22.000Z
solumdashboard/applications/workflows/__init__.py
stackforge/solum-dashboard
f2d61f2e0258e30285731cc5fa66e86dacc9cb3e
[ "Apache-2.0" ]
1
2016-05-30T10:00:53.000Z
2016-05-30T10:00:53.000Z
# Importing non-modules that are not used explicitly from .update import UpdateApplicationClass # noqa
26.25
52
0.809524
13
105
6.538462
1
0
0
0
0
0
0
0
0
0
0
0
0.152381
105
3
53
35
0.955056
0.52381
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
8e3ebe11c8eba8be3bd2a7cf9e47325898fea468
513
py
Python
wol_control/models.py
TheLastBilly/wol_control
0e16c4ee0b89de3d0870e7dcc9026c55b9fd92b6
[ "BSD-2-Clause" ]
null
null
null
wol_control/models.py
TheLastBilly/wol_control
0e16c4ee0b89de3d0870e7dcc9026c55b9fd92b6
[ "BSD-2-Clause" ]
null
null
null
wol_control/models.py
TheLastBilly/wol_control
0e16c4ee0b89de3d0870e7dcc9026c55b9fd92b6
[ "BSD-2-Clause" ]
null
null
null
from flask_login import UserMixin from . import db class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) password = db.Column(db.String(100)) admin = db.Column(db.Boolean()) class Mac(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) mac = db.Column(db.String(18)) ip = db.Column(db.String(16)) admin = db.Column(db.Boolean()) public_id = db.Column(db.String(100))
32.0625
48
0.672515
81
513
4.209877
0.320988
0.234604
0.293255
0.281525
0.662757
0.422287
0.422287
0.422287
0.422287
0.422287
0
0.037559
0.169591
513
16
49
32.0625
0.762911
0
0
0.428571
0
0
0
0
0
0
0
0
0
1
0
false
0.071429
0.142857
0
1
0
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
1
0
0
5
6d41d8666e851b2203f25e56f9a0a7d722d8199e
89
py
Python
alliancewar/__init__.py
Trapavko/CollectorDevTeam-mcoc-v3
c81594527ff2a774438a1823ab2d9fea4d2f5d5f
[ "MIT" ]
null
null
null
alliancewar/__init__.py
Trapavko/CollectorDevTeam-mcoc-v3
c81594527ff2a774438a1823ab2d9fea4d2f5d5f
[ "MIT" ]
null
null
null
alliancewar/__init__.py
Trapavko/CollectorDevTeam-mcoc-v3
c81594527ff2a774438a1823ab2d9fea4d2f5d5f
[ "MIT" ]
null
null
null
from .alliancewar import AllianceWar def setup(bot): bot.add_cog(AllianceWar())
17.8
37
0.719101
11
89
5.727273
0.727273
0
0
0
0
0
0
0
0
0
0
0
0.179775
89
4
38
22.25
0.863014
0
0
0
0
0
0
0
0
0
0
0
0
1
0.333333
false
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
0
0
1
0
1
0
0
5
6d5f86c914c71c187e914ac38fbfe1b977bb89d5
33,486
py
Python
ssa_sim_v2/result_aggregators/experiment_plot_visualizer.py
donghun2018/adclick-simulator-v2
ade886e9dcbde9fcea218a19f0130cc09f81e55e
[ "MIT" ]
null
null
null
ssa_sim_v2/result_aggregators/experiment_plot_visualizer.py
donghun2018/adclick-simulator-v2
ade886e9dcbde9fcea218a19f0130cc09f81e55e
[ "MIT" ]
null
null
null
ssa_sim_v2/result_aggregators/experiment_plot_visualizer.py
donghun2018/adclick-simulator-v2
ade886e9dcbde9fcea218a19f0130cc09f81e55e
[ "MIT" ]
null
null
null
# Fix paths for imports to work in unit tests ---------------- if __name__ == "__main__": from _fix_paths import fix_paths fix_paths() # ------------------------------------------------------------ # Load libraries --------------------------------------------- import pandas as pd import numpy as np import os import matplotlib.pyplot as plt from ssa_sim_v2.tools.directory_utils import ensure_dir from ssa_sim_v2.result_aggregators.experiment_loader import ExperimentLoader from ssa_sim_v2.tools.file_data_handler import FileDataHandler # ------------------------------------------------------------ class SummaryExperimentPlotVisualizer(object): def __init__(self, root_directory, chart_directory, experiment_name, state_type): self.root_directory = root_directory self.series_plot_visualizer = SeriesPlotVisualizer(root_directory=root_directory, chart_directory=chart_directory, experiment_name=experiment_name, state_type=state_type) self.bar_plot_visualizer = ProfitBarPlotVisualizer(root_directory=root_directory, chart_directory=chart_directory, experiment_name=experiment_name, state_type=state_type) self.rep_result_series_plot_visualizer = RepResultSeriesPlotVisualizer(root_directory=root_directory) self.experiment_loader = ExperimentLoader(root_directory=root_directory) def generate_summary_profit_series_plots(self, result_dict, save=False): self.series_plot_visualizer.visualize(result_dict, save) def generate_summary_profit_bar_plots(self, result_dict, save=False): self.bar_plot_visualizer.visualize(result_dict, save) class RepResultExperimentPlotVisualizer(object): def __init__(self, root_directory, figsize=(15, 7), save=False): self.root_directory = root_directory self.figsize = figsize self.save = save self.rep_result_series_plot_visualizer = RepResultSeriesPlotVisualizer(root_directory, figsize, save) self.rep_result_cum_series_plot_visualizer = RepResultCumSeriesPlotVisualizer(root_directory, figsize, save) self.experiment_loader = ExperimentLoader(root_directory) self.comparison_series_plot_visualizer = PriorSimulatorSeriesPlotVisualizer(root_directory, figsize, save) plt.style.use("seaborn-whitegrid") def generate_series_bid_rep_result(self, experiment_name): self._generate_series_rep_result(series_name="bid", experiment_name=experiment_name) def generate_series_profit_rep_result(self, experiment_name): """ Generates series plot of profit obtained from experiment rounds for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of profit (display or save). """ self._generate_series_rep_result(series_name="profit", experiment_name=experiment_name) def generate_series_cumulative_bid_rep_result(self, experiment_name, slice_result=None): self._generate_cumulative_series_rep_result(series_name="bid", experiment_name=experiment_name, slice_result=slice_result) def generate_series_cumulative_profit_rep_result(self, experiment_name, slice_result=None): """ Generates series plot of cumulative profit obtained from experiment rounds for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :param dict slice_result: :return: Return generated series plot of profit (display or save). """ self._generate_cumulative_series_rep_result(series_name="profit", experiment_name=experiment_name, slice_result=slice_result) def generate_series_prior_auctions_rep_result(self, experiment_name): """ Generates series plot of auctions used as a prior in simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior auctions (display or save). """ self._generate_series_rep_result(series_name="prior.auctions", experiment_name=experiment_name) def generate_series_prior_conversion_rate_rep_result(self, experiment_name, slice_result=None): """ Generates series plot of conversion_rate used as a prior in simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :param dict slice_result: :return: Return generated series plot of prior conversion rate (display or save). """ self._generate_series_rep_result(series_name="prior.conversion_rate", experiment_name=experiment_name, slice_result=slice_result) def generate_series_prior_dcpc_rep_result(self, experiment_name): """ Generates series plot of dcpc used as a prior in simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior dcpc (display or save). """ self._generate_series_rep_result(series_name="prior.dcpc", experiment_name=experiment_name) def generate_series_prior_max_cp_rep_result(self, experiment_name): """ Generates series plot of max_cp used in simulator to calculate number of clicks for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior tau (display or save). """ self._generate_series_rep_result(series_name="prior.max_cp", experiment_name=experiment_name) def generate_series_prior_tau_rep_result(self, experiment_name): """ Generates series plot of tau used in simulator to calculate number of clicks for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior max_cp (display or save). """ self._generate_series_rep_result(series_name="prior.tau", experiment_name=experiment_name) def generate_series_prior_theta_1_rep_result(self, experiment_name): """ Generates series plot of theta_1 used in simulator to calculate number of clicks for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior theta_1 (display or save). """ self._generate_series_rep_result(series_name="prior.theta_1", experiment_name=experiment_name) def generate_series_prior_theta_0_rep_result(self, experiment_name): """ Generates series plot of theta_0 used in simulator to calculate number of clicks for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior theta_0 (display or save). """ self._generate_series_rep_result(series_name="prior.theta_0", experiment_name=experiment_name) def generate_series_prior_rpv_rep_result(self, experiment_name): """ Generates series plot of rpv used as a prior in simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior rpv (display or save). """ self._generate_series_rep_result(series_name="prior.rpv", experiment_name=experiment_name) def generate_series_prior_expected_profit_rep_result(self, experiment_name): """ Generates series plot of rpv used as a prior in simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of prior rpv (display or save). """ self._generate_series_rep_result(series_name="prior.expected_profit", experiment_name=experiment_name) def generate_series_simulator_auctions_rep_result(self, experiment_name): """ Generates series plot of number of auctions obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated auctions (display or save). """ self._generate_series_rep_result(series_name="simulator.auctions", experiment_name=experiment_name) def generate_series_simulator_click_probability_rep_result(self, experiment_name): """ Generates series plot for value of click probability obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of click probability (display or save). """ self._generate_series_rep_result(series_name="simulator.click_probability", experiment_name=experiment_name) def generate_series_simulator_clicks_rep_result(self, experiment_name): """ Generates series plot of number of clicks obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated clicks (display or save). """ self._generate_series_rep_result(series_name="simulator.clicks", experiment_name=experiment_name) def generate_series_simulator_conversions_rep_result(self, experiment_name): """ Generates series plot of number of conversions obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated conversions (display or save). """ self._generate_series_rep_result(series_name="simulator.conversions", experiment_name=experiment_name) def generate_series_simulator_cost_rep_result(self, experiment_name): """ Generates series plot for value of cost obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated cost (display or save). """ self._generate_series_rep_result(series_name="simulator.cost", experiment_name=experiment_name) def generate_series_simulator_cpc_rep_result(self, experiment_name): """ Generates series plot for value of cpc obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated cpc (display or save). """ self._generate_series_rep_result(series_name="simulator.cpc", experiment_name=experiment_name) def generate_series_simulator_cpc_bid_rep_result(self, experiment_name): """ Generates series plot for value of cpc bid obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated cpc bid (display or save). """ self._generate_series_rep_result(series_name="simulator.cpc_bid", experiment_name=experiment_name) def generate_series_simulator_cvr_rep_result(self, experiment_name): """ Generates series plot for value of cvr obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated cvr (display or save). """ self._generate_series_rep_result(series_name="simulator.cvr", experiment_name=experiment_name) def generate_series_simulator_dcpc_rep_result(self, experiment_name): """ Generates series plot for value of dcpc obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated dcpc (display or save). """ self._generate_series_rep_result(series_name="simulator.dcpc", experiment_name=experiment_name) def generate_series_simulator_revenue_rep_result(self, experiment_name): """ Generates series plot for value of revenue obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated revenue (display or save). """ self._generate_series_rep_result(series_name="simulator.revenue", experiment_name=experiment_name) def generate_series_simulator_rpv_rep_result(self, experiment_name): """ Generates series plot for value of rpv obtained from simulator for defined experiment spec name. :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of generated rpv (display or save). """ self._generate_series_rep_result(series_name="simulator.rpv", experiment_name=experiment_name) def generate_comparison_series_auctions_rep_result(self, experiment_name): """ :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of profit (display or save). """ self._generate_comparison_series_rep_result(series_name="auctions", experiment_name=experiment_name) def generate_comparison_series_clicks_rep_result(self, experiment_name): """ :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of profit (display or save). """ self._generate_comparison_series_rep_result(series_name="clicks", experiment_name=experiment_name) def generate_comparison_series_conversion_rate_rep_result(self, experiment_name): """ :param str experiment_name: Name of the experiment spec name. :return: Return generated series plot of profit (display or save). """ self._generate_comparison_series_rep_result(series_name="conversion_rate", experiment_name=experiment_name) def _generate_series_rep_result(self, series_name, experiment_name, slice_result=None): """ :param str series_name: :param str experiment_name: :return: """ policy_result_dict = self.experiment_loader.load_experiment_repetition_results_for_each_policy(experiment_name) self.rep_result_series_plot_visualizer.visualize(policy_result_dict=policy_result_dict, series_name=series_name, experiment_name=experiment_name, slice_result=slice_result) def _generate_comparison_series_rep_result(self, series_name, experiment_name, slice_result=None): """ :param str series_name: :param str experiment_name: :return: """ policy_result_dict = self.experiment_loader.load_experiment_repetition_results_for_each_policy(experiment_name) self.comparison_series_plot_visualizer.visualize(policy_result_dict=policy_result_dict, series_name=series_name, experiment_name=experiment_name, slice_result=slice_result) def _generate_cumulative_series_rep_result(self, series_name, experiment_name, slice_result=None): """ :param str series_name: :param str experiment_name: :return: """ policy_result_dict = self.experiment_loader.load_experiment_repetition_results_for_each_policy(experiment_name) self.rep_result_cum_series_plot_visualizer.visualize(policy_result_dict=policy_result_dict, series_name=series_name, experiment_name=experiment_name, slice_result=slice_result) class PlotVisualizer(object): def __init__(self, root_directory, chart_directory=None, experiment_name=None): self.root_directory = root_directory self.chart_directory = chart_directory self.experiment_name = experiment_name def visualize(self, **kwargs): pass class RepResultSeriesPlotVisualizer(PlotVisualizer): def __init__(self, root_directory, figsize=(15, 7), save=False): PlotVisualizer.__init__(self, root_directory) self.figsize = figsize self.save = save def visualize(self, policy_result_dict, series_name, experiment_name, slice_result=None): """ :param policy_result_dict: :param series_name: :param experiment_name: :param slice_result: :return: """ df_list = list() extracted_index = None for policy_name, rep_result_dict_list in policy_result_dict.items(): for rep_result_dict in rep_result_dict_list: seed_dict = rep_result_dict["seed"] action_df = rep_result_dict["action_experiment_df"] if extracted_index is None: extracted_index = action_df["datetime"] action_df["policy_name"] = policy_name action_df["seed_mod"] = seed_dict["mod"] action_df["seed_pol"] = seed_dict["pol"] df_list.append(action_df) final_df = pd.concat(df_list, axis=0, ignore_index=True) # type: pd.DataFrame if series_name not in final_df.columns: raise ValueError("Incorrect value of the series. There isn't series {} in experiment result DataFrame".format(series_name)) for group_idx, group_df in final_df.groupby(['seed_mod', 'seed_pol']): policy_series_list = list() policy_name_list = list() for policy_name, policy_group in group_df.groupby(["policy_name"])[series_name]: policy_name_list.append(policy_name) policy_series_list.append(policy_group.reset_index(drop=True)) result_df = pd.concat(policy_series_list, axis=1) result_df = result_df.set_index(extracted_index) # type: pd.DataFrame result_df.columns = policy_name_list if slice_result is not None: result_df = result_df.loc[slice_result["start"]:slice_result["end"], :] ax = result_df.plot(figsize=self.figsize, alpha=0.5) ax.set_ylabel(series_name.capitalize().replace("_", " ")) ax.set_title("Experiment repetition results for {}".format(series_name)) # plt.tight_layout() x0, x1, y0, y1 = plt.axis() plot_margin = 2.25 plt.axis((x0 - plot_margin, x1 + plot_margin, y0 - plot_margin, y1 + plot_margin)) if self.save: file_name = "experiment_repetition_results_[{}].png".format(series_name) plt.savefig(os.path.join(self.root_directory, experiment_name, file_name), bbox_inches="tight") plt.close() else: plt.show() class PriorSimulatorSeriesPlotVisualizer(PlotVisualizer): def __init__(self, root_directory, figsize=(15, 7), save=False): PlotVisualizer.__init__(self, root_directory) self.figsize = figsize self.save = save def visualize(self, policy_result_dict, series_name, experiment_name, slice_result=None): """ :param policy_result_dict: :param series_name: :param experiment_name: :param slice_result: :return: """ df_list = list() extracted_index = None for policy_name, rep_result_dict_list in policy_result_dict.items(): for rep_result_dict in rep_result_dict_list: seed_dict = rep_result_dict["seed"] action_df = rep_result_dict["action_experiment_df"] if extracted_index is None: extracted_index = action_df["datetime"] action_df["policy_name"] = policy_name action_df["seed_mod"] = seed_dict["mod"] action_df["seed_pol"] = seed_dict["pol"] df_list.append(action_df) final_df = pd.concat(df_list, axis=0, ignore_index=True) # type: pd.DataFrame if series_name == "conversion_rate": simulator_series_name = "cvr" else: simulator_series_name = series_name if "simulator.{}".format(simulator_series_name) not in final_df.columns: raise ValueError("Incorrect value of the series. There isn't series {} in experiment result DataFrame".format(simulator_series_name)) for policy_name, group_df in final_df.groupby(["policy_name"]): policy_series_list = list() series_names_list = list() for seed_names, policy_group in group_df.groupby(['seed_mod', 'seed_pol'])["simulator.{}".format(simulator_series_name)]: series_names_list.append(seed_names) policy_series_list.append(policy_group.reset_index(drop=True)) spec_dir = os.path.join("roomsage_simulator_starter", "experiment_specs", "historical") file_data_handler = FileDataHandler() experiment_spec = file_data_handler.load_spec(spec_dir, "{}".format(experiment_name)) dataset_name = experiment_spec["dataset_name"] file_data_handler = FileDataHandler() prior_df = file_data_handler.load_data("", dataset_name) prior_df["datetime"] = pd.to_datetime(prior_df["date"]) prior_df = prior_df.set_index(prior_df["datetime"]) prior_df = prior_df.loc[extracted_index[0]:, :] series_names_list.append("PRIOR") policy_series_list.append(prior_df[[series_name]].reset_index(drop=True)) result_df = pd.concat(policy_series_list, axis=1) result_df = result_df.set_index(extracted_index) # type: pd.DataFrame result_df = result_df.resample(rule="1M").sum() result_df.columns = series_names_list if slice_result is not None: result_df = result_df.loc[slice_result["start"]:slice_result["end"], :] ax = result_df.plot(figsize=self.figsize, alpha=0.5) ax.set_ylabel(series_name.capitalize().replace("_", " ")) ax.set_title("Experiment results for {}, using {} policy".format(series_name, policy_name)) # plt.tight_layout() x0, x1, y0, y1 = plt.axis() plot_margin = 2.25 plt.axis((x0 - plot_margin, x1 + plot_margin, y0 - plot_margin, y1 + plot_margin)) if self.save: file_name = "experiment_repetition_results_[{}].png".format(series_name) plt.savefig(os.path.join(self.root_directory, experiment_name, file_name), bbox_inches="tight") plt.close() else: plt.show() class RepResultCumSeriesPlotVisualizer(PlotVisualizer): def __init__(self, root_directory, figsize=(15, 7), save=False): PlotVisualizer.__init__(self, root_directory) self.figsize = figsize self.save = save def visualize(self, policy_result_dict, series_name, experiment_name, slice_result=None): """ :param policy_result_dict: :param series_name: :param experiment_name: :param slice_result: :return: """ df_list = list() extracted_index = None for policy_name, rep_result_dict_list in policy_result_dict.items(): for rep_result_dict in rep_result_dict_list: seed_dict = rep_result_dict["seed"] action_df = rep_result_dict["action_experiment_df"] if extracted_index is None: extracted_index = action_df["datetime"] action_df["policy_name"] = policy_name action_df["seed_mod"] = seed_dict["mod"] action_df["seed_pol"] = seed_dict["pol"] df_list.append(action_df) final_df = pd.concat(df_list, axis=0, ignore_index=True) # type: pd.DataFrame if series_name not in final_df.columns: raise ValueError("Incorrect value of the series. There isn't series {} in experiment result DataFrame".format(series_name)) for group_idx, group_df in final_df.groupby(['seed_mod', 'seed_pol']): policy_series_list = list() policy_name_list = list() for policy_name, policy_group in group_df.groupby(["policy_name"])[series_name]: policy_name_list.append(policy_name) policy_series_list.append(policy_group.reset_index(drop=True)) result_df = pd.concat(policy_series_list, axis=1) result_df = result_df.set_index(extracted_index) # type: pd.DataFrame result_df.columns = policy_name_list if slice_result is not None: result_df = result_df.loc[slice_result["start"]:slice_result["end"], :] ax = result_df.cumsum().plot(figsize=self.figsize, alpha=0.5) ax.set_ylabel(series_name.capitalize().replace("_", " ")) ax.set_title("Experiment repetition results for cumulative sum of {}".format(series_name)) if self.save: file_name = "experiment_repetition_results_[{}].png".format(series_name) plt.savefig(os.path.join(self.root_directory, experiment_name, file_name), bbox_inches="tight") plt.close() else: plt.show() class SeriesPlotVisualizer(PlotVisualizer): def __init__(self, root_directory, chart_directory, experiment_name, state_type): super().__init__(root_directory, chart_directory, experiment_name) self.state_type = state_type def visualize(self, result_dict, save=False): plt.style.use("seaborn-whitegrid") action_policy_mean_results_df = result_dict['action_policy_mean_df'] action_policy_std_results_df = result_dict['action_policy_std_df'] action_policy_counter_df = result_dict['action_policy_counter_df'] self.generate_cumulative_and_avg_series_plots(mean_df=action_policy_mean_results_df, std_df=action_policy_std_results_df, counter_df=action_policy_counter_df, save=save) def generate_avg_series_plot(self, mean_df, std_df, counter_df, save=False): mean_series = mean_df / counter_df std_series = std_df / np.sqrt(counter_df) self._generate_plot_series(mean_df=mean_series, std_df=std_series, plot_type="avg", save=save) def generate_cumulative_series_plot(self, mean_df, std_df, save=False): self._generate_plot_series(mean_df=mean_df, std_df=std_df, plot_type="cum", save=save) def generate_cumulative_and_avg_series_plots(self, mean_df, std_df, counter_df, save=False): self.generate_cumulative_series_plot(mean_df=mean_df, std_df=std_df, save=save) self.generate_avg_series_plot(mean_df=mean_df, std_df=std_df, counter_df=counter_df, save=save) def _generate_plot_series(self, mean_df, std_df, plot_type="avg", save=False): if plot_type == "avg": y_label = "Average {} profit".format(self.state_type) title = "Average {} Profit Between Checkpoints".format(self.state_type.capitalize()) file_name = "Chart_2_{}.png" elif plot_type == "cum": y_label = "Average cumulative profit" title = "Cumulative Profit Between Checkpoints" file_name = "Chart_1_{}.png" else: raise ValueError("Incorrect value of the plot_type") ax = mean_df.plot(figsize=(20, 7), marker='o', markersize=5, yerr=std_df) ax.set_xlabel("Day") ax.set_ylabel(y_label) ax.set_title(title) plt.legend(bbox_to_anchor=(0.5, -0.17), loc="upper center", frameon=False, ncol=2, mode="expand") if save: file_name = file_name.format(y_label.replace(" ", "_")) file_path = os.path.join(self.chart_directory, file_name) ensure_dir(file_path) plt.savefig(file_path, bbox_inches="tight") plt.show() plt.close() else: plt.show() class ProfitBarPlotVisualizer(PlotVisualizer): def __init__(self, root_directory, chart_directory, experiment_name, state_type): super().__init__(root_directory, chart_directory, experiment_name) self.state_type = state_type plt.style.use("seaborn-whitegrid") def visualize(self, result_dict, save=False): action_policy_mean_results_df = result_dict['action_policy_mean_df'] action_policy_counter_df = result_dict['action_policy_counter_df'] self.generate_total_and_avg_bar_plots(mean_df=action_policy_mean_results_df, counter_df=action_policy_counter_df, save=save) def generate_total_and_avg_bar_plots(self, mean_df, counter_df, save=False): self.generate_total_bar_plot(mean_df, save) self.generate_average_bar_plot(mean_df, counter_df, save) def generate_total_bar_plot(self, mean_df, save=False): # Calculate total profit total_profit = mean_df.sum(axis=0) self._generate_bar_plot(series=total_profit, plot_type="total", save=save) def generate_average_bar_plot(self, mean_df, counter_df, save=False): # Calculate average profit avg_profit = mean_df.sum(axis=0) / counter_df.astype(float).sum(axis=0) result_str = "" for policy_name, avg_value in avg_profit.iteritems(): result_str += "Policy: {}\n".format(policy_name) result_str += "Total profit={}\n".format( avg_value * counter_df.astype(float).sum(axis=0).loc[policy_name]) result_str += "Average hourly profit={}\n".format(avg_value) result_str += "\n" print(result_str) self._generate_bar_plot(series=avg_profit, plot_type="avg", save=save) def _generate_bar_plot(self, series, plot_type="avg", save=False): max_result = np.max(np.max(series), 0) min_result = np.min(np.min(series), 0) results_range = np.max([max_result - min_result, 0.1]) ax = series.plot(kind='bar', figsize=(20, 7)) for p in ax.patches: shift = 0.04 * results_range if p.get_height() >= 0 else -0.1 * results_range ax.annotate("{}".format(np.round(p.get_height(), 2)), (p.get_x() + p.get_width() / 2.0, p.get_height() + shift), ha="center", va="bottom") if plot_type == "avg": y_label = "Average {} profit".format(self.state_type) file_name = "Chart_4_{}.png" elif plot_type == "total": y_label = "Total profit" file_name = "Chart_3_{}.png" else: raise ValueError("Incorrect value of the plot_type") ax.set_ylabel(y_label) ax.set_title("{}s".format(y_label)) if save: file_name = file_name.format(y_label.replace(" ", "_")) file_path = os.path.join(self.chart_directory, file_name) ensure_dir(file_path) plt.savefig(file_path, bbox_inches="tight") plt.show() plt.close() else: plt.show() if __name__ == "__main__": viz = RepResultExperimentPlotVisualizer(os.path.join("data", "output", "Historical_Calibration"), figsize=(15, 5), save=False) # viz.generate_series_profit_rep_result("gadw_campagne_chessy_fr_hotel_spa_const_log_log_curve_const_cvr_is_1_181655974_42054076756_20170101_20181231") viz.generate_comparison_series_auctions_rep_result("Hotel_IT_OM_Hotel_IT_const_log_log_curve_real_cvr_is_1_20170101_20181231") viz.generate_comparison_series_clicks_rep_result("Hotel_IT_OM_Hotel_IT_const_log_log_curve_real_cvr_is_1_20170101_20181231") viz.generate_comparison_series_conversion_rate_rep_result("Hotel_IT_OM_Hotel_IT_const_log_log_curve_real_cvr_is_1_20170101_20181231") # viz.generate_series_bid_rep_result("Hotel_IT_OM_Hotel_IT_const_log_log_curve_real_cvr_is_1_20170101_20181231")
46.251381
155
0.664905
4,073
33,486
5.114166
0.0685
0.096111
0.040615
0.044359
0.844695
0.816419
0.780653
0.752712
0.691647
0.66313
0
0.008007
0.250314
33,486
723
156
46.315353
0.821742
0.206056
0
0.526316
0
0
0.084545
0.022045
0
0
0
0
0
1
0.142105
false
0.002632
0.021053
0
0.184211
0.002632
0
0
0
null
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
eda88884e2c565b6324e72af1702e9a25d6b0643
138
py
Python
tests/test_r_freeze.py
chinmayshah99/r_freeze
48110e8f021b2adb9ec5b3bac152ca1b73bcc34e
[ "MIT" ]
1
2021-01-13T04:10:54.000Z
2021-01-13T04:10:54.000Z
tests/test_r_freeze.py
chinmayshah99/r_freeze
48110e8f021b2adb9ec5b3bac152ca1b73bcc34e
[ "MIT" ]
5
2020-10-03T14:07:40.000Z
2021-02-13T13:30:08.000Z
tests/test_r_freeze.py
chinmayshah99/r_freeze
48110e8f021b2adb9ec5b3bac152ca1b73bcc34e
[ "MIT" ]
1
2020-10-03T17:26:35.000Z
2020-10-03T17:26:35.000Z
#!/usr/bin/env python """Tests for `r_freeze` package.""" import pytest from r_freeze import r_freeze def test_ok(): print("ok")
11.5
35
0.673913
22
138
4.045455
0.727273
0.235955
0
0
0
0
0
0
0
0
0
0
0.173913
138
11
36
12.545455
0.780702
0.362319
0
0
0
0
0.02439
0
0
0
0
0
0
1
0.25
true
0
0.5
0
0.75
0.25
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
1
0
1
0
0
0
0
5
ede7876a23748b110f274356bdbe6738fd5c2868
24
py
Python
__init__.py
IJMTutorSES/ftrobopy
7e41aeba7ce41b291690af252b567928024495dd
[ "MIT" ]
24
2015-10-01T21:51:25.000Z
2022-02-17T12:45:35.000Z
__init__.py
IJMTutorSES/ftrobopy
7e41aeba7ce41b291690af252b567928024495dd
[ "MIT" ]
18
2016-03-01T13:38:34.000Z
2021-12-07T22:24:46.000Z
__init__.py
IJMTutorSES/ftrobopy
7e41aeba7ce41b291690af252b567928024495dd
[ "MIT" ]
16
2016-02-12T20:24:22.000Z
2021-12-03T13:09:47.000Z
from .ftrobopy import *
12
23
0.75
3
24
6
1
0
0
0
0
0
0
0
0
0
0
0
0.166667
24
1
24
24
0.9
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
0
0
0
5
61084d27653675bb9585b94fea26ac0c03bebc68
4,071
py
Python
oldAI.py
edu-fr/checkers-AI
88973d540eb96e091ea617a7355eb8994bab68c4
[ "CC0-1.0" ]
null
null
null
oldAI.py
edu-fr/checkers-AI
88973d540eb96e091ea617a7355eb8994bab68c4
[ "CC0-1.0" ]
null
null
null
oldAI.py
edu-fr/checkers-AI
88973d540eb96e091ea617a7355eb8994bab68c4
[ "CC0-1.0" ]
null
null
null
import math from copy import deepcopy import pygame from checkers.board import Board from checkers.constants import ROWS, COLS, RED, WHITE from checkers.piece import Piece class Movement: def __init__(self, move, piece, skip): self.move = move self.piece = piece self.skip = skip def minimax(board, depth, maximizing, color, no_move_available): if depth == 0 or board.winner() is not None: value = board.get_white_left() - board.get_red_left() return value, None movement = Movement(None, None, None) if maximizing: # CPU max_value = - math.inf for row in range(ROWS): for col in range(COLS): current_piece = board.get_piece(row, col) if current_piece == 0 or current_piece.get_color() != color: continue valid_moves = board.get_valid_moves(current_piece) if valid_moves is not None: no_move_available = False for valid_move, skip in valid_moves.items(): new_board = deepcopy(board) new_Board = Board() new_Board.board = new_board new_Board.red_kings = board.red_kings new_Board.red_left = board.red_left new_Board.white_kings = board.white_kings new_Board.white_left = board.white_left new_Board.board.move(new_Board.board.get_piece(row, col), valid_move[0], valid_move[1]) if skip: new_Board.board.remove(skip) current_value = minimax(new_Board.board, depth - 1, False, WHITE if (color == RED) else RED, no_move_available) max_value = max(max_value, current_value[0]) if max_value == current_value[0]: movement.move = valid_move movement.piece = board.get_piece(row, col) movement.skip = skip if no_move_available: print("DRAW") return max_value, movement else: # CPU 2 min_value = math.inf min_move = None min_piece = None for row in range(ROWS): for col in range(COLS): current_piece = board.get_piece(row, col) if current_piece == 0 or current_piece.get_color() != color: continue valid_moves = board.get_valid_moves(current_piece) if valid_moves is not None: no_move_available = False for valid_move, skip in valid_moves.items(): new_board = deepcopy(board) new_Board = Board() new_Board.board = new_board new_Board.red_kings = board.red_kings new_Board.red_left = board.red_left new_Board.white_kings = board.white_kings new_Board.white_left = board.white_left new_Board.board.move(new_Board.board.get_piece(row, col), valid_move[0], valid_move[1]) if skip: new_Board.board.remove(skip) current_value = minimax(new_Board.board, depth - 1, True, WHITE if (color == RED) else RED, no_move_available) min_value = min(min_value, current_value[0]) if min_value == current_value[0]: movement.move = valid_move movement.piece = board.get_piece(row, col) movement.skip = skip if no_move_available: print("DRAW") return min_value, movement
44.25
116
0.507246
446
4,071
4.374439
0.139013
0.098411
0.079959
0.049206
0.735008
0.708355
0.708355
0.708355
0.708355
0.670425
0
0.005978
0.424711
4,071
91
117
44.736264
0.827071
0.002211
0
0.634146
0
0
0.001971
0
0
0
0
0
0
1
0.02439
false
0
0.073171
0
0.146341
0.02439
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
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
5
b67d3322f81d35a59eed389a6b1f5c72bcb13fb4
141
py
Python
ch04/ex6.py
gama79530/Coursera_Python_for_Everybody_2019
16a03db48accc4593dda085352f166874b39c874
[ "MIT" ]
null
null
null
ch04/ex6.py
gama79530/Coursera_Python_for_Everybody_2019
16a03db48accc4593dda085352f166874b39c874
[ "MIT" ]
null
null
null
ch04/ex6.py
gama79530/Coursera_Python_for_Everybody_2019
16a03db48accc4593dda085352f166874b39c874
[ "MIT" ]
null
null
null
def pay(hours,rate) : return hours * rate hours = float(input('Enter Hours:')) rate = float(input('Enter Rate:')) print(pay(hours,rate))
23.5
36
0.673759
21
141
4.52381
0.428571
0.378947
0.252632
0
0
0
0
0
0
0
0
0
0.141844
141
6
37
23.5
0.785124
0
0
0
0
0
0.161972
0
0
0
0
0
0
1
0.2
false
0
0
0.2
0.4
0.2
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
0
1
0
0
0
5
b6ae820e5b1ffd493dcca1c116b9036e87e194b9
100
py
Python
dnc/globals.py
Jeffrey-Ede/adaptive-scans
a4f8f0275d5f894c34f7ae9bbd64222f635fb73e
[ "MIT" ]
4
2020-12-04T22:20:46.000Z
2022-02-25T17:13:41.000Z
99/dnc/globals.py
Jeffrey-Ede/intelligent-partial-STEM
dc13e64ba3fb8266d39a260780af615b170a3c88
[ "MIT" ]
null
null
null
99/dnc/globals.py
Jeffrey-Ede/intelligent-partial-STEM
dc13e64ba3fb8266d39a260780af615b170a3c88
[ "MIT" ]
null
null
null
import numpy as np global full_scans global_full_scans = np.ones((32,96,96,1), dtype=np.float32)
25
59
0.75
19
100
3.789474
0.684211
0.277778
0.416667
0
0
0
0
0
0
0
0
0.103448
0.13
100
4
59
25
0.724138
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.333333
0
1
0
0
null
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
0
0
0
5
fcd119cabc16edc11713dbac6008e48ebed101a0
232
py
Python
web/routes/web.py
testdrivenio/masonite-on-docker
fb23e30f3dbaa9a873604c3b0da4df98884518ad
[ "MIT" ]
4
2021-03-25T14:56:07.000Z
2021-10-31T12:28:54.000Z
web/routes/web.py
testdrivenio/masonite-on-docker
fb23e30f3dbaa9a873604c3b0da4df98884518ad
[ "MIT" ]
3
2019-12-06T04:02:04.000Z
2021-05-13T09:38:44.000Z
web/routes/web.py
testdrivenio/masonite-on-docker
fb23e30f3dbaa9a873604c3b0da4df98884518ad
[ "MIT" ]
3
2020-11-14T16:55:09.000Z
2021-03-26T18:59:06.000Z
"""Web Routes.""" from masonite.routes import Get, Post ROUTES = [ Get("/", "WelcomeController@show").name("welcome"), Get("/sample", "WelcomeController@show").name("welcome"), Post("/", "WelcomeController@upload"), ]
23.2
61
0.642241
23
232
6.478261
0.565217
0.281879
0.33557
0.42953
0
0
0
0
0
0
0
0
0.133621
232
9
62
25.777778
0.741294
0.047414
0
0
0
0
0.423256
0.316279
0
0
0
0
0
1
0
false
0
0.166667
0
0.166667
0
1
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
0
0
0
0
0
0
0
5
fcde9dc7737ee3be9565ede9d56f9ea3ad37bcf9
42
py
Python
python/testData/keywordCompletion/noNonLiteralExpressionKeywordsAfterPattern.py
06needhamt/intellij-community
63d7b8030e4fdefeb4760e511e289f7e6b3a5c5b
[ "Apache-2.0" ]
null
null
null
python/testData/keywordCompletion/noNonLiteralExpressionKeywordsAfterPattern.py
06needhamt/intellij-community
63d7b8030e4fdefeb4760e511e289f7e6b3a5c5b
[ "Apache-2.0" ]
null
null
null
python/testData/keywordCompletion/noNonLiteralExpressionKeywordsAfterPattern.py
06needhamt/intellij-community
63d7b8030e4fdefeb4760e511e289f7e6b3a5c5b
[ "Apache-2.0" ]
null
null
null
match x: case [] <caret>: pass
14
20
0.452381
5
42
3.8
1
0
0
0
0
0
0
0
0
0
0
0
0.404762
42
3
21
14
0.76
0
0
0
0
0
0
0
0
0
0
0
0
0
null
null
0.333333
0
null
null
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
1
0
0
1
0
0
0
0
0
5
1e2a6103ead2c730b423e00496685bd1f2c207b7
111
py
Python
src/applications/api/models/__init__.py
luisito666/M2-API-REST
238837c2cbd0e9aadcce29def0dd9935b888047b
[ "MIT" ]
null
null
null
src/applications/api/models/__init__.py
luisito666/M2-API-REST
238837c2cbd0e9aadcce29def0dd9935b888047b
[ "MIT" ]
3
2021-04-08T19:14:52.000Z
2022-03-12T01:05:15.000Z
src/applications/api/models/__init__.py
luisito666/M2-API-REST
238837c2cbd0e9aadcce29def0dd9935b888047b
[ "MIT" ]
1
2020-12-25T20:34:09.000Z
2020-12-25T20:34:09.000Z
from .download import Download from .pages import Pages from .token import Token from .site import Site, Image
22.2
30
0.801802
17
111
5.235294
0.411765
0
0
0
0
0
0
0
0
0
0
0
0.153153
111
4
31
27.75
0.946809
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
1e31dbfdde55b50d1f1bd1689879648007126dc1
119
py
Python
bempy/django/blocks/attach/__init__.py
svetlyak40wt/bempy
ad87982d17c2d14c344d9e3d91a48c37dfb72535
[ "BSD-3-Clause" ]
1
2015-04-29T15:19:45.000Z
2015-04-29T15:19:45.000Z
bempy/django/blocks/attach/__init__.py
svetlyak40wt/bempy
ad87982d17c2d14c344d9e3d91a48c37dfb72535
[ "BSD-3-Clause" ]
null
null
null
bempy/django/blocks/attach/__init__.py
svetlyak40wt/bempy
ad87982d17c2d14c344d9e3d91a48c37dfb72535
[ "BSD-3-Clause" ]
1
2019-06-10T16:08:54.000Z
2019-06-10T16:08:54.000Z
from bempy import block @block() def attach(): return dict(button='The Button', text='The Text')
14.875
36
0.588235
15
119
4.666667
0.733333
0
0
0
0
0
0
0
0
0
0
0
0.285714
119
7
37
17
0.823529
0
0
0
0
0
0.152542
0
0
0
0
0
0
1
0.2
true
0
0.2
0.2
0.6
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
1
1
0
0
5
1ec565030ac49621a9c7db306b7a06e569e8ab57
43
py
Python
tests/__init__.py
davidmayes5/balloons-for-blinds
ae02f79cab8aa7079e12b6c9a36162b93fa04883
[ "BSD-3-Clause" ]
null
null
null
tests/__init__.py
davidmayes5/balloons-for-blinds
ae02f79cab8aa7079e12b6c9a36162b93fa04883
[ "BSD-3-Clause" ]
null
null
null
tests/__init__.py
davidmayes5/balloons-for-blinds
ae02f79cab8aa7079e12b6c9a36162b93fa04883
[ "BSD-3-Clause" ]
null
null
null
# python -m unittest tests.titlescreentests
43
43
0.837209
5
43
7.2
1
0
0
0
0
0
0
0
0
0
0
0
0.093023
43
1
43
43
0.923077
0.953488
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
5
1ee1c9735ef2617983659d05052b9fb9288161d7
143
py
Python
image_registration/matching/keypoint/__init__.py
hakaboom/image_registration
7ec286c5e81670d7599f925c5279e162804278c6
[ "Apache-2.0" ]
null
null
null
image_registration/matching/keypoint/__init__.py
hakaboom/image_registration
7ec286c5e81670d7599f925c5279e162804278c6
[ "Apache-2.0" ]
null
null
null
image_registration/matching/keypoint/__init__.py
hakaboom/image_registration
7ec286c5e81670d7599f925c5279e162804278c6
[ "Apache-2.0" ]
null
null
null
#! usr/bin/python # -*- coding:utf-8 -*- from .akaze import AKAZE from .sift import SIFT from .orb import ORB, CUDA_ORB from .surf import SURF
20.428571
30
0.713287
24
143
4.208333
0.541667
0
0
0
0
0
0
0
0
0
0
0.008333
0.160839
143
6
31
23.833333
0.833333
0.258741
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
9496a24ca6df90b4c2fb6dfe720ae23bb7dc76de
65
py
Python
dlm/models/models3D/__init__.py
romainloiseau/deep-linear-shapes
faed8e14a8f66ab1c780972f616543552295cb1e
[ "MIT" ]
20
2021-08-31T15:10:48.000Z
2021-12-01T19:25:13.000Z
dlm/models/models3D/__init__.py
romainloiseau/deep-linear-shapes
faed8e14a8f66ab1c780972f616543552295cb1e
[ "MIT" ]
null
null
null
dlm/models/models3D/__init__.py
romainloiseau/deep-linear-shapes
faed8e14a8f66ab1c780972f616543552295cb1e
[ "MIT" ]
null
null
null
from .pointnet import PointNetfeat, PointNetCls, PointNetDenseCls
65
65
0.876923
6
65
9.5
1
0
0
0
0
0
0
0
0
0
0
0
0.076923
65
1
65
65
0.95
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
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
9499d7ab22e7c763b9548cb323966aa988e3af52
74
py
Python
algomorphism/datasets/__init__.py
efth-mcl/algomorphism
5b69d19701e450020a539196215575706e7ff675
[ "MIT" ]
null
null
null
algomorphism/datasets/__init__.py
efth-mcl/algomorphism
5b69d19701e450020a539196215575706e7ff675
[ "MIT" ]
null
null
null
algomorphism/datasets/__init__.py
efth-mcl/algomorphism
5b69d19701e450020a539196215575706e7ff675
[ "MIT" ]
null
null
null
from .graph_base import GraphBaseDataset from .base import SeenUnseenBase
24.666667
40
0.864865
9
74
7
0.666667
0.31746
0
0
0
0
0
0
0
0
0
0
0.108108
74
2
41
37
0.954545
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
0
0
0
5
94d1019ab3a782460c0dacd4d74cef5f482140eb
84
py
Python
explorer/models/worker_task.py
cryptassic/dex-explorer
1588011db1666b8f1ffb6499d909e4eff3f6b09b
[ "MIT" ]
null
null
null
explorer/models/worker_task.py
cryptassic/dex-explorer
1588011db1666b8f1ffb6499d909e4eff3f6b09b
[ "MIT" ]
null
null
null
explorer/models/worker_task.py
cryptassic/dex-explorer
1588011db1666b8f1ffb6499d909e4eff3f6b09b
[ "MIT" ]
null
null
null
from typing import NamedTuple class WorkerTask(NamedTuple): block_number: int
14
29
0.785714
10
84
6.5
0.9
0
0
0
0
0
0
0
0
0
0
0
0.166667
84
5
30
16.8
0.928571
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.333333
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
5
94f653367f51b787aa7e4082641cc9ac3b00b585
64
py
Python
src/static/code_stubs/python/babylonian_square_roots.py
basimr/lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
28
2019-01-06T11:39:13.000Z
2022-02-28T03:35:55.000Z
src/static/code_stubs/python/babylonian_square_roots.py
basimr/project-lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
88
2017-04-01T15:18:36.000Z
2021-09-22T19:41:11.000Z
src/static/code_stubs/python/babylonian_square_roots.py
basimr/project-lovelace
3456e0dc2e155eda7f8e34e1cf7ad816af5c5feb
[ "MIT" ]
4
2019-08-11T14:51:16.000Z
2021-04-30T16:37:52.000Z
def babylonian_sqrt(S): # Your code goes here! return 0
16
26
0.65625
10
64
4.1
1
0
0
0
0
0
0
0
0
0
0
0.021277
0.265625
64
3
27
21.333333
0.851064
0.3125
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
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
5