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
b4d8c937ba0e831a35a6a5ca9fbccba6cea9f38e
19,161
py
Python
analysis/gameboard_test.py
SCAII/SCAII
7ab302f788556392850d104d3df6e0b4a556414d
[ "BSD-3-Clause" ]
1
2017-11-01T20:09:32.000Z
2017-11-01T20:09:32.000Z
analysis/gameboard_test.py
SCAII/SCAII
7ab302f788556392850d104d3df6e0b4a556414d
[ "BSD-3-Clause" ]
103
2017-09-14T17:04:53.000Z
2018-08-15T22:52:32.000Z
analysis/gameboard_test.py
SCAII/SCAII
7ab302f788556392850d104d3df6e0b4a556414d
[ "BSD-3-Clause" ]
6
2018-01-31T00:05:14.000Z
2020-01-29T07:01:29.000Z
import unittest from flatten import parse_line import extractionMap as extractionMap # clickGameQuadrant: "tutorial.scr,9-13-2018,13:48:5:219,1536871685219,1,1.0,userClick:473_106;region:gameArea;target:gameboardBackground;clickGameQuadrant:upperRightQuadrant,false,false,false,false,false,false" # clickEntity: "tutorial.scr,9-13-2018,12:20:54:902,1536866454902,1,1.0,userClick:515_260;region:gameArea;target:gameboard;clickEntity:friendly-Big Fort_lowerRightQuadrant_200_198,false,false,false,false,false,false" # hideEntityTooltips: "tutorial.scr,9-13-2018,12:15:3:802,1536866103802,1,1.0,hideEntityTooltips:all,false,false,false,false,false,false" # showEntityTooltip: "tutorial.scr,9-13-2018,12:15:4:83,1536866104083,1,1.0,showEntityTooltip:friendly-City_lowerLeftQuadrant,false,false,false,false,false,false" class TestFlatteningGameboard(unittest.TestCase): def test_clickGameQuadrant(self): line = "tutorial.scr,9-13-2018,13:48:5:219,1536871685219,1,1.0,userClick:473_106;region:gameArea;target:gameboardBackground;clickGameQuadrant:upperRightQuadrant,false,false,false,false,false,false" extraction_map = extractionMap.get_extraction_map() obj = parse_line(line,extraction_map) self.assertEqual(obj["stepIntoDecisionPoint"], "NA") self.assertEqual(obj["showQuestion"], "NA") self.assertEqual(obj["hideEntityTooltips"], "NA") self.assertEqual(obj["showEntityTooltip.entityInfo"], "NA") self.assertEqual(obj["showEntityTooltip.tipQuadrant"], "NA") self.assertEqual(obj["startMouseOverSaliencyMap"], "NA") self.assertEqual(obj["endMouseOverSaliencyMap"], "NA") self.assertEqual(obj["waitForResearcherStart"], "NA") self.assertEqual(obj["waitForResearcherEnd"], "NA") self.assertEqual(obj["userClick"], "yes") self.assertEqual(obj["userClick.coordX"], "473") self.assertEqual(obj["userClick.coordY"], "106") self.assertEqual(obj["userClick.region"], "gameArea") self.assertEqual(obj["userClick.target"], "gameboardBackground") self.assertEqual(obj["userClick.answerQuestion.clickStep"], "NA") self.assertEqual(obj["userClick.answerQuestion.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer1"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer2"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.fileName"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.date"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.time"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.1970Sec"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.decisionPoint"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.region"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.timelineClick"], "NA") self.assertEqual(obj["userClick.jumpToDecisionPoint"], "NA") self.assertEqual(obj["userClick.clickTimeLineBlocker"], "NA") self.assertEqual(obj["userClick.play"], "NA") self.assertEqual(obj["userClick.pause"], "NA") self.assertEqual(obj["userClick.touchStepProgressLabel"], "NA") self.assertEqual(obj["userClick.clickGameQuadrant"], "upperRightQuadrant") self.assertEqual(obj["userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.clickActionLabel"], "NA") self.assertEqual(obj["userClick.clickActionLabelDenied"], "NA") self.assertEqual(obj["userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.touchCumRewardLabel"], "NA") self.assertEqual(obj["userClick.touchCumRewardValueFor"], "NA") def test_clickEntity(self): # "fileName,date,time,1970Sec,decisionPoint,questionId,OMIT,userClick.coordX,userClick.coordY,OMIT,userClick.region,OMIT,userClick.target,OMIT,userClick.clickEntity.clickGameEntity,userClick.clickEntity.clickQuadrant,userClick.clickEntity.coordX,userClick.clickEntity.coordY" line = "tutorial.scr,9-13-2018,12:20:54:902,1536866454902,1,1.0,userClick:515_260;region:gameArea;target:gameboard;clickEntity:friendly-Big Fort_lowerRightQuadrant_200_198,false,false,false,false,false,false" extraction_map = extractionMap.get_extraction_map() obj = parse_line(line,extraction_map) self.assertEqual(obj["stepIntoDecisionPoint"], "NA") self.assertEqual(obj["showQuestion"], "NA") self.assertEqual(obj["hideEntityTooltips"], "NA") self.assertEqual(obj["showEntityTooltip.entityInfo"], "NA") self.assertEqual(obj["showEntityTooltip.tipQuadrant"], "NA") self.assertEqual(obj["startMouseOverSaliencyMap"], "NA") self.assertEqual(obj["endMouseOverSaliencyMap"], "NA") self.assertEqual(obj["waitForResearcherStart"], "NA") self.assertEqual(obj["waitForResearcherEnd"], "NA") self.assertEqual(obj["userClick"], "yes") self.assertEqual(obj["userClick.coordX"], "515") self.assertEqual(obj["userClick.coordY"], "260") self.assertEqual(obj["userClick.region"], "gameArea") self.assertEqual(obj["userClick.target"], "gameboard") self.assertEqual(obj["userClick.answerQuestion.clickStep"], "NA") self.assertEqual(obj["userClick.answerQuestion.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer1"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer2"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.fileName"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.date"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.time"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.1970Sec"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.decisionPoint"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.region"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.timelineClick"], "NA") self.assertEqual(obj["userClick.jumpToDecisionPoint"], "NA") self.assertEqual(obj["userClick.clickTimeLineBlocker"], "NA") self.assertEqual(obj["userClick.play"], "NA") self.assertEqual(obj["userClick.pause"], "NA") self.assertEqual(obj["userClick.touchStepProgressLabel"], "NA") self.assertEqual(obj["userClick.clickGameQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.clickGameEntity"], "friendly-Big Fort") self.assertEqual(obj["userClick.clickEntity.clickQuadrant"], "lowerRightQuadrant") self.assertEqual(obj["userClick.clickEntity.coordX"], "200") self.assertEqual(obj["userClick.clickEntity.coordY"], "198") self.assertEqual(obj["userClick.clickActionLabel"], "NA") self.assertEqual(obj["userClick.clickActionLabelDenied"], "NA") self.assertEqual(obj["userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.touchCumRewardLabel"], "NA") self.assertEqual(obj["userClick.touchCumRewardValueFor"], "NA") def test_hideEntityTooltips(self): line = "tutorial.scr,9-13-2018,12:15:3:802,1536866103802,1,1.0,hideEntityTooltips:all,false,false,false,false,false,false" extraction_map = extractionMap.get_extraction_map() obj = parse_line(line, extraction_map) self.assertEqual(obj["stepIntoDecisionPoint"], "NA") self.assertEqual(obj["showQuestion"], "NA") self.assertEqual(obj["hideEntityTooltips"], "all") self.assertEqual(obj["showEntityTooltip.entityInfo"], "NA") self.assertEqual(obj["showEntityTooltip.tipQuadrant"], "NA") self.assertEqual(obj["startMouseOverSaliencyMap"], "NA") self.assertEqual(obj["endMouseOverSaliencyMap"], "NA") self.assertEqual(obj["waitForResearcherStart"], "NA") self.assertEqual(obj["waitForResearcherEnd"], "NA") self.assertEqual(obj["userClick"], "NA") self.assertEqual(obj["userClick.coordX"], "NA") self.assertEqual(obj["userClick.coordY"], "NA") self.assertEqual(obj["userClick.region"], "NA") self.assertEqual(obj["userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.clickStep"], "NA") self.assertEqual(obj["userClick.answerQuestion.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer1"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer2"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.fileName"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.date"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.time"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.1970Sec"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.decisionPoint"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.region"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.timelineClick"], "NA") self.assertEqual(obj["userClick.jumpToDecisionPoint"], "NA") self.assertEqual(obj["userClick.clickTimeLineBlocker"], "NA") self.assertEqual(obj["userClick.play"], "NA") self.assertEqual(obj["userClick.pause"], "NA") self.assertEqual(obj["userClick.touchStepProgressLabel"], "NA") self.assertEqual(obj["userClick.clickGameQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.clickActionLabel"], "NA") self.assertEqual(obj["userClick.clickActionLabelDenied"], "NA") self.assertEqual(obj["userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.touchCumRewardLabel"], "NA") self.assertEqual(obj["userClick.touchCumRewardValueFor"], "NA") def test_showEntityTooltip(self): line = "tutorial.scr,9-13-2018,12:15:4:83,1536866104083,1,1.0,showEntityTooltip:friendly-City_lowerLeftQuadrant,false,false,false,false,false,false" extraction_map = extractionMap.get_extraction_map() obj = parse_line(line, extraction_map) self.assertEqual(obj["stepIntoDecisionPoint"], "NA") self.assertEqual(obj["showQuestion"], "NA") self.assertEqual(obj["hideEntityTooltips"], "NA") self.assertEqual(obj["showEntityTooltip.entityInfo"], "friendly-City") self.assertEqual(obj["showEntityTooltip.tipQuadrant"], "lowerLeftQuadrant") self.assertEqual(obj["startMouseOverSaliencyMap"], "NA") self.assertEqual(obj["endMouseOverSaliencyMap"], "NA") self.assertEqual(obj["waitForResearcherStart"], "NA") self.assertEqual(obj["waitForResearcherEnd"], "NA") self.assertEqual(obj["userClick"], "NA") self.assertEqual(obj["userClick.coordX"], "NA") self.assertEqual(obj["userClick.coordY"], "NA") self.assertEqual(obj["userClick.region"], "NA") self.assertEqual(obj["userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.clickStep"], "NA") self.assertEqual(obj["userClick.answerQuestion.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer1"], "NA") self.assertEqual(obj["userClick.answerQuestion.answer2"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.fileName"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.date"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.time"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.1970Sec"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.decisionPoint"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.questionId"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.region"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.target"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.answerQuestion.userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.timelineClick"], "NA") self.assertEqual(obj["userClick.jumpToDecisionPoint"], "NA") self.assertEqual(obj["userClick.clickTimeLineBlocker"], "NA") self.assertEqual(obj["userClick.play"], "NA") self.assertEqual(obj["userClick.pause"], "NA") self.assertEqual(obj["userClick.touchStepProgressLabel"], "NA") self.assertEqual(obj["userClick.clickGameQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickEntity.clickQuadrant"], "NA") self.assertEqual(obj["userClick.clickEntity.coordX"], "NA") self.assertEqual(obj["userClick.clickEntity.coordY"], "NA") self.assertEqual(obj["userClick.clickActionLabel"], "NA") self.assertEqual(obj["userClick.clickActionLabelDenied"], "NA") self.assertEqual(obj["userClick.selectedRewardBar"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickGameEntity"], "NA") self.assertEqual(obj["userClick.clickSaliencyMap.clickQuadrant"], "NA") self.assertEqual(obj["userClick.touchCumRewardLabel"], "NA") self.assertEqual(obj["userClick.touchCumRewardValueFor"], "NA")
64.952542
283
0.711132
1,854
19,161
7.329558
0.056095
0.247259
0.296711
0.297299
0.953933
0.945691
0.935463
0.934579
0.934579
0.933402
0
0.019918
0.135327
19,161
295
284
64.952542
0.800278
0.057408
0
0.893443
0
0.016393
0.481668
0.416593
0
0
0
0
0.918033
1
0.016393
false
0
0.012295
0
0.032787
0
0
0
0
null
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
null
0
0
0
1
0
0
0
0
0
0
0
0
0
12
b4e3bf6253ede20c52a94a9d23acd2b218c739e2
214
py
Python
src/scoot/src/behaviors/scout/__init__.py
BCLab-UNM/SC2
3e476a529ca9c6c650b921a749ae496671cca6a8
[ "MIT" ]
null
null
null
src/scoot/src/behaviors/scout/__init__.py
BCLab-UNM/SC2
3e476a529ca9c6c650b921a749ae496671cca6a8
[ "MIT" ]
null
null
null
src/scoot/src/behaviors/scout/__init__.py
BCLab-UNM/SC2
3e476a529ca9c6c650b921a749ae496671cca6a8
[ "MIT" ]
null
null
null
# Import behavior modules into the behavior namespace from . import search from . import searchRandomWalk from . import fine_search from . import DDSA from . import goto_waypoint from . import goto_repair_station
23.777778
53
0.813084
29
214
5.862069
0.517241
0.352941
0.188235
0
0
0
0
0
0
0
0
0
0.154206
214
8
54
26.75
0.939227
0.238318
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
3705c150c4d90b69e9ffdc5b268f88fe7f32603f
25,553
py
Python
los/analyze/ellipse_grid/scripts/data.py
phil-mansfield/shellfish
91b0b8216276969aacc66b09bbfbb5251218e57e
[ "MIT" ]
12
2016-12-07T17:57:07.000Z
2021-12-10T22:48:53.000Z
los/analyze/ellipse_grid/scripts/data.py
phil-mansfield/shellfish
91b0b8216276969aacc66b09bbfbb5251218e57e
[ "MIT" ]
48
2016-12-04T03:48:24.000Z
2021-08-08T16:34:24.000Z
los/analyze/ellipse_grid/scripts/data.py
phil-mansfield/shellfish
91b0b8216276969aacc66b09bbfbb5251218e57e
[ "MIT" ]
5
2019-02-25T15:14:22.000Z
2020-10-10T07:43:37.000Z
import numpy as np acs = np.array([ 0.2, 0.2276, 0.2552, 0.2828, 0.3103, 0.3379, 0.3655, 0.3931, 0.4207, 0.4483, 0.4759, 0.5034, 0.531, 0.5586, 0.5862, 0.6138, 0.6414, 0.669, 0.6966, 0.7241, 0.7517, 0.7793, 0.8069, 0.8345, 0.8621, 0.8897, 0.9172, 0.9448, 0.9724, 1, ]) bcs = np.array([ 0.2, 0.2276, 0.2552, 0.2828, 0.3103, 0.3379, 0.3655, 0.3931, 0.4207, 0.4483, 0.4759, 0.5034, 0.531, 0.5586, 0.5862, 0.6138, 0.6414, 0.669, 0.6966, 0.7241, 0.7517, 0.7793, 0.8069, 0.8345, 0.8621, 0.8897, 0.9172, 0.9448, 0.9724, 1, ]) ac_grid = np.array([ 0.8342, 0.8233, 0.8138, 0.8086, 0.8004, 0.793, 0.7917, 0.7834, 0.783, 0.7803, 0.7775, 0.7732, 0.7727, 0.7715, 0.7693, 0.7677, 0.766, 0.7651, 0.7637, 0.764, 0.7618, 0.762, 0.7615, 0.76, 0.7599, 0.7594, 0.7583, 0.7575, 0.759, 0.7569, 0, 0.8392, 0.8275, 0.8203, 0.8145, 0.8058, 0.8048, 0.7991, 0.7957, 0.793, 0.7883, 0.7873, 0.7836, 0.7824, 0.7799, 0.7799, 0.7787, 0.778, 0.7762, 0.774, 0.7745, 0.7721, 0.7706, 0.7705, 0.7711, 0.7691, 0.7694, 0.7684, 0.7679, 0.7671, 0, 0, 0.8433, 0.832, 0.8275, 0.8211, 0.8156, 0.8133, 0.8075, 0.8057, 0.8024, 0.7972, 0.7972, 0.7951, 0.7925, 0.7889, 0.7897, 0.7879, 0.7864, 0.7855, 0.7842, 0.7833, 0.7817, 0.7819, 0.7806, 0.779, 0.779, 0.7782, 0.7759, 0.7776, 0, 0, 0, 0.848, 0.8396, 0.8329, 0.8291, 0.8253, 0.8199, 0.8157, 0.8134, 0.8115, 0.8082, 0.8048, 0.803, 0.8016, 0.8001, 0.7975, 0.7974, 0.7957, 0.7943, 0.7938, 0.7918, 0.7928, 0.7909, 0.79, 0.7905, 0.7899, 0.7885, 0.7878, 0, 0, 0, 0, 0.8528, 0.846, 0.8417, 0.8353, 0.8317, 0.8268, 0.8249, 0.8215, 0.8199, 0.8175, 0.8133, 0.8134, 0.8114, 0.8102, 0.808, 0.8064, 0.8048, 0.8045, 0.8037, 0.8022, 0.8014, 0.8011, 0.7999, 0.8005, 0.799, 0.7985, 0, 0, 0, 0, 0, 0.8577, 0.8524, 0.8482, 0.8419, 0.8397, 0.8364, 0.8317, 0.8302, 0.8278, 0.8264, 0.8239, 0.8213, 0.8195, 0.8196, 0.8182, 0.8158, 0.8156, 0.8143, 0.8121, 0.8122, 0.8126, 0.81, 0.8084, 0.8097, 0.8087, 0, 0, 0, 0, 0, 0, 0.8649, 0.8582, 0.8545, 0.8508, 0.8465, 0.8445, 0.842, 0.8383, 0.8371, 0.8333, 0.8335, 0.8306, 0.8309, 0.828, 0.8272, 0.8253, 0.8242, 0.8236, 0.8222, 0.8211, 0.8216, 0.8207, 0.8194, 0.8193, 0, 0, 0, 0, 0, 0, 0, 0.8698, 0.8637, 0.8587, 0.8584, 0.8545, 0.852, 0.8485, 0.848, 0.8455, 0.8433, 0.8424, 0.8397, 0.8387, 0.8361, 0.8351, 0.835, 0.8335, 0.8327, 0.8322, 0.8299, 0.831, 0.8297, 0.829, 0, 0, 0, 0, 0, 0, 0, 0, 0.8751, 0.8711, 0.8693, 0.8651, 0.8622, 0.8596, 0.8565, 0.856, 0.8518, 0.8526, 0.8501, 0.8475, 0.8471, 0.8449, 0.8458, 0.8447, 0.8427, 0.8428, 0.8405, 0.8405, 0.8393, 0.8396, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8803, 0.8777, 0.8728, 0.8728, 0.8685, 0.8667, 0.8657, 0.8638, 0.8618, 0.86, 0.8594, 0.8579, 0.8573, 0.8545, 0.8544, 0.8537, 0.8517, 0.8521, 0.8506, 0.8501, 0.8491, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8873, 0.8813, 0.8815, 0.8795, 0.8764, 0.8751, 0.8723, 0.8719, 0.8698, 0.8675, 0.8664, 0.8667, 0.8654, 0.8629, 0.8631, 0.8592, 0.8608, 0.8589, 0.8587, 0.8604, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8932, 0.8904, 0.8892, 0.8867, 0.8836, 0.8832, 0.8804, 0.8783, 0.8768, 0.8763, 0.8757, 0.8736, 0.8717, 0.8711, 0.8716, 0.8696, 0.8679, 0.8692, 0.8687, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8985, 0.8958, 0.8941, 0.8927, 0.8912, 0.8892, 0.8879, 0.8881, 0.8849, 0.8853, 0.8823, 0.8819, 0.8815, 0.8805, 0.8786, 0.8779, 0.8771, 0.8782, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9054, 0.9033, 0.901, 0.9006, 0.8995, 0.8958, 0.8958, 0.893, 0.8928, 0.8917, 0.8918, 0.89, 0.8882, 0.8891, 0.8872, 0.8858, 0.8867, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9125, 0.9098, 0.9073, 0.9066, 0.9047, 0.9039, 0.9015, 0.9031, 0.8996, 0.8998, 0.8976, 0.896, 0.8965, 0.896, 0.8961, 0.8952, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9177, 0.9169, 0.9147, 0.9142, 0.9115, 0.9114, 0.9095, 0.9087, 0.9084, 0.9068, 0.9069, 0.9061, 0.9047, 0.9035, 0.9031, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.923, 0.9214, 0.9191, 0.9197, 0.9168, 0.9188, 0.9174, 0.9152, 0.9166, 0.9139, 0.9129, 0.914, 0.9129, 0.9119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9302, 0.9286, 0.9269, 0.9262, 0.9267, 0.9244, 0.9238, 0.9236, 0.9232, 0.9204, 0.9215, 0.9211, 0.9195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9359, 0.9342, 0.9336, 0.932, 0.9314, 0.9323, 0.9308, 0.93, 0.9291, 0.9284, 0.9272, 0.9279, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.942, 0.9409, 0.9386, 0.9388, 0.9379, 0.9377, 0.937, 0.936, 0.9351, 0.9342, 0.9361, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.949, 0.9459, 0.9463, 0.9462, 0.944, 0.9431, 0.944, 0.9442, 0.9436, 0.9426, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9542, 0.9524, 0.9533, 0.9521, 0.9526, 0.9506, 0.9497, 0.9509, 0.9488, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9596, 0.9595, 0.9579, 0.9577, 0.9573, 0.9579, 0.9574, 0.9566, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9659, 0.9645, 0.9644, 0.9643, 0.9633, 0.9631, 0.9647, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9705, 0.9716, 0.9705, 0.9706, 0.9707, 0.9705, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9789, 0.9765, 0.9784, 0.9768, 0.977, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9838, 0.9847, 0.9836, 0.9832, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9893, 0.9881, 0.9885, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9942, 0.9943, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.001, ]) bc_grid = np.array([ 0.8328, 0.8513, 0.8631, 0.8787, 0.8897, 0.8969, 0.9096, 0.9142, 0.9261, 0.9333, 0.9403, 0.9423, 0.9509, 0.9559, 0.9603, 0.9641, 0.9663, 0.9705, 0.9757, 0.9784, 0.9802, 0.9843, 0.9877, 0.9881, 0.9914, 0.9922, 0.9939, 0.9966, 1, 1.001, 0, 0.8388, 0.8501, 0.8639, 0.8774, 0.8853, 0.8999, 0.9082, 0.9162, 0.9231, 0.9289, 0.9395, 0.9437, 0.949, 0.9542, 0.9607, 0.9654, 0.9695, 0.9733, 0.9754, 0.9802, 0.9803, 0.9841, 0.9857, 0.9906, 0.9914, 0.9947, 0.997, 0.9974, 1.002, 0, 0, 0.8422, 0.8527, 0.8667, 0.8779, 0.8896, 0.8996, 0.9069, 0.9176, 0.9249, 0.9302, 0.9378, 0.9447, 0.9487, 0.9524, 0.9605, 0.9631, 0.9677, 0.9727, 0.9737, 0.9792, 0.9809, 0.9864, 0.9884, 0.991, 0.9942, 0.9944, 0.9945, 1.002, 0, 0, 0, 0.8473, 0.8584, 0.8695, 0.8816, 0.8932, 0.9005, 0.9092, 0.9167, 0.9253, 0.9312, 0.9363, 0.9418, 0.9485, 0.9541, 0.9604, 0.9648, 0.9686, 0.9726, 0.9768, 0.9799, 0.9847, 0.9864, 0.9893, 0.9952, 0.9977, 0.9979, 1.001, 0, 0, 0, 0, 0.8525, 0.8642, 0.8756, 0.8845, 0.8941, 0.9012, 0.9114, 0.9189, 0.9263, 0.9331, 0.938, 0.9467, 0.9507, 0.957, 0.9603, 0.9653, 0.9706, 0.9745, 0.9786, 0.9812, 0.985, 0.9889, 0.991, 0.9965, 0.997, 1.001, 0, 0, 0, 0, 0, 0.8568, 0.8692, 0.8808, 0.8861, 0.8971, 0.9071, 0.9134, 0.9213, 0.9293, 0.9364, 0.9415, 0.9469, 0.9525, 0.9581, 0.9641, 0.9673, 0.9707, 0.9771, 0.9795, 0.9854, 0.9869, 0.9915, 0.9923, 0.998, 1.003, 0, 0, 0, 0, 0, 0, 0.8639, 0.8738, 0.8829, 0.8929, 0.9011, 0.9082, 0.9182, 0.9234, 0.9324, 0.9371, 0.946, 0.9509, 0.9561, 0.9608, 0.9662, 0.9709, 0.9735, 0.9788, 0.983, 0.9875, 0.9913, 0.9944, 0.996, 1.001, 0, 0, 0, 0, 0, 0, 0, 0.869, 0.8789, 0.8861, 0.8967, 0.9055, 0.9129, 0.9204, 0.9297, 0.935, 0.9426, 0.9481, 0.9522, 0.9583, 0.9624, 0.9689, 0.9732, 0.9774, 0.9818, 0.9868, 0.9882, 0.9932, 0.9971, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0.8747, 0.8839, 0.8944, 0.9017, 0.9112, 0.917, 0.9243, 0.9326, 0.9374, 0.9475, 0.9509, 0.9565, 0.9619, 0.9664, 0.9727, 0.9774, 0.9802, 0.9854, 0.9873, 0.9928, 0.9956, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8791, 0.8901, 0.8967, 0.9083, 0.915, 0.9225, 0.9297, 0.9364, 0.9427, 0.9502, 0.9556, 0.9605, 0.9664, 0.9718, 0.9761, 0.9808, 0.9842, 0.9903, 0.9927, 0.9975, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8869, 0.8936, 0.9052, 0.9122, 0.9191, 0.9276, 0.9329, 0.9414, 0.9458, 0.9528, 0.9584, 0.9659, 0.9703, 0.9744, 0.9797, 0.9822, 0.9872, 0.9916, 0.9965, 1.003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8929, 0.9022, 0.9102, 0.9179, 0.9243, 0.933, 0.9384, 0.9456, 0.9511, 0.9579, 0.9641, 0.9688, 0.973, 0.9781, 0.9848, 0.9885, 0.9907, 0.9968, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.8972, 0.9068, 0.9145, 0.9219, 0.931, 0.9376, 0.9435, 0.951, 0.955, 0.9634, 0.9668, 0.9729, 0.9774, 0.9827, 0.9868, 0.9896, 0.9967, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9045, 0.9134, 0.92, 0.9291, 0.9346, 0.9423, 0.9489, 0.9534, 0.9606, 0.9669, 0.9732, 0.9763, 0.9803, 0.9876, 0.991, 0.9937, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9117, 0.9188, 0.926, 0.9333, 0.941, 0.948, 0.9523, 0.961, 0.9649, 0.9714, 0.9755, 0.9796, 0.9862, 0.9915, 0.995, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9167, 0.9241, 0.9326, 0.9383, 0.9464, 0.9533, 0.9591, 0.9644, 0.9711, 0.9762, 0.9822, 0.9868, 0.9908, 0.9945, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9222, 0.9312, 0.9366, 0.9438, 0.9501, 0.9587, 0.964, 0.9701, 0.9757, 0.9797, 0.9843, 0.9916, 0.9958, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9297, 0.936, 0.9431, 0.9499, 0.9573, 0.962, 0.969, 0.9741, 0.9812, 0.9848, 0.9896, 0.9958, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9351, 0.9422, 0.9486, 0.9552, 0.9628, 0.9689, 0.9731, 0.9803, 0.9856, 0.9903, 0.9952, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9407, 0.9486, 0.9546, 0.9624, 0.966, 0.974, 0.9799, 0.984, 0.9891, 0.9952, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9481, 0.9536, 0.9611, 0.9673, 0.9714, 0.9785, 0.9838, 0.9898, 0.9936, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9531, 0.9612, 0.9676, 0.9725, 0.9786, 0.9841, 0.9898, 0.9947, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9585, 0.9662, 0.972, 0.978, 0.9839, 0.991, 0.9943, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9658, 0.9713, 0.9784, 0.984, 0.9886, 0.9945, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9702, 0.9778, 0.9826, 0.9899, 0.9955, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9781, 0.9832, 0.9898, 0.9955, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9829, 0.9899, 0.9945, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9886, 0.9929, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9941, 1.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ]) c_grid = np.array([ 1.137, 1.134, 1.133, 1.129, 1.129, 1.13, 1.126, 1.129, 1.125, 1.124, 1.123, 1.125, 1.123, 1.122, 1.122, 1.121, 1.122, 1.121, 1.12, 1.119, 1.12, 1.119, 1.118, 1.119, 1.118, 1.118, 1.118, 1.118, 1.116, 1.117, 0, 1.132, 1.132, 1.129, 1.126, 1.128, 1.122, 1.122, 1.121, 1.12, 1.121, 1.117, 1.118, 1.117, 1.117, 1.115, 1.114, 1.113, 1.113, 1.114, 1.112, 1.113, 1.113, 1.113, 1.111, 1.112, 1.111, 1.111, 1.111, 1.11, 0, 0, 1.128, 1.128, 1.124, 1.123, 1.121, 1.118, 1.118, 1.115, 1.114, 1.115, 1.112, 1.111, 1.111, 1.112, 1.109, 1.109, 1.108, 1.107, 1.108, 1.106, 1.107, 1.105, 1.105, 1.105, 1.104, 1.105, 1.106, 1.103, 0, 0, 0, 1.123, 1.122, 1.12, 1.117, 1.114, 1.114, 1.112, 1.111, 1.109, 1.108, 1.108, 1.107, 1.106, 1.105, 1.104, 1.103, 1.102, 1.102, 1.101, 1.101, 1.099, 1.099, 1.099, 1.097, 1.097, 1.097, 1.097, 0, 0, 0, 0, 1.118, 1.116, 1.113, 1.112, 1.11, 1.11, 1.107, 1.105, 1.103, 1.102, 1.103, 1.1, 1.099, 1.098, 1.098, 1.097, 1.096, 1.095, 1.094, 1.094, 1.094, 1.093, 1.093, 1.09, 1.091, 1.09, 0, 0, 0, 0, 0, 1.114, 1.111, 1.107, 1.108, 1.105, 1.102, 1.102, 1.1, 1.098, 1.096, 1.096, 1.095, 1.094, 1.092, 1.091, 1.091, 1.09, 1.089, 1.089, 1.087, 1.086, 1.087, 1.087, 1.085, 1.084, 0, 0, 0, 0, 0, 0, 1.107, 1.106, 1.103, 1.101, 1.1, 1.098, 1.095, 1.095, 1.092, 1.092, 1.089, 1.089, 1.087, 1.087, 1.085, 1.085, 1.084, 1.083, 1.082, 1.081, 1.08, 1.079, 1.08, 1.078, 0, 0, 0, 0, 0, 0, 0, 1.102, 1.101, 1.1, 1.096, 1.094, 1.092, 1.091, 1.087, 1.087, 1.085, 1.083, 1.083, 1.082, 1.082, 1.08, 1.079, 1.078, 1.077, 1.076, 1.076, 1.074, 1.074, 1.073, 0, 0, 0, 0, 0, 0, 0, 0, 1.097, 1.095, 1.091, 1.09, 1.088, 1.087, 1.085, 1.082, 1.083, 1.079, 1.079, 1.078, 1.076, 1.076, 1.073, 1.072, 1.072, 1.07, 1.071, 1.069, 1.069, 1.067, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.093, 1.089, 1.089, 1.084, 1.083, 1.081, 1.079, 1.077, 1.076, 1.074, 1.072, 1.071, 1.069, 1.069, 1.068, 1.066, 1.066, 1.064, 1.064, 1.063, 1.062, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.087, 1.086, 1.081, 1.079, 1.078, 1.075, 1.074, 1.071, 1.071, 1.069, 1.068, 1.065, 1.064, 1.064, 1.062, 1.063, 1.061, 1.06, 1.059, 1.056, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.081, 1.079, 1.076, 1.074, 1.073, 1.069, 1.069, 1.067, 1.066, 1.063, 1.061, 1.061, 1.06, 1.059, 1.056, 1.056, 1.056, 1.054, 1.052, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.077, 1.074, 1.072, 1.07, 1.067, 1.065, 1.063, 1.06, 1.06, 1.057, 1.057, 1.055, 1.054, 1.053, 1.052, 1.052, 1.05, 1.048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.071, 1.068, 1.067, 1.063, 1.062, 1.06, 1.058, 1.057, 1.055, 1.053, 1.051, 1.051, 1.05, 1.047, 1.047, 1.047, 1.044, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.065, 1.063, 1.062, 1.059, 1.057, 1.055, 1.054, 1.05, 1.05, 1.048, 1.048, 1.047, 1.044, 1.043, 1.042, 1.04, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.061, 1.058, 1.056, 1.054, 1.052, 1.049, 1.048, 1.047, 1.044, 1.043, 1.041, 1.04, 1.039, 1.039, 1.037, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.057, 1.054, 1.053, 1.05, 1.048, 1.044, 1.043, 1.042, 1.039, 1.039, 1.038, 1.035, 1.034, 1.033, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.051, 1.049, 1.047, 1.045, 1.042, 1.041, 1.039, 1.037, 1.035, 1.035, 1.033, 1.031, 1.03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.046, 1.044, 1.042, 1.04, 1.038, 1.035, 1.034, 1.032, 1.031, 1.03, 1.028, 1.026, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.042, 1.039, 1.038, 1.035, 1.034, 1.031, 1.03, 1.029, 1.027, 1.026, 1.023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.036, 1.036, 1.033, 1.03, 1.03, 1.028, 1.026, 1.023, 1.022, 1.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.033, 1.03, 1.028, 1.026, 1.024, 1.023, 1.021, 1.019, 1.018, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.029, 1.026, 1.024, 1.022, 1.021, 1.018, 1.017, 1.015, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.024, 1.022, 1.02, 1.018, 1.017, 1.015, 1.012, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.02, 1.017, 1.016, 1.014, 1.012, 1.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.015, 1.014, 1.011, 1.01, 1.008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.011, 1.009, 1.007, 1.005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.007, 1.006, 1.004, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.004, 1.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9997, ]) ac_grid = np.reshape(ac_grid, (30, 30)) bc_grid = np.reshape(bc_grid, (30, 30)) c_grid = np.reshape(c_grid, (30, 30))
228.151786
274
0.315658
4,254
25,553
1.893982
0.212741
0.316495
0.442721
0.549088
0.370485
0.281867
0.269207
0.229738
0.220554
0.208018
0
0.642683
0.517552
25,553
111
275
230.207207
0.01087
0
0
0.066038
0
0
0
0
0
0
0
0
0
1
0
false
0
0.009434
0
0.009434
0
0
0
1
null
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
3723f11cf724138e2dc968972f5d71ca8f990153
13,072
py
Python
ws_lock/tests/test_with_django.py
sevdog/test-websocker-user-lock
8aef3249f623e23479d61c7681e0f59909c47926
[ "MIT" ]
null
null
null
ws_lock/tests/test_with_django.py
sevdog/test-websocker-user-lock
8aef3249f623e23479d61c7681e0f59909c47926
[ "MIT" ]
null
null
null
ws_lock/tests/test_with_django.py
sevdog/test-websocker-user-lock
8aef3249f623e23479d61c7681e0f59909c47926
[ "MIT" ]
null
null
null
import threading from asgiref.sync import sync_to_async from django.test import TestCase, TransactionTestCase from django.contrib.auth import get_user_model from ..models import Item from .utils import application, websocket_connect_to_asgi, User class TestLocks(TestCase): fixtures = ['initial_setup'] @classmethod def setUpTestData(cls): print('test-setup', threading.get_ident()) cls.USERS = { username: User.objects.get_by_natural_key(username) for username in ['alice', 'bob', 'charlie', 'david'] } async def test_fetch(self): @sync_to_async def fetch(): return list(Item.objects.all()) items = await fetch() assert len(items) == 8 async def test_denied_access(self): print('test', threading.get_ident()) communicator = websocket_connect_to_asgi(application, self.USERS['david']) connected, _subprotocol = await communicator.connect() self.assertFalse(connected) await communicator.disconnect() async def test_shared_bar_baz(self): communicator_baz = websocket_connect_to_asgi(application, self.USERS['alice']) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) communicator_bar = websocket_connect_to_asgi(application, self.USERS['bob']) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 3 is FOO await communicator_bar.send_json_to({'items': [3]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': self.USERS['bob'].id, 'item': 3, 'locked': True }] # leave lock await communicator_bar.send_json_to({'items': []}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': self.USERS['bob'].id, 'item': 3, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_unshared_bar_baz(self): communicator_baz = websocket_connect_to_asgi(application, self.USERS['alice']) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) communicator_bar = websocket_connect_to_asgi(application, self.USERS['bob']) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 7 is BAZ await communicator_baz.send_json_to({'items': [7]}) assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': self.USERS['alice'].id, 'item': 7, 'locked': True }] # leave lock await communicator_baz.send_json_to({'items': []}) assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': self.USERS['alice'].id, 'item': 7, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_multiple_bar_baz(self): communicator_baz = websocket_connect_to_asgi(application, self.USERS['alice']) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) communicator_bar = websocket_connect_to_asgi(application, self.USERS['bob']) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 7 is BAZ, item 3 is FOO await communicator_baz.send_json_to({'items': [3, 7]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == [{ 'user': self.USERS['alice'].id, 'item': 3, 'locked': True }] assert received_baz == [{ 'user': self.USERS['alice'].id, 'item': 3, 'locked': True }] assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': self.USERS['alice'].id, 'item': 7, 'locked': True }] # leave lock await communicator_baz.send_json_to({'items': []}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == [{ 'user': self.USERS['alice'].id, 'item': 3, 'locked': False }] assert received_baz == [{ 'user': self.USERS['bob'].id, 'item': 3, 'locked': False }] assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': self.USERS['bob'].id, 'item': 7, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_shared_no_conflict_bar_baz(self): communicator_baz = websocket_connect_to_asgi(application, self.USERS['alice']) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) communicator_bar = websocket_connect_to_asgi(application, self.USERS['bob']) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 3 is FOO await communicator_bar.send_json_to({'items': [3]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': self.USERS['bob'].id, 'item': 3, 'locked': True }] # item 3 already locked await communicator_baz.send_json_to({'items': [3]}) assert await communicator_bar.receive_nothing() assert await communicator_baz.receive_nothing() await communicator_baz.disconnect() await communicator_bar.disconnect() class TestLocksInTransaction(TransactionTestCase): fixtures = ['initial_setup'] @sync_to_async def _get_user(self, username): return User.objects.get_by_natural_key(username) async def test_fetch(self): @sync_to_async def fetch(): return list(Item.objects.all()) items = await fetch() assert len(items) == 8 async def test_denied_access(self): print('test', threading.get_ident()) communicator = websocket_connect_to_asgi(application, await self._get_user('david')) connected, _subprotocol = await communicator.connect() self.assertFalse(connected) await communicator.disconnect() async def test_shared_bar_baz(self): user_baz = await self._get_user('alice') communicator_baz = websocket_connect_to_asgi(application, user_baz) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) user_bar = await self._get_user('bob') communicator_bar = websocket_connect_to_asgi(application, user_bar) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 3 is FOO await communicator_bar.send_json_to({'items': [3]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': user_bar.id, 'item': 3, 'locked': True }] # leave lock await communicator_bar.send_json_to({'items': []}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': user_bar.id, 'item': 3, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_unshared_bar_baz(self): user_baz = await self._get_user('alice') communicator_baz = websocket_connect_to_asgi(application, user_baz) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) user_bar = await self._get_user('bob') communicator_bar = websocket_connect_to_asgi(application, user_bar) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 7 is BAZ await communicator_baz.send_json_to({'items': [7]}) assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': user_baz.id, 'item': 7, 'locked': True }] # leave lock await communicator_baz.send_json_to({'items': []}) assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': user_baz.id, 'item': 7, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_multiple_bar_baz(self): user_baz = await self._get_user('alice') communicator_baz = websocket_connect_to_asgi(application, user_baz) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) user_bar = await self._get_user('bob') communicator_bar = websocket_connect_to_asgi(application, user_bar) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 7 is BAZ, item 3 is FOO await communicator_baz.send_json_to({'items': [3, 7]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == [{ 'user': user_baz.id, 'item': 3, 'locked': True }] assert received_baz == [{ 'user': user_baz.id, 'item': 3, 'locked': True }] assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': user_baz.id, 'item': 7, 'locked': True }] # leave lock await communicator_baz.send_json_to({'items': []}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == [{ 'user': user_baz.id, 'item': 3, 'locked': False }] assert received_baz == [{ 'user': user_baz.id, 'item': 3, 'locked': False }] assert await communicator_bar.receive_nothing() received_baz = await communicator_baz.receive_json_from() assert received_baz == [{ 'user': user_baz.id, 'item': 7, 'locked': False }] await communicator_baz.disconnect() await communicator_bar.disconnect() async def test_shared_no_conflict_bar_baz(self): user_baz = await self._get_user('alice') communicator_baz = websocket_connect_to_asgi(application, user_baz) connected, _subprotocol = await communicator_baz.connect() self.assertTrue(connected) user_bar = await self._get_user('bob') communicator_bar = websocket_connect_to_asgi(application, user_bar) connected, _subprotocol = await communicator_bar.connect() self.assertTrue(connected) # item 3 is FOO await communicator_bar.send_json_to({'items': [3]}) received_bar = await communicator_bar.receive_json_from() received_baz = await communicator_baz.receive_json_from() assert received_bar == received_baz == [{ 'user': user_bar.id, 'item': 3, 'locked': True }] # item 3 already locked await communicator_baz.send_json_to({'items': [3]}) assert await communicator_bar.receive_nothing() assert await communicator_baz.receive_nothing() await communicator_baz.disconnect() await communicator_bar.disconnect()
39.255255
92
0.630125
1,420
13,072
5.492958
0.061972
0.200513
0.117949
0.069231
0.938718
0.938718
0.938718
0.928846
0.928846
0.924487
0
0.005025
0.269278
13,072
333
93
39.255255
0.811558
0.019201
0
0.934483
0
0
0.044592
0
0
0
0
0
0.186207
1
0.013793
false
0
0.02069
0.010345
0.058621
0.010345
0
0
0
null
1
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
37262e0ad22b07ec74b73b646f37d900c45b7666
157
py
Python
torchmin/trustregion/__init__.py
dhjpolymath/pytorch-minimize
cabe819c97c707fd9f3dc31f50c4520d9c39dfc5
[ "MIT" ]
50
2021-04-18T10:32:34.000Z
2022-03-21T08:39:43.000Z
torchmin/trustregion/__init__.py
dhjpolymath/pytorch-minimize
cabe819c97c707fd9f3dc31f50c4520d9c39dfc5
[ "MIT" ]
9
2021-11-20T20:54:06.000Z
2022-03-30T15:59:21.000Z
torchmin/trustregion/__init__.py
dhjpolymath/pytorch-minimize
cabe819c97c707fd9f3dc31f50c4520d9c39dfc5
[ "MIT" ]
12
2021-06-15T19:15:08.000Z
2022-03-23T14:23:16.000Z
from .ncg import _minimize_trust_ncg from .exact import _minimize_trust_exact from .dogleg import _minimize_dogleg from .krylov import _minimize_trust_krylov
39.25
42
0.878981
23
157
5.521739
0.347826
0.440945
0.448819
0
0
0
0
0
0
0
0
0
0.095541
157
4
42
39.25
0.894366
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
2eaed3078fb0fec633e83d560c13b2a481bcdeef
13,154
py
Python
tests/integration_tests/test_command_line_options.py
Naveenaidu/moban
5a4d41546a99f66b39e7deb3e216c9238fa3b07b
[ "MIT" ]
null
null
null
tests/integration_tests/test_command_line_options.py
Naveenaidu/moban
5a4d41546a99f66b39e7deb3e216c9238fa3b07b
[ "MIT" ]
null
null
null
tests/integration_tests/test_command_line_options.py
Naveenaidu/moban
5a4d41546a99f66b39e7deb3e216c9238fa3b07b
[ "MIT" ]
null
null
null
import os import sys from shutil import copyfile from mock import patch from nose.tools import eq_, raises, assert_raises class TestCustomOptions: def setUp(self): self.config_file = "config.yaml" with open(self.config_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_file") def test_custom_options(self, fake_template_doer): test_args = [ "moban", "-c", self.config_file, "-cd", "/home/developer/configuration", "-td", "/home/developer/templates", "-t", "a.jj2", ] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "a.jj2", "config.yaml", "moban.output" ) @patch("moban.plugins.BaseEngine.render_to_file") def test_minimal_options(self, fake_template_doer): test_args = ["moban", "-c", self.config_file, "-t", "a.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "a.jj2", "config.yaml", "moban.output" ) @raises(SystemExit) def test_missing_template(self): test_args = ["moban", "-c", self.config_file] with patch.object(sys, "argv", test_args): from moban.main import main main() def tearDown(self): self.patcher1.stop() os.unlink(self.config_file) class TestOptions: def setUp(self): self.config_file = "data.yml" with open(self.config_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_file") def test_default_options(self, fake_template_doer): test_args = ["moban", "-t", "a.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "a.jj2", "data.yml", "moban.output" ) @patch("moban.plugins.BaseEngine.render_string_to_file") def test_string_template(self, fake_template_doer): string_template = "{{HELLO}}" test_args = ["moban", string_template] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( string_template, "data.yml", "moban.output" ) @raises(SystemExit) def test_no_argments(self): test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() def tearDown(self): self.patcher1.stop() os.unlink(self.config_file) @raises(Exception) def test_missing_configuration(): test_args = ["moban", "-t", "a.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() class TestNoOptions: def setUp(self): self.config_file = ".moban.yml" copyfile( os.path.join("tests", "fixtures", self.config_file), self.config_file, ) self.data_file = "data.yaml" with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command(self, fake_template_doer): test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() call_args = list(fake_template_doer.call_args[0][0]) eq_( call_args, [ ("README.rst.jj2", "data.yaml", "README.rst"), ("setup.py.jj2", "data.yaml", "setup.py"), ], ) @raises(Exception) @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command_with_missing_output(self, fake_template_doer): test_args = ["moban", "-t", "abc.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command_with_a_few_options(self, fake_template_doer): test_args = ["moban", "-t", "abc.jj2", "-o", "xyz.output"] with patch.object(sys, "argv", test_args): from moban.main import main main() call_args = list(fake_template_doer.call_args[0][0]) eq_(call_args, [("abc.jj2", "data.yaml", "xyz.output")]) @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command_with_options(self, fake_template_doer): test_args = [ "moban", "-t", "abc.jj2", "-c", "new.yml", "-o", "xyz.output", ] with patch.object(sys, "argv", test_args): from moban.main import main main() call_args = list(fake_template_doer.call_args[0][0]) eq_(call_args, [("abc.jj2", "new.yml", "xyz.output")]) @raises(Exception) def test_single_command_without_output_option(self, fake_template_doer): test_args = ["moban", "-t", "abc.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() def tearDown(self): os.unlink(self.config_file) os.unlink(self.data_file) self.patcher1.stop() class TestNoOptions2: def setUp(self): self.config_file = ".moban.yml" copyfile( os.path.join("tests", "fixtures", self.config_file), self.config_file, ) self.data_file = "data.yaml" with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command(self, fake_template_doer): test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() call_args = list(fake_template_doer.call_args[0][0]) eq_( call_args, [ ("README.rst.jj2", "data.yaml", "README.rst"), ("setup.py.jj2", "data.yaml", "setup.py"), ], ) def tearDown(self): self.patcher1.stop() os.unlink(self.config_file) os.unlink(self.data_file) class TestCustomMobanFile: def setUp(self): self.config_file = "custom-moban.txt" copyfile( os.path.join("tests", "fixtures", ".moban.yml"), self.config_file ) self.data_file = "data.yaml" with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_files") def test_single_command(self, fake_template_doer): test_args = ["moban", "-m", self.config_file] with patch.object(sys, "argv", test_args): from moban.main import main main() call_args = list(fake_template_doer.call_args[0][0]) eq_( call_args, [ ("README.rst.jj2", "data.yaml", "README.rst"), ("setup.py.jj2", "data.yaml", "setup.py"), ], ) def tearDown(self): self.patcher1.stop() os.unlink(self.config_file) os.unlink(self.data_file) class TestTemplateOption: def setUp(self): self.config_file = "custom-moban.txt" copyfile( os.path.join("tests", "fixtures", ".moban.yml"), self.config_file ) self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() @patch("moban.plugins.BaseEngine.render_to_file") def test_template_option_override_moban_file(self, fake_template_doer): test_args = ["moban", "-t", "setup.py.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "setup.py.jj2", "data.yml", "moban.output" ) @patch("moban.plugins.BaseEngine.render_to_file") def test_template_option_not_in_moban_file(self, fake_template_doer): test_args = ["moban", "-t", "foo.jj2"] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "foo.jj2", "data.yml", "moban.output" ) def tearDown(self): self.patcher1.stop() os.unlink(self.config_file) @patch("moban.plugins.verify_the_existence_of_directories") def test_duplicated_targets_in_moban_file(fake_verify): config_file = "duplicated.moban.yml" copyfile(os.path.join("tests", "fixtures", config_file), ".moban.yml") test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main assert_raises(SystemExit, main) os.unlink(".moban.yml") class TestInvalidMobanFile: def setUp(self): self.config_file = ".moban.yml" @raises(SystemExit) @patch("moban.plugins.BaseEngine.render_to_files") def test_no_configuration(self, fake_template_doer): with open(self.config_file, "w") as f: f.write("") test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() @raises(SystemExit) @patch("moban.plugins.BaseEngine.render_to_files") def test_no_configuration_2(self, fake_template_doer): with open(self.config_file, "w") as f: f.write("not: related") test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() @raises(SystemExit) @patch("moban.plugins.BaseEngine.render_to_files") def test_no_targets(self, fake_template_doer): with open(self.config_file, "w") as f: f.write("configuration: test") test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main main() def tearDown(self): os.unlink(self.config_file) class TestComplexOptions: def setUp(self): self.config_file = ".moban.yml" copyfile( os.path.join("tests", "fixtures", ".moban-2.yml"), self.config_file ) self.data_file = "data.yaml" with open(self.data_file, "w") as f: f.write("hello: world") self.patcher1 = patch( "moban.plugins.verify_the_existence_of_directories" ) self.patcher1.start() def test_single_command(self): test_args = ["moban"] with patch.object(sys, "argv", test_args): from moban.main import main with patch("moban.plugins.BaseEngine.render_to_files") as fake: main() call_args = list(fake.call_args[0][0]) eq_( call_args, [ ("README.rst.jj2", "custom-data.yaml", "README.rst"), ("setup.py.jj2", "data.yml", "setup.py"), ], ) def tearDown(self): os.unlink(self.config_file) os.unlink(self.data_file) self.patcher1.stop() class TestTemplateTypeOption: def setUp(self): self.config_file = "data.yml" with open(self.config_file, "w") as f: f.write("hello: world") @patch("moban.plugins.BaseEngine.render_to_file") def test_mako_option(self, fake_template_doer): test_args = ["moban", "-t", "a.mako"] with patch.object(sys, "argv", test_args): from moban.main import main main() fake_template_doer.assert_called_with( "a.mako", "data.yml", "moban.output" ) def tearDown(self): os.unlink(self.config_file) @raises(SystemExit) def test_version_option(): test_args = ["moban", "-v"] with patch.object(sys, "argv", test_args): from moban.main import main main()
30.662005
79
0.570929
1,542
13,154
4.653697
0.075875
0.051282
0.068283
0.057692
0.873746
0.865385
0.850753
0.836678
0.81034
0.793618
0
0.006647
0.302341
13,154
428
80
30.733645
0.775308
0
0
0.703704
0
0
0.18139
0.085601
0
0
0
0
0.025641
1
0.116809
false
0
0.079772
0
0.222222
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
2eb1d598b8587f0eb4383ebc916de7ba8a379363
6,164
py
Python
tests/AOJ/test_ITP1_8_B.py
nabetama-training/CompetitionProgrammingPractice
0801173df3992c2e78b02b383f2df9ba792cbf2f
[ "BSD-2-Clause" ]
null
null
null
tests/AOJ/test_ITP1_8_B.py
nabetama-training/CompetitionProgrammingPractice
0801173df3992c2e78b02b383f2df9ba792cbf2f
[ "BSD-2-Clause" ]
2
2020-07-04T04:19:28.000Z
2020-07-26T06:16:07.000Z
tests/AOJ/test_ITP1_8_B.py
nabetama-training/CompetitionProgrammingPractice
0801173df3992c2e78b02b383f2df9ba792cbf2f
[ "BSD-2-Clause" ]
null
null
null
import sys from io import StringIO import unittest from src.AOJ.ITP1_8_B import resolve class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_1(self): input = """123 55 1000 0 """ output = """6 10 1 """ self.assertIO(input, output) def test_2(self): input = """123434134414 999999999999999999 234823492348923949234 1134842394 12349 219349 2394295922 2134324009823984932973957384823684234729917374928374 89237497289349179374923947926525620343 8412634873268747123 2987489327983 1000000000000000000000001 0 """ output = """34 162 97 39 19 28 47 253 196 86 79 2 """ self.assertIO(input,output) def test_3(self): input = """123434134414 999999999999999999 234823492348923949234 1134842394 12349 219349 2394295922 2134324009823984932973957384823684234729917374928374 89237497289349179374923947926525620343 8412634873268747123 2987489327983 587423874100000123420402030401234230420340 10004030401010203040001023040103204023043040 8888949249823984932973957384823684234729917374928374 89237497289349179374923947926525620343 841263489823984932973957384823684234729917374928374 89237497289349179374923947926525620343 8412634873268747123 2987489327983 587423874173268747123 2987489327983 58742387419237 11112001029199101002311020374723874100746 888381001039823984932973957384823684234729917374928374 89237497289349179374923947926525620343 8412634873268747123 2987489327983 5874238741874743274972347 1 1 1 1 2 2 3 4 45 23 3 2 2 2134 111 1111111111111111111111111111111111111 13243 384 384837493 234923 2 2134 111 1111111111111111111111111111111111111 13243 384 384834837493 234923 2 2134 111 1111111111111111111111111111111111111 13243 384 384837493 234923994829374921734 23744837493 234923 2 2134 111 1111111111111111111111111111111111111 13243 384 384837493 234923994829374921734 23749234893298473274 23483274832 2384374 384 82374 9993949292939499293949293949923949394234999939492929394992939492939499239493942349999394929293949929394929394992394939423499993949292939499293949293949923949394234999234893298473274 23483274832 2384374 384 82374 9993949292939499293949293949923949394234999939492929394992939492939499239493942349999394929293949929394929394992394939423499993949292939499293949293949923949394234997493 234923994829374921734 23749234893298473274 23483274832 2384374 384 82374 99939492929394992939492939499239493942349999394929293949929394929394992394939423499993949292939499293949293949924837493 234923 2 2134 111 1111111111111111111111111111111111111 13243 384 384837493 234923994829374921734 23749234893298473274 23483274832 2384374 384 82374 9993949292939499293949293949923949394234999939492929394992939492939499239493942349999394929293949929394929394992394934837493 234923 2 2134 111 1111111111111111111111111111111111111 13243 384 384837493 234923994829374921734 23749234893298473274 23483274832 2384374 384 82374 999394929293949929394929394992394939423499993949292939499293949293949923949394234999939492929394992939492939499239493942349999394929293949929394929394992394939423499942349999394929293949929394929394992394939423499394939423499993949292939499293949293949923949394234999939492929394992939492939499239493942349 22 2 2 0 """ output = """34 162 97 39 19 28 47 253 196 86 79 102 59 294 196 270 196 86 79 99 79 70 111 274 196 86 79 127 1 1 1 1 2 2 3 4 9 5 3 2 2 10 3 37 13 15 49 23 2 10 3 37 13 15 64 23 2 10 3 37 13 15 49 104 54 23 2 10 3 37 13 15 49 104 100 46 31 15 24 1093 46 31 15 24 1032 104 100 46 31 15 24 729 23 2 10 3 37 13 15 49 104 100 46 31 15 24 757 23 2 10 3 37 13 15 49 104 100 46 31 15 24 1858 4 2 2 """ self.assertIO(input,output) def test_4(self): input = """1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1811111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111177711111111111111111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 98398798238974910987000838749823794798237497293749872398798749749874972394797979711010873 0 """ output = """1000 1029 520 """ self.assertIO(input,output)
18.735562
1,019
0.889682
387
6,164
14.155039
0.315245
0.002191
0.008762
0.049288
0.266156
0.259036
0.238773
0.200986
0.198065
0.178715
0
0.893519
0.088903
6,164
329
1,020
18.735562
0.081909
0
0
0.648903
0
0
0.859854
0.649797
0
1
0
0
0.018809
1
0.015674
false
0
0.012539
0
0.031348
0
0
0
1
null
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
1
1
null
1
0
0
0
0
0
0
0
0
0
0
0
0
7
2eddfff39bdf21fdb30979ecaced37895989ddc1
172
py
Python
tacost/__init__.py
thejasvibr/test_acoustictracking
c212b44f7359542fede0dff2513798995cde0d20
[ "MIT" ]
null
null
null
tacost/__init__.py
thejasvibr/test_acoustictracking
c212b44f7359542fede0dff2513798995cde0d20
[ "MIT" ]
null
null
null
tacost/__init__.py
thejasvibr/test_acoustictracking
c212b44f7359542fede0dff2513798995cde0d20
[ "MIT" ]
null
null
null
__version__ = "0.1.35" from tacost import simulate_LMU_playback_setup from tacost import calculate_toa from tacost import make_sim_audio from tacost import make_positions
24.571429
46
0.854651
27
172
5.037037
0.62963
0.294118
0.470588
0.294118
0
0
0
0
0
0
0
0.026316
0.116279
172
6
47
28.666667
0.868421
0
0
0
0
0
0.034884
0
0
0
0
0
0
1
0
false
0
0.8
0
0.8
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
1
0
1
0
0
7
2eef0b409293749e86d09d9351a852c83052f812
3,594
py
Python
tests/test_hc_interfaces.py
lguohan/sonic-snmpagent
0c14bcc2bb9cb35573ddcae2a23b6640db45fa01
[ "Apache-2.0" ]
null
null
null
tests/test_hc_interfaces.py
lguohan/sonic-snmpagent
0c14bcc2bb9cb35573ddcae2a23b6640db45fa01
[ "Apache-2.0" ]
null
null
null
tests/test_hc_interfaces.py
lguohan/sonic-snmpagent
0c14bcc2bb9cb35573ddcae2a23b6640db45fa01
[ "Apache-2.0" ]
null
null
null
import os import sys # noinspection PyUnresolvedReferences import tests.mock_tables.dbconnector modules_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(modules_path, 'src')) from unittest import TestCase from ax_interface.pdu import PDU from ax_interface.mib import MIBTable from sonic_ax_impl.mibs.ietf import rfc2863 class TestGetNextPDU(TestCase): @classmethod def setUpClass(cls): cls.lut = MIBTable(rfc2863.InterfaceMIBObjects) def test_get_next_alias(self): if_alias = b'\x01\x06\x10\x00\x00\x00\x00o\x00\x01\xcc4\x00\x01\xcc5\x00\x00\x000\x07\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00}\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02' pdu = PDU.decode(if_alias) resp = pdu.make_response(self.lut) print(resp) def test_get_next1(self): payload = b'\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01R\x00\x00\x01S\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02' pdu = PDU.decode(payload) resp = pdu.make_response(self.lut) print(resp) def test_get_next2(self): payload = b'\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01V\x00\x00\x01W\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01\\\x00\x00\x01]\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01b\x00\x00\x01c\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01h\x00\x00\x01i\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02' pdu = PDU.decode(payload) resp = pdu.make_response(self.lut) print(resp) def test_get_next3(self): payload = b'\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01V\x00\x00\x01W\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01\\\x00\x00\x01]\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01b\x00\x00\x01c\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02\x01\x06\x10\x00\x00\x00\x00\x17\x00\x00\x01h\x00\x00\x01i\x00\x00\x00,\x06\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x03\x02\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1f\x00\x00\x00\x02' pdu = PDU.decode(payload) resp = pdu.make_response(self.lut) print(resp)
81.681818
1,010
0.722871
760
3,594
3.384211
0.101316
0.671851
0.556376
0.275272
0.816096
0.803655
0.803655
0.796268
0.796268
0.796268
0
0.36399
0.07123
3,594
44
1,011
81.681818
0.406531
0.009738
0
0.393939
0
0.121212
0.698426
0.697583
0
1
0
0
0
1
0.151515
false
0
0.212121
0
0.393939
0.121212
0
0
0
null
1
1
1
1
1
1
1
1
1
0
1
0
0
0
1
0
1
0
0
0
0
0
1
1
null
1
0
0
0
0
0
0
0
0
0
0
0
0
15
25c55df46b9198911e8487c0ad332c9fc0bf414b
28,263
py
Python
python/test/test_BoolFunction.py
drewrisinger/tweedledum
1c331a076fa137295193a10e0ed664603ae80c21
[ "MIT" ]
7
2020-03-13T17:08:01.000Z
2021-11-17T11:43:58.000Z
python/test/test_BoolFunction.py
drewrisinger/tweedledum
1c331a076fa137295193a10e0ed664603ae80c21
[ "MIT" ]
2
2021-03-16T12:05:50.000Z
2021-03-16T13:06:47.000Z
python/test/test_BoolFunction.py
drewrisinger/tweedledum
1c331a076fa137295193a10e0ed664603ae80c21
[ "MIT" ]
8
2020-02-13T18:05:55.000Z
2021-03-16T11:12:33.000Z
#------------------------------------------------------------------------------- # Part of Tweedledum Project. This file is distributed under the MIT License. # See accompanying file /LICENSE for details. #------------------------------------------------------------------------------- import unittest from tweedledum.bool_function_compiler import BitVec, BoolFunction from python.test import examples class TestBoolFunction(unittest.TestCase): def test_constant_3bit(self): function = BoolFunction(examples.constant_3bit) self.assertEqual(function._parameters_signature, []) result = examples.constant_3bit() self.assertEqual(result, BitVec(3, '101')) def test_identity(self): function = BoolFunction(examples.identity) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1)]) result = examples.identity(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = examples.identity(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1')) def test_identity_2bit(self): function = BoolFunction(examples.identity_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2)]) for a in range(4): tmp = BitVec(2, a) result = examples.identity(tmp) self.assertEqual(result, tmp) def test_bool_not(self): function = BoolFunction(examples.bool_not) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1)]) for a in range(2): tmp = BitVec(1, a) result = examples.bool_not(tmp) self.assertEqual(result, not bool(tmp)) def test_bit_not(self): function = BoolFunction(examples.bit_not) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1)]) for a in range(2): tmp = BitVec(1, a) result = examples.bit_not(tmp) self.assertEqual(result, ~tmp) def test_bit_not_2bit(self): function = BoolFunction(examples.bit_not_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2)]) for a in range(4): tmp = BitVec(2, a) result = examples.bit_not_2bit(tmp) self.assertEqual(result, ~tmp) def test_bool_and(self): function = BoolFunction(examples.bool_and) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bool_and(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) and BitVec(1, b) self.assertEqual(result, tmp) def test_bit_and(self): function = BoolFunction(examples.bit_and) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bit_and(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) & BitVec(1, b) self.assertEqual(result, tmp) def test_bit_and_2bit(self): function = BoolFunction(examples.bit_and_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.bit_and_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) & BitVec(2, b) self.assertEqual(result, tmp) def test_bool_or(self): function = BoolFunction(examples.bool_or) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bool_or(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) self.assertEqual(result, tmp) def test_bit_or(self): function = BoolFunction(examples.bit_or) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bit_or(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) | BitVec(1, b) self.assertEqual(result, tmp) def test_bit_or_2bit(self): function = BoolFunction(examples.bit_or_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.bit_or_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) | BitVec(2, b) self.assertEqual(result, tmp) def test_bit_xor(self): function = BoolFunction(examples.bit_xor) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bit_xor(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) self.assertEqual(result, tmp) def test_bit_xor_2bit(self): function = BoolFunction(examples.bit_xor_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.bit_xor_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) ^ BitVec(2, b) self.assertEqual(result, tmp) def test_eq(self): function = BoolFunction(examples.eq) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.eq(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) == BitVec(1, b) self.assertEqual(result, tmp) def test_bit_eq_2bit(self): function = BoolFunction(examples.eq_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.eq_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) == BitVec(2, b) self.assertEqual(result, tmp) def test_ne(self): function = BoolFunction(examples.ne) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.ne(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) != BitVec(1, b) self.assertEqual(result, tmp) def test_bit_ne_2bit(self): function = BoolFunction(examples.ne_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.ne_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) != BitVec(2, b) self.assertEqual(result, tmp) class TestBoolFunctionSimulation(unittest.TestCase): def test_constant(self): function = BoolFunction(examples.constant) result = function.simulate() self.assertEqual(result, BitVec(1, '1')) def test_constant_2bit(self): function = BoolFunction(examples.constant_2bit) result = function.simulate() self.assertEqual(result, BitVec('10')) def test_constant_3bit(self): function = BoolFunction(examples.constant_3bit) result = function.simulate() self.assertEqual(result, BitVec(3, 5)) def test_constant_4bit(self): function = BoolFunction(examples.constant_4bit) result = function.simulate() self.assertEqual(result, BitVec('0000')) def test_identity(self): function = BoolFunction(examples.identity) result = function.simulate(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = function.simulate(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1')) def test_identity_2bit(self): function = BoolFunction(examples.identity_2bit) for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, tmp) def test_identity_not(self): function = BoolFunction(examples.identity_not) for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, (tmp, ~tmp)) def test_bool_not(self): function = BoolFunction(examples.bool_not) for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_bit_not(self): function = BoolFunction(examples.bit_not) for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_bit_not_2bit(self): function = BoolFunction(examples.bit_not_2bit) for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_bool_and(self): function = BoolFunction(examples.bool_and) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) and BitVec(1, b) self.assertEqual(result, tmp) def test_bit_and(self): function = BoolFunction(examples.bit_and) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) & BitVec(1, b) self.assertEqual(result, tmp) def test_bit_and_2bit(self): function = BoolFunction(examples.bit_and_2bit) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) & BitVec(2, b) self.assertEqual(result, tmp) def test_bool_or(self): function = BoolFunction(examples.bool_or) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) self.assertEqual(result, tmp) def test_bit_or(self): function = BoolFunction(examples.bit_or) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) | BitVec(1, b) self.assertEqual(result, tmp) def test_bit_or_2bit(self): function = BoolFunction(examples.bit_or_2bit) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) | BitVec(2, b) self.assertEqual(result, tmp) def test_bit_xor(self): function = BoolFunction(examples.bit_xor) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) self.assertEqual(result, tmp) def test_bit_xor_2bit(self): function = BoolFunction(examples.bit_xor_2bit) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) ^ BitVec(2, b) self.assertEqual(result, tmp) def test_eq(self): function = BoolFunction(examples.eq) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) == BitVec(1, b) self.assertEqual(result, tmp) def test_bit_eq_2bit(self): function = BoolFunction(examples.eq_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) == BitVec(2, b) self.assertEqual(result, tmp) def test_ne(self): function = BoolFunction(examples.ne) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) != BitVec(1, b) self.assertEqual(result, tmp) def test_bit_ne_2bit(self): function = BoolFunction(examples.ne_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) != BitVec(2, b) self.assertEqual(result, tmp) class TestBoolFunctionFullSimulation(unittest.TestCase): def test_identity(self): function = BoolFunction(examples.identity) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '10') result = function.simulate(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = function.simulate(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1')) def test_identity_2bit(self): function = BoolFunction(examples.identity_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 2) self.assertEqual(str(function.truth_table(output_bit=0)), '1010') self.assertEqual(str(function.truth_table(output_bit=1)), '1100') for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, tmp) def test_not(self): function = BoolFunction(examples.bool_not) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '01') for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_not_2bit(self): function = BoolFunction(examples.bit_not_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 2) self.assertEqual(str(function.truth_table(output_bit=0)), '0101') self.assertEqual(str(function.truth_table(output_bit=1)), '0011') for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_and(self): function = BoolFunction(examples.bool_and) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1000') for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) and BitVec(1, b) self.assertEqual(result, tmp) def test_and_2bit(self): function = BoolFunction(examples.bit_and_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) output0 = BitVec(16, 0xaaaa) & BitVec(16, 0xf0f0) output1 = BitVec(16, 0xcccc) & BitVec(16, 0xff00) self.assertEqual(str(function.truth_table(output_bit=0)), str(output0)) self.assertEqual(str(function.truth_table(output_bit=1)), str(output1)) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) & BitVec(2, b) self.assertEqual(result, tmp) def test_or(self): function = BoolFunction(examples.bool_or) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1110') for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) self.assertEqual(result, tmp) def test_or_2bit(self): function = BoolFunction(examples.bit_or_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) output0 = BitVec(16, 0xaaaa) | BitVec(16, 0xf0f0) output1 = BitVec(16, 0xcccc) | BitVec(16, 0xff00) self.assertEqual(str(function.truth_table(output_bit=0)), str(output0)) self.assertEqual(str(function.truth_table(output_bit=1)), str(output1)) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) | BitVec(2, b) self.assertEqual(result, tmp) def test_xor_2bit(self): function = BoolFunction(examples.bit_xor_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) output0 = BitVec(16, 0xaaaa) ^ BitVec(16, 0xf0f0) output1 = BitVec(16, 0xcccc) ^ BitVec(16, 0xff00) self.assertEqual(str(function.truth_table(output_bit=0)), str(output0)) self.assertEqual(str(function.truth_table(output_bit=1)), str(output1)) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) ^ BitVec(2, b) self.assertEqual(result, tmp) class TestBoolFunctionExpressionConstructor(unittest.TestCase): def test_identity(self): function = BoolFunction.from_expression("x") function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '10') def test_not(self): function = BoolFunction.from_expression("~x") function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '01') def test_and(self): function = BoolFunction.from_expression("x & b") function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1000') def test_or(self): function = BoolFunction.from_expression("x | b") function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1110') def test_xor(self): function = BoolFunction.from_expression("x ^ b") function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '0110') def test_de_morgan(self): function = BoolFunction.from_expression("~(~(x0 | x1) ^ (~x0 & ~x1))") function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1111') class TestBoolFunctionTTConstructor(unittest.TestCase): def test_identity(self): function = BoolFunction.from_truth_table('10') self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) result = function.simulate(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = function.simulate(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1')) def test_identity_2bit(self): function = BoolFunction.from_truth_table(['1010', '1100']) self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 2) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 2) for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp[0], tmp[1]) self.assertEqual(result, (tmp[0], tmp[1])) def test_not(self): function = BoolFunction.from_truth_table('01') self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp) def test_not_2bit(self): function = BoolFunction.from_truth_table(['0101', '0011']) self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 2) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 2) for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp[0], tmp[1]) self.assertEqual(result, (~tmp[0], ~tmp[1])) def test_and(self): function = BoolFunction.from_truth_table('1000') self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) and BitVec(1, b) self.assertEqual(result, tmp) def test_and_2bit(self): function = BoolFunction.from_truth_table(['1010000010100000', '1100110000000000']) self.assertEqual(function.num_inputs(), 4) self.assertEqual(function.num_outputs(), 2) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) for a in range(4): for b in range(4): a_bv = BitVec(2, a) b_bv = BitVec(2, b) result = function.simulate(a_bv[0], a_bv[1], b_bv[0], b_bv[1]) tmp = a_bv & b_bv self.assertEqual(result, (tmp[0], tmp[1])) def test_or(self): function = BoolFunction(examples.bool_and) function = BoolFunction.from_truth_table('1110') self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) self.assertEqual(result, tmp) def test_or_2bit(self): function = BoolFunction.from_truth_table(['1111101011111010', '1111111111001100']) self.assertEqual(function.num_inputs(), 4) self.assertEqual(function.num_outputs(), 2) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) for a in range(4): for b in range(4): a_bv = BitVec(2, a) b_bv = BitVec(2, b) result = function.simulate(a_bv[0], a_bv[1], b_bv[0], b_bv[1]) tmp = a_bv | b_bv self.assertEqual(result, (tmp[0], tmp[1])) def test_xor(self): function = BoolFunction(examples.bool_and) function = BoolFunction.from_truth_table('0110') self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) self.assertEqual(result, tmp) def test_xor_2bit(self): function = BoolFunction.from_truth_table(['0101101001011010', '0011001111001100']) self.assertEqual(function.num_inputs(), 4) self.assertEqual(function.num_outputs(), 2) self.assertEqual(function.num_input_bits(), 4) self.assertEqual(function.num_output_bits(), 2) for a in range(4): for b in range(4): a_bv = BitVec(2, a) b_bv = BitVec(2, b) result = function.simulate(a_bv[0], a_bv[1], b_bv[0], b_bv[1]) tmp = a_bv ^ b_bv self.assertEqual(result, (tmp[0], tmp[1]))
42.757943
80
0.586562
3,466
28,263
4.640219
0.030871
0.191196
0.17447
0.161661
0.961326
0.935025
0.931791
0.906672
0.8892
0.871106
0
0.03933
0.2821
28,263
660
81
42.822727
0.753327
0.009872
0
0.867572
0
0
0.008828
0
0
0
0.002573
0
0.348048
1
0.110357
false
0
0.005093
0
0.123939
0
0
0
0
null
0
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
25e9e7d1e07aa5e003762696a7c0f41db1daac94
8,176
py
Python
code/utils/write_result2html.py
Shanthika/FeatureNet
eb0a87fd202380e1ba1f62d948cfcb29248d4b47
[ "MIT" ]
170
2018-03-23T02:40:26.000Z
2022-03-26T07:25:23.000Z
code/utils/write_result2html.py
Shanthika/FeatureNet
eb0a87fd202380e1ba1f62d948cfcb29248d4b47
[ "MIT" ]
28
2018-05-22T21:20:15.000Z
2022-01-08T19:50:32.000Z
code/utils/write_result2html.py
Shanthika/FeatureNet
eb0a87fd202380e1ba1f62d948cfcb29248d4b47
[ "MIT" ]
55
2018-04-04T07:57:53.000Z
2022-03-26T03:55:32.000Z
import os import numpy as np from tqdm import tqdm from utils import pc_util from scipy.misc import imsave def write_result(): root_path = "/home/lqyu/server/proj49/PointSR_data/test_data/our_collected_data" model_names = ['1024_nonormal_generator2_2', '1024_nonormal_generator2_2_uniformloss', '1024_nonormal_generator2_2_recursive'] index_path = os.path.join("index.html") index = open(index_path, "w") index.write("<html><body><table><tr>") index.write("<th width='5%%'>name</th>") index.write("<tr><th></th>") for model in model_names: index.write("<th>%s</th>" % model) index.write("</tr>") # get sample list items = os.listdir(root_path + "/" + model_names[0]) items.sort() # mkdir model image path for model in model_names: if not os.path.exists(root_path + "/" + model + "_three_view_img/"): os.makedirs(root_path + "/" + model + "_three_view_img/") # write img to file for item in tqdm(items): index.write("<tr>") index.write("<td>%s</td>" % item) # write prediction for model in model_names: path = root_path + "/" + model +"/" + item if not os.path.exists(path): continue img_path = root_path + "/" + model + "_three_view_img/" + item img_path = img_path.replace("xyz", "png") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data, diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) index.write("</tr>") index.close() def write_result2html_benchmark(): root_path = "/home/lqyu/server/proj49/PointSR_data/test_data/our_collected_data" phase = 'surface_benchmark' input_path ="../data/"+phase+"/1024_nonuniform" gt_path = "../data/"+phase+"/4096" model_names = ['1024_nonormal_generator2_2','1024_nonormal_generator2_2_uniformloss','1024_nonormal_generator2_2_recursive'] index_path = os.path.join(root_path, phase + "_index.html") index = open(index_path, "w") index.write("<html><body><table><tr>") index.write("<th width='5%%'>name</th><th>Input</th>") index.write("<th>Refered GT</th></tr>") index.write("<tr><th></th>") for model in model_names: index.write("<th>%s</th>" % model) index.write("</tr>") # get sample list items = os.listdir(root_path + "/" + model_names[0] + "/result/" + phase) items.sort() # mkdir model image path for model in model_names: if not os.path.exists(root_path + "/" + model + "/result/" + phase + "_three_view_img/"): os.makedirs(root_path + "/" + model + "/result/" + phase + "_three_view_img/") # write img to file for item in tqdm(items): index.write("<tr>") index.write("<td>%s</td>" % item) # write input image object = item.split("_")[0] id = item.split(".")[0] path = input_path + "/%s.xyz" % (id) img_path = input_path + "_three_view_img/%s.png" % (id) if not os.path.exists(input_path + "_three_view_img/"): os.makedirs(input_path + "_three_view_img/") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) # write gt image path = gt_path + "/%s.xyz" % (id) img_path = gt_path + "_three_view_img/%s.png" % (id) if not os.path.exists(gt_path + "_three_view_img/"): os.makedirs(gt_path + "_three_view_img/") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) index.write("</tr>") index.write("<tr><th></th>") # write prediction for model in model_names: path = root_path + "/" + model + "/result/" + phase + "/" + item if not os.path.exists(path): continue img_path = root_path + "/" + model + "/result/" + phase + "_three_view_img/" + item img_path = img_path.replace("xyz", "png") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) index.write("</tr>") index.close() def write_result2html_ModelNet(): root_path = "../model" gt_path = "../data/ModelNet10_poisson_normal" #gt_path = "../data/Patches" model_names = ['1024_generator2_2','new_1024_generator2_2','new_1024_generator2_2_fixed_lr'] phase = 'test' index_path = os.path.join(root_path, phase + "_index.html") index = open(index_path, "w") index.write("<html><body><table><tr>") index.write("<th width='5%%'>name</th><th>Input</th>") index.write("<th>Refered GT</th></tr>") index.write("<tr><th></th>") for model in model_names: index.write("<th>%s</th>" % model) index.write("</tr>") # get sample list items = os.listdir(root_path + "/" + model_names[0] + "/result/" + phase) items.sort() # mkdir model image path for model in model_names: if not os.path.exists(root_path + "/" + model + "/result/" + phase + "_three_view_img/"): os.makedirs(root_path + "/" + model + "/result/" + phase + "_three_view_img/") # write img to file for item in tqdm(items[::25]): index.write("<tr>") index.write("<td>%s</td>" % item) # write input image object = item.split("_")[0] id = item.split(".")[0] fixed = "%s/1024_nonuniform/%s" % (gt_path, 'train') path = fixed + "/%s.xyz" % (id) img_path = fixed + "_three_view_img/%s.png" % (id) if not os.path.exists(fixed + "_three_view_img/"): os.makedirs(fixed + "_three_view_img/") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) # write gt image fixed = "%s/4096/%s" % (gt_path, 'train') path = fixed + "/%s.xyz" % (id) img_path = fixed + "_three_view_img/%s.png" % (id) if not os.path.exists(fixed + "_three_view_img/"): os.makedirs(fixed + "_three_view_img/") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) index.write("</tr>") index.write("<tr><th></th>") # write prediction for model in model_names: path = root_path + "/" + model + "/result/" + phase + "/" + item if not os.path.exists(path): continue img_path = root_path + "/" + model + "/result/" + phase + "_three_view_img/" + item img_path = img_path.replace("xyz", "png") if not os.path.exists(img_path): data = np.loadtxt(path) data = data[:, 0:3] img = pc_util.point_cloud_three_views(data,diameter=8) imsave(img_path, img) index.write("<td><img width='100%%', src='%s'></td>" % img_path) index.write("</tr>") index.close() if __name__ == '__main__': write_result2html_ModelNet() #write_result2html_benchmark() #calculate_emd_error('ModelNet40')
38.748815
128
0.564579
1,085
8,176
4.024885
0.103226
0.084726
0.057706
0.042821
0.905656
0.900847
0.881154
0.869476
0.861461
0.861461
0
0.022682
0.266634
8,176
210
129
38.933333
0.705637
0.045988
0
0.768293
0
0
0.226221
0.088046
0
0
0
0
0
1
0.018293
false
0
0.030488
0
0.04878
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
d350c9bd37e15e9fb55a638f73096954a2c01ada
122
py
Python
xflask/wtforms/__init__.py
sotheara-leang/xFlask
b6899d4b6d1bdc4acfd812bfa8807e2cba7e8df0
[ "MIT" ]
2
2020-02-11T08:29:49.000Z
2020-02-17T10:24:36.000Z
xflask/wtforms/__init__.py
sotheara-leang/xFlask
b6899d4b6d1bdc4acfd812bfa8807e2cba7e8df0
[ "MIT" ]
null
null
null
xflask/wtforms/__init__.py
sotheara-leang/xFlask
b6899d4b6d1bdc4acfd812bfa8807e2cba7e8df0
[ "MIT" ]
null
null
null
from wtforms import * from flask_wtf.file import * from xflask.wtforms.field import * from xflask.wtforms.form import *
17.428571
34
0.778689
18
122
5.222222
0.5
0.319149
0.340426
0.489362
0
0
0
0
0
0
0
0
0.147541
122
6
35
20.333333
0.903846
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
d39a17c6a801cf1b62f226c19b03d7df967ca93d
70
py
Python
foronoi/tree/__init__.py
Smart-Ag/voronoi_diagram_generator
a68aac565a5e59c577eeb05471afeabd1905071e
[ "MIT" ]
null
null
null
foronoi/tree/__init__.py
Smart-Ag/voronoi_diagram_generator
a68aac565a5e59c577eeb05471afeabd1905071e
[ "MIT" ]
null
null
null
foronoi/tree/__init__.py
Smart-Ag/voronoi_diagram_generator
a68aac565a5e59c577eeb05471afeabd1905071e
[ "MIT" ]
null
null
null
from foronoi.tree.node import Node from foronoi.tree.tree import Tree
23.333333
34
0.828571
12
70
4.833333
0.416667
0.37931
0.517241
0
0
0
0
0
0
0
0
0
0.114286
70
2
35
35
0.935484
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
9fa3ffaafe08636c1c9412f7ad2b778621a4338d
3,128
py
Python
runtime/components/Basic_Arithmetic/test_divide.py
ulise/hetida-designer
a6be8eb45abf950d5498e3ca756ea1d2e46b5c00
[ "MIT" ]
41
2020-11-18T10:12:29.000Z
2022-03-28T21:46:41.000Z
runtime/components/Basic_Arithmetic/test_divide.py
ulise/hetida-designer
a6be8eb45abf950d5498e3ca756ea1d2e46b5c00
[ "MIT" ]
4
2020-12-08T15:28:15.000Z
2022-02-01T11:40:17.000Z
runtime/components/Basic_Arithmetic/test_divide.py
ulise/hetida-designer
a6be8eb45abf950d5498e3ca756ea1d2e46b5c00
[ "MIT" ]
14
2020-11-18T11:39:17.000Z
2022-03-21T15:05:11.000Z
import pandas as pd from .divide import main def test_numeric(): assert main(a=16.0, b=4.0)["quotient"] == 4.0 def test_s_numeric(): assert main( a=pd.Series( { "2019-08-01T15:20:12": 1.2, "2019-08-01T15:44:12": None, "2019-08-03T16:20:15": 0.3, "2019-08-05T12:00:34": 0.5, } ), b=-2, )["quotient"].equals( pd.Series( { "2019-08-01T15:20:12": -0.6, "2019-08-01T15:44:12": None, "2019-08-03T16:20:15": -0.15, "2019-08-05T12:00:34": -0.25, } ) ) def test_s_basic(): assert main( a=pd.Series( { "2019-08-01T15:20:12": 1.25, "2019-08-01T15:44:12": None, "2019-08-03T16:20:15": 0.25, "2019-08-05T12:00:34": 0.5, } ), b=pd.Series( { "2019-08-01T15:20:12": 1.0, "2019-08-01T15:44:12": 1.25, "2019-08-03T16:20:15": 0.25, "2019-08-05T12:00:34": 2.0, } ), )["quotient"].equals( pd.Series( { "2019-08-01T15:20:12": 1.25, "2019-08-01T15:44:12": None, "2019-08-03T16:20:15": 1.0, "2019-08-05T12:00:34": 0.25, } ) ) def test_df_basic(): assert main( a=pd.DataFrame( { "a": { "2019-08-01T15:20:12": 1.5, "2019-08-01T15:44:12": 7.5, "2019-08-03T16:20:15": 0.5, "2019-08-05T12:00:34": 0.5, }, "b": { "2019-08-01T15:20:12": 7.25, "2019-08-01T15:44:12": 7.0, "2019-08-03T16:20:15": 7.5, "2019-08-05T12:00:34": 7.5, }, } ), b=pd.DataFrame( { "a": { "2019-08-01T15:20:12": 1.5, "2019-08-01T15:44:12": 7.5, "2019-08-03T16:20:15": 0.5, "2019-08-05T12:00:34": 0.5, }, "b": { "2019-08-01T15:20:12": 7.25, "2019-08-01T15:44:12": 7.0, "2019-08-03T16:20:15": 7.5, "2019-08-05T12:00:34": 7.5, }, } ), )["quotient"].equals( pd.DataFrame( { "a": { "2019-08-01T15:20:12": 1.0, "2019-08-01T15:44:12": 1.0, "2019-08-03T16:20:15": 1.0, "2019-08-05T12:00:34": 1.0, }, "b": { "2019-08-01T15:20:12": 1.0, "2019-08-01T15:44:12": 1.0, "2019-08-03T16:20:15": 1.0, "2019-08-05T12:00:34": 1.0, }, } ) )
27.438596
49
0.335678
379
3,128
2.751979
0.110818
0.253116
0.232023
0.137105
0.885906
0.863854
0.862895
0.862895
0.835091
0.741131
0
0.449622
0.492327
3,128
113
50
27.681416
0.207179
0
0
0.542857
0
0
0.279412
0
0
0
0
0
0.038095
1
0.038095
true
0
0.019048
0
0.057143
0
0
0
0
null
1
1
0
1
1
1
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
11
9fbb38c823953621f20cce6d52150ffc1e941522
4,627
py
Python
gentelella/app/api/restaurants/get.py
Dhvani35729/Trofi-Dashboard
a49b4cbac964e60ea3124e4808ba88ef7256a8fe
[ "MIT" ]
null
null
null
gentelella/app/api/restaurants/get.py
Dhvani35729/Trofi-Dashboard
a49b4cbac964e60ea3124e4808ba88ef7256a8fe
[ "MIT" ]
null
null
null
gentelella/app/api/restaurants/get.py
Dhvani35729/Trofi-Dashboard
a49b4cbac964e60ea3124e4808ba88ef7256a8fe
[ "MIT" ]
null
null
null
from django.http import JsonResponse from ...constants import DISCOUNT_INCREMENT def get_all_restaurants_with_hours(db, active=True): res_ref = db.collection(u'restaurants').where( u'is_active', u'==', True).get() # import pdb # pdb.set_trace() all_hours = [] for i in range(24): all_hours.append({"key": str(i), "data": []}) for res in res_ref: # print(u'{} => {}'.format(res.id, res.to_dict())) res_public_data = res.to_dict() hours_ref = db.collection(u'restaurants').document(res.id).collection( u'hours').where(u'start_id', u'>=', res_public_data["opening_hour"]).where(u'start_id', u'<=', res_public_data["closing_hour"]) if active: hours_ref = hours_ref.where(u'is_active', u'==', True) hours_ref = hours_ref.get() for hour in hours_ref: # print(u'{} => {}'.format(hour.id, hour.to_dict())) hour_data = hour.to_dict() current_discount = 0 next_discount = 0 current_contribution = 0 all_discounts = hour_data["discounts"] max_discount = hour_data["max_discount"] max_discount_reached = False for discount in sorted(all_discounts): if all_discounts[discount]["is_active"] is True: current_discount = float(discount.replace("_", ".")) current_contribution = all_discounts[discount]["current_contributed"] if max_discount != current_discount: next_discount = current_discount + DISCOUNT_INCREMENT else: max_discount_reached = True next_discount = max_discount break hour_id = int(hour_data["start_id"]) res_card = { "hour_id": hour_id, "key": res.id, "name": res_public_data["name"], "tags": res_public_data["tags"], "needed_contribution": hour_data["needed_contribution"], "current_discount": current_discount, "next_discount": next_discount, "max_discount_reached": max_discount_reached, "current_contribution": current_contribution, } all_hours[hour_id]["data"].append(res_card) return JsonResponse({"list": all_hours}) def get_all_restaurants_with_hour(db, hour_id, active=True): res_ref = db.collection(u'restaurants').where( u'is_active', u'==', True).get() all_hours = {"key": str(hour_id), "data": []} for res in res_ref: # print(u'{} => {}'.format(res.id, res.to_dict())) res_public_data = res.to_dict() hours_ref = db.collection(u'restaurants').document(res.id).collection( u'hours').where(u'start_id', u'==', int(hour_id)) if active: hours_ref = hours_ref.where(u'is_active', u'==', True) hours_ref = hours_ref.get() for hour in hours_ref: # print(u'{} => {}'.format(hour.id, hour.to_dict())) hour_data = hour.to_dict() current_discount = 0 next_discount = 0 current_contribution = 0 all_discounts = hour_data["discounts"] max_discount = hour_data["max_discount"] max_discount_reached = False for discount in sorted(all_discounts): if all_discounts[discount]["is_active"] is True: current_discount = float(discount.replace("_", ".")) current_contribution = all_discounts[discount]["current_contributed"] if max_discount != current_discount: next_discount = current_discount + DISCOUNT_INCREMENT else: max_discount_reached = True next_discount = max_discount break hour_id = int(hour_data["start_id"]) res_card = { "hour_id": hour_id, "key": res.id, "name": res_public_data["name"], "tags": res_public_data["tags"], "needed_contribution": hour_data["needed_contribution"], "current_discount": current_discount, "next_discount": next_discount, "max_discount_reached": max_discount_reached, "current_contribution": current_contribution, } all_hours["data"].append(res_card) return JsonResponse(all_hours)
38.558333
139
0.558461
507
4,627
4.769231
0.134122
0.072787
0.043011
0.026468
0.906534
0.886683
0.857734
0.857734
0.841191
0.841191
0
0.002558
0.323968
4,627
119
140
38.882353
0.77046
0.048844
0
0.822222
0
0
0.127902
0
0
0
0
0
0
1
0.022222
false
0
0.022222
0
0.066667
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
9fbb4cc9de7036906b065b57c1df2842b81a1b3a
191
py
Python
config.py
Mobin-khorushi/tradebot
44f559c5de1d262bfb4a1db0ead617db4c5d23f1
[ "Apache-2.0" ]
null
null
null
config.py
Mobin-khorushi/tradebot
44f559c5de1d262bfb4a1db0ead617db4c5d23f1
[ "Apache-2.0" ]
null
null
null
config.py
Mobin-khorushi/tradebot
44f559c5de1d262bfb4a1db0ead617db4c5d23f1
[ "Apache-2.0" ]
null
null
null
WEBHOOK_PASS="letsmakethisourpassword" API_KEY="BpKCfUiCLoDj0SuLcLmKqpenmvLpu4Rk7RHnW2xHJU9ik9mN8WUQZb4nsg0yDbTu" API_SECRET="U1HxoxdeaX8syDSrZMcuu0SLReerK8VZvaZ4OD3KDsX7PMlixd8W5fa7Q7XDbhM8"
63.666667
77
0.942408
9
191
19.666667
0.888889
0
0
0
0
0
0
0
0
0
0
0.111111
0.010471
191
3
77
63.666667
0.825397
0
0
0
0
0
0.786458
0.786458
0
1
0
0
0
1
0
false
0.333333
0
0
0
0
1
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
null
1
0
0
0
0
0
0
1
0
0
0
0
0
7
4cc93a7102c4c23fc4151b9bc3a476fe9dd62941
10,508
py
Python
apimaster/migrations/0001_initial.py
romsha28/hospital_python
1bb86266223df5084321917169156aaec1c5e318
[ "Apache-2.0" ]
null
null
null
apimaster/migrations/0001_initial.py
romsha28/hospital_python
1bb86266223df5084321917169156aaec1c5e318
[ "Apache-2.0" ]
1
2021-10-18T08:56:11.000Z
2021-10-18T08:56:11.000Z
apimaster/migrations/0001_initial.py
romsha28/hospital_python
1bb86266223df5084321917169156aaec1c5e318
[ "Apache-2.0" ]
null
null
null
# Generated by Django 3.2.8 on 2021-11-26 10:39 from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Address', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('user_id', models.IntegerField(blank=True)), ('subject', models.CharField(blank=True, default='Home Address', max_length=150)), ('locality', models.CharField(blank=True, max_length=100)), ('address', models.CharField(blank=True, max_length=100)), ('address2', models.CharField(blank=True, max_length=100)), ('city', models.CharField(blank=True, max_length=100)), ('state', models.CharField(blank=True, max_length=100)), ('country', models.CharField(blank=True, max_length=100)), ('pincode', models.IntegerField(blank=True)), ('latitude_coordinate', models.CharField(blank=True, max_length=100)), ('longitude_coordinate', models.CharField(blank=True, max_length=100)), ('status', models.BooleanField(default=False)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], options={ 'verbose_name': 'Address', }, ), migrations.CreateModel( name='UserProfiles', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, max_length=100)), ('title', models.CharField(blank=True, default='General User', max_length=120)), ('about', models.TextField(blank=True)), ('description', models.TextField(blank=True)), ('dob', models.DateField(auto_now_add=True)), ('occupation', models.CharField(choices=[('patient', 'Patient'), ('doctor', 'Doctor'), ('other', 'Other')], default='patient', max_length=20)), ('photo', models.CharField(blank=True, max_length=100)), ('sex', models.CharField(choices=[('male', 'Male'), ('female', 'Female'), ('other', 'Other')], default='male', max_length=20)), ('email', models.EmailField(max_length=254, unique=True)), ('mobile', models.CharField(blank=True, max_length=20)), ('mobile1', models.CharField(blank=True, max_length=20)), ('blood_group', models.CharField(blank=True, max_length=50)), ('locality', models.CharField(blank=True, max_length=100)), ('address', models.CharField(blank=True, max_length=100)), ('address2', models.CharField(blank=True, max_length=100)), ('city', models.CharField(blank=True, max_length=100)), ('state', models.CharField(blank=True, max_length=100)), ('country', models.CharField(blank=True, max_length=100)), ('pincode', models.IntegerField(blank=True)), ('latitude_coordinate', models.CharField(blank=True, max_length=100)), ('longitude_coordinate', models.CharField(blank=True, max_length=100)), ('users_id', models.IntegerField(blank=True)), ('profile_id', models.IntegerField(blank=True)), ('status', models.BooleanField(default=False)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], ), migrations.CreateModel( name='UsersAchievements', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, default='Issues text', max_length=150)), ('subject', models.CharField(blank=True, default='subject text', max_length=150)), ('description', models.TextField(blank=True)), ('univercity', models.CharField(blank=True, max_length=150)), ('college', models.CharField(blank=True, max_length=150)), ('bord', models.CharField(blank=True, max_length=150)), ('grade', models.IntegerField(blank=True)), ('file', models.CharField(blank=True, max_length=150)), ('status', models.BooleanField(default=False)), ('user_id', models.IntegerField(blank=True)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], options={ 'verbose_name': 'UsersIssues', }, ), migrations.CreateModel( name='UsersEducations', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, default='Issues text', max_length=150)), ('subject', models.CharField(blank=True, default='subject text', max_length=150)), ('description', models.TextField(blank=True)), ('univercity', models.CharField(blank=True, max_length=150)), ('college', models.CharField(blank=True, max_length=150)), ('bord', models.CharField(blank=True, max_length=150)), ('grade', models.IntegerField(blank=True)), ('file', models.CharField(blank=True, max_length=150)), ('user_id', models.IntegerField(blank=True)), ('status', models.BooleanField(default=False)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], options={ 'verbose_name': 'UsersIssues', }, ), migrations.CreateModel( name='UsersIssues', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, default='Issues text', max_length=150)), ('subject', models.CharField(blank=True, default='subject text', max_length=150)), ('description', models.TextField(blank=True)), ('issues_id', models.IntegerField(blank=True)), ('user_id', models.IntegerField(blank=True)), ('status', models.BooleanField(default=False)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], options={ 'verbose_name': 'UsersIssues', }, ), migrations.CreateModel( name='UsersSpecializations', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, default='Issues text', max_length=150)), ('subject', models.CharField(blank=True, default='subject text', max_length=150)), ('description', models.TextField(blank=True)), ('univercity', models.CharField(blank=True, max_length=150)), ('college', models.CharField(blank=True, max_length=150)), ('bord', models.CharField(blank=True, max_length=150)), ('grade', models.IntegerField(blank=True)), ('file', models.CharField(blank=True, max_length=150)), ('status', models.BooleanField(default=False)), ('user_id', models.IntegerField(blank=True)), ('is_deleted', models.BooleanField(default=False)), ('created_by', models.IntegerField(blank=True)), ('updated_by', models.IntegerField(blank=True)), ('deleted_by', models.IntegerField(blank=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('updated_at', models.DateTimeField(auto_now_add=True)), ('deleted_at', models.DateTimeField(auto_now_add=True)), ], options={ 'verbose_name': 'UsersIssues', }, ), ]
58.055249
159
0.574515
1,015
10,508
5.8
0.107389
0.122303
0.146085
0.175302
0.881773
0.86071
0.843044
0.823
0.823
0.823
0
0.019775
0.273316
10,508
180
160
58.377778
0.751179
0.004282
0
0.797688
1
0
0.129816
0
0
0
0
0
0
1
0
false
0
0.011561
0
0.034682
0
0
0
0
null
0
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
9
e266039bbbcd6e3039bb300d2339dbd7eae824b5
93
py
Python
models/policy/__init__.py
danilonumeroso/role
921c625f2675e8dab9e70d5ae0492f36ed189bd2
[ "MIT" ]
1
2021-06-24T16:30:45.000Z
2021-06-24T16:30:45.000Z
models/policy/__init__.py
danilonumeroso/chess-rl
921c625f2675e8dab9e70d5ae0492f36ed189bd2
[ "MIT" ]
null
null
null
models/policy/__init__.py
danilonumeroso/chess-rl
921c625f2675e8dab9e70d5ae0492f36ed189bd2
[ "MIT" ]
null
null
null
from .decaying_eps_greedy import DecayingEpsilonGreedy from .eps_greedy import EpsilonGreedy
31
54
0.892473
11
93
7.272727
0.636364
0.225
0.375
0
0
0
0
0
0
0
0
0
0.086022
93
2
55
46.5
0.941176
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
2c4d0ba10e65041d74d830e19a945cb53e224681
2,794
py
Python
predictions_writer.py
MANASLU8/tf_ner
fd23d7bb33383458571cf90de0a815e49698b53b
[ "Apache-2.0" ]
null
null
null
predictions_writer.py
MANASLU8/tf_ner
fd23d7bb33383458571cf90de0a815e49698b53b
[ "Apache-2.0" ]
null
null
null
predictions_writer.py
MANASLU8/tf_ner
fd23d7bb33383458571cf90de0a815e49698b53b
[ "Apache-2.0" ]
1
2020-01-19T16:29:51.000Z
2020-01-19T16:29:51.000Z
from pathlib import Path import functools def write_predictions(name, input_fn, fwords, ftags, generator_fn, estimator): Path('results/score').mkdir(parents=True, exist_ok=True) with Path('results/score/{}.preds.txt'.format(name)).open('wb') as f: test_inpf = functools.partial(input_fn, fwords(name), ftags(name)) golds_gen = generator_fn(fwords(name), ftags(name)) preds_gen = estimator.predict(test_inpf) for golds, preds in zip(golds_gen, preds_gen): ((words, _), tags) = golds for word, tag, tag_pred in zip(words, tags, preds['tags']): f.write(b' '.join([word, tag_pred]) + b'\n') f.write(b'\n') def write_predictions_conv(name, input_fn, fwords, ftags, generator_fn, estimator): Path('results/score').mkdir(parents=True, exist_ok=True) with Path('results/score/{}.preds.txt'.format(name)).open('wb') as f: test_inpf = functools.partial(input_fn, fwords(name), ftags(name)) golds_gen = generator_fn(fwords(name), ftags(name)) preds_gen = estimator.predict(test_inpf) for golds, preds in zip(golds_gen, preds_gen): ((words, _), (_, _)), tags = golds for word, tag, tag_pred in zip(words, tags, preds['tags']): f.write(b' '.join([word, tag_pred]) + b'\n') f.write(b'\n') def write_predictions_conv_ema(name, mode, input_fn, fwords, ftags, generator_fn, estimator): Path('results/score').mkdir(parents=True, exist_ok=True) with Path('results/score/{}.{}.preds.txt'.format(name, mode)).open('wb') as f: test_inpf = functools.partial(input_fn, fwords(name), ftags(name)) golds_gen = generator_fn(fwords(name), ftags(name)) preds_gen = estimator.predict(test_inpf) for golds, preds in zip(golds_gen, preds_gen): ((words, _), (_, _)), tags = golds for word, tag, tag_pred in zip(words, tags, preds[mode]): f.write(b' '.join([word, tag_pred]) + b'\n') f.write(b'\n') def write_predictions_ema(name, mode, input_fn, fwords, ftags, generator_fn, estimator): Path('results/score').mkdir(parents=True, exist_ok=True) with Path('results/score/{}.{}.preds.txt'.format(name, mode)).open('wb') as f: test_inpf = functools.partial(input_fn, fwords(name), ftags(name)) golds_gen = generator_fn(fwords(name), ftags(name)) preds_gen = estimator.predict(test_inpf) for golds, preds in zip(golds_gen, preds_gen): ((words, _), tags) = golds for word, tag, tag_pred in zip(words, tags, preds[mode]): f.write(b' '.join([word, tag_pred]) + b'\n') f.write(b'\n')
54.784314
93
0.607731
382
2,794
4.267016
0.13089
0.058896
0.063804
0.083436
0.966258
0.966258
0.966258
0.966258
0.966258
0.966258
0
0
0.238368
2,794
50
94
55.88
0.765977
0
0
0.869565
0
0
0.070866
0.03937
0
0
0
0
0
1
0.086957
false
0
0.043478
0
0.130435
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
2c60f702544bdeb805947bb2bec1957126bf8417
171
py
Python
ibsng/handler/ras/get_ras_descriptions.py
ParspooyeshFanavar/pyibsng
d48bcf4f25e3f23461528bf0ff8870cc3d537444
[ "MIT" ]
6
2018-03-06T10:16:36.000Z
2021-12-05T12:43:10.000Z
ibsng/handler/ras/get_ras_descriptions.py
ParspooyeshFanavar/pyibsng
d48bcf4f25e3f23461528bf0ff8870cc3d537444
[ "MIT" ]
3
2018-03-06T10:27:08.000Z
2022-01-02T15:21:27.000Z
ibsng/handler/ras/get_ras_descriptions.py
ParspooyeshFanavar/pyibsng
d48bcf4f25e3f23461528bf0ff8870cc3d537444
[ "MIT" ]
3
2018-01-06T16:28:31.000Z
2018-09-17T19:47:19.000Z
"""Get ras description API method.""" from ibsng.handler.handler import Handler class getRasDescriptions(Handler): """Get ras description method class.""" pass
19
43
0.725146
20
171
6.2
0.6
0.096774
0.274194
0
0
0
0
0
0
0
0
0
0.163743
171
8
44
21.375
0.867133
0.380117
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0.333333
0.333333
0
0.666667
0
1
0
0
null
0
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
1
0
0
7
3929c913a134895fafd19baa1b23d8d29964ca03
97
py
Python
pythonProject1/chap2/demo12.py
zhudi7/pythonAK
d52995a4c35a3c9aeb1542922e9d786f4dcc8d1c
[ "Apache-2.0" ]
null
null
null
pythonProject1/chap2/demo12.py
zhudi7/pythonAK
d52995a4c35a3c9aeb1542922e9d786f4dcc8d1c
[ "Apache-2.0" ]
null
null
null
pythonProject1/chap2/demo12.py
zhudi7/pythonAK
d52995a4c35a3c9aeb1542922e9d786f4dcc8d1c
[ "Apache-2.0" ]
null
null
null
# 公众号:MarkerJava # 开发时间:2020/10/5 17:25 print(153 % 10) print(153 // 10 % 10) print(153 // 100)
13.857143
22
0.628866
18
97
3.388889
0.611111
0.393443
0.327869
0
0
0
0
0
0
0
0
0.3625
0.175258
97
6
23
16.166667
0.4
0.360825
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0
0
0
1
1
0
0
null
1
1
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
8
1a458de4970c6e88db33bcdeb2a6316bf3e67cb1
112
py
Python
tests/RDkit/__init__.py
niladell/DockStream
75f06d24a95699cdc06fe1ea021e213e1d9fa5b3
[ "Apache-2.0" ]
34
2021-08-05T06:28:30.000Z
2022-03-17T02:42:49.000Z
tests/RDkit/__init__.py
niladell/DockStream
75f06d24a95699cdc06fe1ea021e213e1d9fa5b3
[ "Apache-2.0" ]
9
2021-08-31T10:35:51.000Z
2022-02-03T08:57:58.000Z
tests/RDkit/__init__.py
niladell/DockStream
75f06d24a95699cdc06fe1ea021e213e1d9fa5b3
[ "Apache-2.0" ]
10
2021-08-12T02:32:11.000Z
2022-01-19T11:51:33.000Z
from tests.RDkit.test_RDkit_ligand_preparation import * from tests.RDkit.test_RDkit_stereo_enumeration import *
37.333333
55
0.875
16
112
5.75
0.5625
0.195652
0.304348
0.391304
0.5
0
0
0
0
0
0
0
0.071429
112
2
56
56
0.884615
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
1a52a103d1856c66f88ae0087a7d8a0e8f0e8e1c
89
py
Python
compsim/generate/__init__.py
skyman/CompressionSimulator
b484f41845aa16e3e3e057a1d7739909d0dff0df
[ "MIT" ]
null
null
null
compsim/generate/__init__.py
skyman/CompressionSimulator
b484f41845aa16e3e3e057a1d7739909d0dff0df
[ "MIT" ]
null
null
null
compsim/generate/__init__.py
skyman/CompressionSimulator
b484f41845aa16e3e3e057a1d7739909d0dff0df
[ "MIT" ]
null
null
null
# coding=utf-8 from randgen import generate_random_grid, generate_random_separation_grid
29.666667
73
0.876404
13
89
5.615385
0.769231
0.383562
0
0
0
0
0
0
0
0
0
0.012195
0.078652
89
2
74
44.5
0.878049
0.134831
0
0
1
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
1
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
1ac425f1f2c726d364ec29964862548e267bf110
173,663
py
Python
FAD_Result.py
Sameerpython/Bindingdata
e13d1c152339117ee33e6084da3f34aae222dbcd
[ "MIT" ]
null
null
null
FAD_Result.py
Sameerpython/Bindingdata
e13d1c152339117ee33e6084da3f34aae222dbcd
[ "MIT" ]
null
null
null
FAD_Result.py
Sameerpython/Bindingdata
e13d1c152339117ee33e6084da3f34aae222dbcd
[ "MIT" ]
null
null
null
#!/usr/bin/python # Import modules for CGI handling import cgi, cgitb import webbrowser import urllib import urllib2 import re import sys, os from itertools import izip import requests from bs4 import BeautifulSoup import numpy as np import pandas as pd from collections import Counter import matplotlib import matplotlib.pyplot as plt import uuid from Bio.Seq import Seq from Bio import motifs import string from Bio.Alphabet import IUPAC from zipfile import ZipFile # Create instance of FieldStorage form = cgi.FieldStorage() print "Content-type:text/html\r\n\r\n" print "<html>" print "<head>" print "<style>" print """ * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } .grid { background: white; margin: 0 0 20px 0; } .grid:after { /* Or @extend clearfix */ content: ""; display: table; clear: both; } [class*='col-'] { float: left; padding-right: 20px; } .grid [class*='col-']:last-of-type { padding-right: 0; } .col-2-3 { width: 33.33%; overflow: scroll; } .col-1-3 { width: 33.33%; overflow: scroll; } .module { padding: 20px; background: #eee; } body { padding: 10px 50px 200px; background-size: 300px 300px; } h1 { color: white; } h1 em { color: #666; font-size: 16px; } """ ############# #style for printing image side by side print """ .weblogo_column { float: left; width: 33.33%; padding: 2px; } /* Clearfix (clear floats) */ .weblogo_row::after { content: ""; clear: both; display: table; } """ ############ ######style for collapsible content### print """ .collapsible { background-color: #777; color: white; cursor: pointer; padding: 18px; width: 100%; border: none; text-align: left; outline: none; font-size: 15px; } .active, .collapsible:hover { background-color: #555; } .contentsection { padding: 0 18px; display: none; overflow: scroll; background-color: #f1f1f1; } """ ############End of style for collapsible content### #style for divindg into 2 columns print "* {box-sizing: border-box;}" print ".column {float: left;width: 50%;padding: 10px;height: 300px;}" print ".row:after {content: "";display: table;clear: both;}" #END of style for divindg into 2 columns print "</style>" print "<body>" # Substructure Atom Information for PCHILIDE ligand Nicot=sorted(['O2','C2','N1','C10','C4X','C4','N3','O4','N10','C9A','C5X','N5', 'C9','C8','C7','C6','C8M','C7M']) Ribitol=sorted(["O5'","C5'","C4'","O4'","C3'","O3'","C2'", "02'", "C1'"]) phosphate=sorted(['PA','O2A','O1A','O3P','P','O1P','O2P']) Ribose=sorted(['O5B','C5B','C4B','O4B','C1B','C2B','O2B','C3B','O3B']) Adenin=sorted(['N6','N1','C2','N3','C4','C5','C6','N7','C8','N9']) #SUbstructure section ends here # Information of the selected ligands and PDB ids from LigPage.py variable = "" value = "" r = "" value_dict={} lig_sel=[] for key in form.keys(): variable = str(key) # print "The selected Ligand for PDBID:%s" %variable value = str(form.getvalue(variable)) # print "is", value value_dict.setdefault('%s'%variable,[]).append(value) r += "<p>"+ variable +", "+ value +"</p>\n" print "<p style='font-size:20px; color:blue'> Results for the following selected PDBID's and Ligands: ",'\n'.join("{}:{}".format(k,v) for k,v in value_dict.items()),"</p>","<br/>" pdbsum_URL="http://www.ebi.ac.uk/thornton-srv/databases/cgi-bin/pdbsum/GetPage.pl?pdbcode=" pdbsum_URL2="&template=links.html" #DIctionary and List pdbsum_dict={} PDBID_LIST=[] #Title for Page Title="The Results are for the following selected PDBID's and Ligands:" #print Title.center(100,' '),"<br/>" #Preparing PdbSum Url with selected PDB ids for ids,lig in value_dict.iteritems(): pdbsumurl=pdbsum_URL+ids+pdbsum_URL2 lig_sel.append(lig) pdbsum_dict.setdefault('%s'%ids,[]).append(pdbsumurl) #print "PDBSUMDICT", pdbsum_dict,"<br/>","<br/>" #creating a list for PDB ids for id,url in pdbsum_dict.iteritems(): PDBID_LIST.append(id) #print "PDBID LIST", PDBID_LIST, "<br/>" #Extracting the Href links from PDBSum home page for the selected PDB ids and Ligands using BeautifulSoup litems=[] new=[] items2=[] new1=[] lig_link=[] finalLIG_link=[] liginte_set=set() ligintelist=[] link_set=set() for id,url in pdbsum_dict.iteritems(): #print id, url, "<br/>" for link in url: html_page=requests.get(link) soup = BeautifulSoup(html_page.text,'html.parser') ligand_name_items=soup.find_all('a') for items in ligand_name_items: name=items.contents[0] links='www.ebi.ac.uk' + items.get('href') text=str(name)+ " " + str(links) litems.append(text) #Looping over the extracted URLs from PDBSum and appending into a lIst called New for x in litems: x=x.strip() new.append(x) #print new #Looping over Ligand and PDBSum Urls (from above step) to extract the PDBSUm URL for the seleted Ligand Page in PDBSUm. The Ligand Page URL is now as a SET data type ligand_urlLIST=[] for lig in lig_sel: #print "LIGAND", lig, "<br/>" for y in new: lig= ''.join(lig) if y.startswith(lig):#y=y.split() y=y.split() link=y[1] link1="http://"+link #print link1 ligand_urlLIST.append(link1) link_set.add(link1) link_setlist=list(link_set) #print ligand_urlLIST #print "SET",link_setlist, "<br/>" #Using Beautifulsoup to extract all the links from PDBSUM Ligand interaction Page for each of the PDB ids. #print PDBID_LIST PDBID_URL_dict=zip(PDBID_LIST,ligand_urlLIST) LiginteractPage=dict(PDBID_URL_dict) #print "what1", LiginteractPage, "<br/>" #print "what2", PDBID_URL_dict for pdbid,pdbsumlink in LiginteractPage.iteritems(): links=list(LiginteractPage.viewvalues()) for y in links: html_page2=requests.get(y) soup2 = BeautifulSoup(html_page2.text,'html.parser') ligand_name_items1=soup2.find_all('a') #Looping over all the href links from PDBSUM ligand intercation page to extract #URL(Final page for extracting atom details) for the atom based interaction for PDB ids with ligands for items in ligand_name_items1: name=items.contents[0] links='www.ebi.ac.uk' + items.get('href') text=str(links) items2.append(text) for i in items2: # print i final=i.split() final=''.join(final) #print final, "<br/>" if 'thornton-srv/databases/cgi-bin/pdbsum/GetLigInt.pl?pdb=' in final: finalLIG_link.append(final) lastitem=finalLIG_link[-1] lastitem="http://"+lastitem # print lastitem,"<br/>" if lastitem not in ligintelist: ligintelist.append(lastitem) liginte_set.add(lastitem) liginte_list=list(liginte_set) #print "LIST", (ligintelist),"<br/>" PDBID_INTURL_dict=zip(PDBID_LIST,ligintelist) pdbsum_dict1=dict(PDBID_INTURL_dict) for id,link in pdbsum_dict1.iteritems(): links=list(pdbsum_dict1.viewvalues()) PDBID=list(pdbsum_dict1.viewkeys()) #print "HI LINKS CHECK for SPACE", links,"<br/>" #print "PDBIDs", PDBID,"<br/>" Number_of_Ids=len(PDBID) #FInal DIctionary with PDBID and Ligplot URL for extracting intercation details mydictcheck={} for ids,links in zip(PDBID,ligintelist): mydictcheck.setdefault('%s'%ids,[]).append(links) ############################################################################### #SECTION OF FIDING COMMON LIGAND ATOMS ############################################################################### #selecting common ligand atoms that are hydrogen bonded in selected PDB structures H_printing = False H_atoms_commoncomp={} for H_pdbids,H_pdbidlinks in mydictcheck.iteritems(): for H_links_sel in H_pdbidlinks: H_links_sel1=str(H_links_sel) weblink=requests.get(H_links_sel1, stream=True) for H_atomlines in weblink.iter_lines(): H_atomlines1=H_atomlines.strip() if H_atomlines1.startswith('Hydrogen bonds'): H_printing = True elif H_atomlines1.startswith('Non-bonded contacts'): H_printing = False if H_printing: #print H_atomlines if H_atomlines1.startswith(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')): H_atomlines2=H_atomlines1.split() H_atm_sel=H_atomlines2[8] H_atoms_commoncomp.setdefault('%s'%H_pdbids,[]).append(H_atm_sel) H_atomsvalues_dict1=H_atoms_commoncomp.values() H_common_intersectionfinal=sorted(list(set.intersection(*map(set,H_atomsvalues_dict1)))) #END of selecting common ligand atoms that are hydrogen bonded in selected PDB structures #selecting common ligand atoms that are non-hydrogen bonded in selected PDB structures NONH_printing = False NONHatoms_commoncomp={} for NONHpdbids,NONHpdbidlinks in mydictcheck.iteritems(): for NONHlinks_sel in NONHpdbidlinks: NONHlinks_sel1=str(NONHlinks_sel) weblink=requests.get(NONHlinks_sel1, stream=True) for NONHatomlines in weblink.iter_lines(): NONHatomlines1=NONHatomlines.strip() if NONHatomlines1.startswith('Non-bonded contacts'): NONH_printing = True elif NONHatomlines1.startswith('Hydrogen bonds'): NONH_printing = False if NONH_printing: #print atomlines1 if NONHatomlines1.startswith(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')): NONHatomlines2=NONHatomlines1.split() NONHatm_sel=NONHatomlines2[8] NONHatoms_commoncomp.setdefault('%s'%NONHpdbids,[]).append(NONHatm_sel) NONHatomsvalues_dict1=NONHatoms_commoncomp.values() NONHcommon_intersectionfinal=sorted(list(set.intersection(*map(set,NONHatomsvalues_dict1)))) ############################################################################### #END OF SECTION OF FIDING COMMON LIGAND ATOMS ############################################################################### ############################################################################### #START OF SECTION OF LIGAND ATOMS IN EACH SUBGROUPS: ############################################################################### ############################################################################### # 1.START OF SECTION OF NAD SUBGROUPS: ############################################################################### #Nicot Nicot_graphdicH={} Nicot_common_graphdicH={} Nicot_graphdicNH={} Nicot_common_graphdicNH={} Nicot_All_combine_Lig_Res_H={} Nicot_allH_Lig_Resdict={} Nicot_Common_combine_Lig_Res_H={} Nicot_CommonH_Lig_Resdict={} Nicot_All_combine_Lig_Res_NH={} Nicot_allNH_Lig_Resdict={} Nicot_Common_combine_Lig_Res_NH={} Nicot_CommonNH_Lig_Resdict={} Nicot_All_combine_Lig_Res_H_distance={} Nicot_allH_Lig_Resdict_distance={} Nicot_Common_combine_Lig_Res_H_distance={} Nicot_CommonH_Lig_Resdict_distance={} Nicot_All_combine_Lig_Res_NH_distance={} Nicot_allNH_Lig_Resdict_distance={} Nicot_Common_combine_Lig_Res_NH_distance={} Nicot_CommonNH_Lig_Resdict_distance={} Nicot_listdata_H=[] Nicot_listdata_NH=[] Nicot_lresidueH=[] Nicot_latomH=[] Nicot_lresidueNH=[] Nicot_latomNH=[] Nicot_common_listdata_H=[] Nicot_common_listdata_NH=[] Nicot_H_appended_lig_tabledic={} Nicot_H_Common_appended_lig_tabledic={} Nicot_NH_appended_lig_tabledic={} Nicot_NH_Common_appended_lig_tabledic={} Nicot_finalsetH=set() Nicot_finalsetNH=set() #End of Nicot #Ribitol Ribitol_graphdicH={} Ribitol_common_graphdicH={} Ribitol_graphdicNH={} Ribitol_common_graphdicNH={} Ribitol_All_combine_Lig_Res_H={} Ribitol_allH_Lig_Resdict={} Ribitol_Common_combine_Lig_Res_H={} Ribitol_CommonH_Lig_Resdict={} Ribitol_All_combine_Lig_Res_NH={} Ribitol_allNH_Lig_Resdict={} Ribitol_Common_combine_Lig_Res_NH={} Ribitol_CommonNH_Lig_Resdict={} Ribitol_All_combine_Lig_Res_H_distance={} Ribitol_allH_Lig_Resdict_distance={} Ribitol_Common_combine_Lig_Res_H_distance={} Ribitol_CommonH_Lig_Resdict_distance={} Ribitol_All_combine_Lig_Res_NH_distance={} Ribitol_allNH_Lig_Resdict_distance={} Ribitol_Common_combine_Lig_Res_NH_distance={} Ribitol_CommonNH_Lig_Resdict_distance={} Ribitol_listdata_H=[] Ribitol_listdata_NH=[] Ribitol_lresidueH=[] Ribitol_latomH=[] Ribitol_lresidueNH=[] Ribitol_latomNH=[] Ribitol_common_listdata_H=[] Ribitol_common_listdata_NH=[] Ribitol_H_appended_lig_tabledic={} Ribitol_H_Common_appended_lig_tabledic={} Ribitol_NH_appended_lig_tabledic={} Ribitol_NH_Common_appended_lig_tabledic={} #End of Ribitol #phosphate phosphate_graphdicH={} phosphate_common_graphdicH={} phosphate_graphdicNH={} phosphate_common_graphdicNH={} phosphate_All_combine_Lig_Res_H={} phosphate_allH_Lig_Resdict={} phosphate_Common_combine_Lig_Res_H={} phosphate_CommonH_Lig_Resdict={} phosphate_All_combine_Lig_Res_NH={} phosphate_allNH_Lig_Resdict={} phosphate_Common_combine_Lig_Res_NH={} phosphate_CommonNH_Lig_Resdict={} phosphate_All_combine_Lig_Res_H_distance={} phosphate_allH_Lig_Resdict_distance={} phosphate_Common_combine_Lig_Res_H_distance={} phosphate_CommonH_Lig_Resdict_distance={} phosphate_All_combine_Lig_Res_NH_distance={} phosphate_allNH_Lig_Resdict_distance={} phosphate_Common_combine_Lig_Res_NH_distance={} phosphate_CommonNH_Lig_Resdict_distance={} phosphate_listdata_H=[] phosphate_listdata_NH=[] phosphate_lresidueH=[] phosphate_latomH=[] phosphate_lresidueNH=[] phosphate_latomNH=[] phosphate_common_listdata_H=[] phosphate_common_listdata_NH=[] phosphate_H_appended_lig_tabledic={} phosphate_H_Common_appended_lig_tabledic={} phosphate_NH_appended_lig_tabledic={} phosphate_NH_Common_appended_lig_tabledic={} phosphate_finalsetH=set() phosphate_finalsetNH=set() #End of phosphate #Ribose Ribose_graphdicH={} Ribose_common_graphdicH={} Ribose_graphdicNH={} Ribose_common_graphdicNH={} Ribose_All_combine_Lig_Res_H={} Ribose_allH_Lig_Resdict={} Ribose_Common_combine_Lig_Res_H={} Ribose_CommonH_Lig_Resdict={} Ribose_All_combine_Lig_Res_NH={} Ribose_allNH_Lig_Resdict={} Ribose_Common_combine_Lig_Res_NH={} Ribose_CommonNH_Lig_Resdict={} Ribose_All_combine_Lig_Res_H_distance={} Ribose_allH_Lig_Resdict_distance={} Ribose_Common_combine_Lig_Res_H_distance={} Ribose_CommonH_Lig_Resdict_distance={} Ribose_All_combine_Lig_Res_NH_distance={} Ribose_allNH_Lig_Resdict_distance={} Ribose_Common_combine_Lig_Res_NH_distance={} Ribose_CommonNH_Lig_Resdict_distance={} Ribose_listdata_H=[] Ribose_listdata_NH=[] Ribose_common_listdata_H=[] Ribose_common_listdata_NH=[] Ribose_H_appended_lig_tabledic={} Ribose_H_Common_appended_lig_tabledic={} Ribose_NH_appended_lig_tabledic={} Ribose_NH_Common_appended_lig_tabledic={} #End ofRibose #Adenin Adenin_graphdicH={} Adenin_common_graphdicH={} Adenin_graphdicNH={} Adenin_common_graphdicNH={} Adenin_All_combine_Lig_Res_H={} Adenin_allH_Lig_Resdict={} Adenin_Common_combine_Lig_Res_H={} Adenin_CommonH_Lig_Resdict={} Adenin_All_combine_Lig_Res_NH={} Adenin_allNH_Lig_Resdict={} Adenin_Common_combine_Lig_Res_NH={} Adenin_CommonNH_Lig_Resdict={} Adenin_All_combine_Lig_Res_H_distance={} Adenin_allH_Lig_Resdict_distance={} Adenin_Common_combine_Lig_Res_H_distance={} Adenin_CommonH_Lig_Resdict_distance={} Adenin_All_combine_Lig_Res_NH_distance={} Adenin_allNH_Lig_Resdict_distance={} Adenin_Common_combine_Lig_Res_NH_distance={} Adenin_CommonNH_Lig_Resdict_distance={} Adenin_listdata_H=[] Adenin_listdata_NH=[] Adenin_lresidueH=[] Adenin_latomH=[] Adenin_lresidueNH=[] Adenin_latomNH=[] Adenin_common_listdata_H=[] Adenin_common_listdata_NH=[] Adenin_H_appended_lig_tabledic={} Adenin_H_Common_appended_lig_tabledic={} Adenin_NH_appended_lig_tabledic={} Adenin_NH_Common_appended_lig_tabledic={} #End ofAdenin lresidueH=[] latomH=[] ldistanceH=[] residueH={} atmnameH={} dicresidue_unique={} residue_seenH=set() atom_seenH=set() lresidueNH=[] latomNH=[] ldistanceNH=[] residueNH={} atmnameNH={} dicresidue_unique={} residue_seenNH=set() atom_seenNH=set() Ribitol_finalsetH=set() Ribitol_finalsetNH=set() Adenin_finalsetH=set() Adenin_finalsetNH=set() finalsetH=set() finalsetNH=set() combines_listdata=[] #print "<table style=width:50%>" #print "<tr>" #print "<th colspan='%d'>Interaction List</th>"% Number_of_Ids #print "</tr>" #print "</div>" H_appended_lig_tabledic={} H_Common_appended_lig_tabledic={} NH_Common_appended_lig_tabledic={} NH_appended_lig_tabledic={} graphdicH={} graphdicNH={} common_graphdicH={} common_graphdicNH={} printing = False for id,link in mydictcheck.iteritems(): #print link, id links_sel=link[0] link1= ''.join(str(links_sel)) res2=urllib.urlopen(str(link1)) html=res2.read() #print html for l in link: ll=str(l) r = requests.get(ll, stream=True) for line in r.iter_lines(): line=line.strip() if line.startswith('Hydrogen bonds'): printing = True elif line.startswith('Non-bonded contacts'): printing = False if printing: if line.startswith(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')): #print "HB", line lineH=line.split() lignameH=lineH[9] atmH=lineH[8] resH=lineH[3] residuenumH=lineH[4] distanceH=lineH[12] resnumH=resH+residuenumH # #appending each residue and its position to list called lresidue lresidueH.append(resnumH) #appending each ligand atom to list called latom latomH.append(atmH) #appending distance of each interaction to ldistance ldistanceH.append(distanceH) #creating a set for residue with position residue_seenH.add(resnumH) #creating a set for each ligand atom atom_seenH.add(atmH) #making a dictionary with list comtaining residue name and position residueH.setdefault('%s'%id,[]).append(resnumH) #making a dictionary with list comataing ligand atoms atmnameH.setdefault('%s'%id,[]).append(atmH) if atmH in Nicot: Nicot_lresidueH.append(resnumH) Nicot_latomH.append(atmH) Nicot_graphdicH.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for physio and weblogo Nicot_All_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for table Nicot_All_combine_Lig_Res_H_uniquify= {k:list(set(j)) for k,j in Nicot_All_combine_Lig_Res_H.items()} Nicot_allH_Lig_Resdict['%s'%id]=Nicot_All_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for all group Nicot_All_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Nicot_All_combine_Lig_Res_H_distance_uniquify= {k:list(set(j)) for k,j in Nicot_All_combine_Lig_Res_H_distance.items()} Nicot_allH_Lig_Resdict_distance['%s'%id]=Nicot_All_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in H_common_intersectionfinal: Nicot_common_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Nicot_Common_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with common lig atom and residues for table Nicot_Common_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Nicot_Common_combine_Lig_Res_H.items()} Nicot_CommonH_Lig_Resdict['%s'%id]=Nicot_Common_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for common group Nicot_Common_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Nicot_Common_combine_Lig_Res_H_distance_uniquify={k:list(set(j)) for k,j in Nicot_Common_combine_Lig_Res_H_distance.items()} Nicot_CommonH_Lig_Resdict_distance['%s'%id]=Nicot_Common_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in Ribitol: Ribitol_lresidueH.append(resnumH) Ribitol_latomH.append(atmH) Ribitol_graphdicH.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for physio and weblogo Ribitol_All_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for table Ribitol_All_combine_Lig_Res_H_uniquify= {k:list(set(j)) for k,j in Ribitol_All_combine_Lig_Res_H.items()} Ribitol_allH_Lig_Resdict['%s'%id]=Ribitol_All_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for all group Ribitol_All_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Ribitol_All_combine_Lig_Res_H_distance_uniquify= {k:list(set(j)) for k,j in Ribitol_All_combine_Lig_Res_H_distance.items()} Ribitol_allH_Lig_Resdict_distance['%s'%id]=Ribitol_All_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in H_common_intersectionfinal: Ribitol_common_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Ribitol_Common_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with common lig atom and residues for table Ribitol_Common_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Ribitol_Common_combine_Lig_Res_H.items()} Ribitol_CommonH_Lig_Resdict['%s'%id]=Ribitol_Common_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for common group Ribitol_Common_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Ribitol_Common_combine_Lig_Res_H_distance_uniquify={k:list(set(j)) for k,j in Ribitol_Common_combine_Lig_Res_H_distance.items()} Ribitol_CommonH_Lig_Resdict_distance['%s'%id]=Ribitol_Common_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in phosphate: phosphate_lresidueH.append(resnumH) phosphate_latomH.append(atmH) phosphate_graphdicH.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for physio and weblogo phosphate_All_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for table phosphate_All_combine_Lig_Res_H_uniquify= {k:list(set(j)) for k,j in phosphate_All_combine_Lig_Res_H.items()} phosphate_allH_Lig_Resdict['%s'%id]=phosphate_All_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for all group phosphate_All_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table phosphate_All_combine_Lig_Res_H_distance_uniquify= {k:list(set(j)) for k,j in phosphate_All_combine_Lig_Res_H_distance.items()} phosphate_allH_Lig_Resdict_distance['%s'%id]=phosphate_All_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in H_common_intersectionfinal: phosphate_common_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) phosphate_Common_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with common lig atom and residues for table phosphate_Common_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in phosphate_Common_combine_Lig_Res_H.items()} phosphate_CommonH_Lig_Resdict['%s'%id]=phosphate_Common_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for common group phosphate_Common_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table phosphate_Common_combine_Lig_Res_H_distance_uniquify={k:list(set(j)) for k,j in phosphate_Common_combine_Lig_Res_H_distance.items()} phosphate_CommonH_Lig_Resdict_distance['%s'%id]=phosphate_Common_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in Ribose: Ribose_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Ribose_All_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for table Ribose_All_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Ribose_All_combine_Lig_Res_H.items()} Ribose_allH_Lig_Resdict['%s'%id]=Ribose_All_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for all group Ribose_All_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Ribose_All_combine_Lig_Res_H_distance_uniquify= {k:list(set(j)) for k,j in Ribose_All_combine_Lig_Res_H_distance.items()} Ribose_allH_Lig_Resdict_distance['%s'%id]=Ribose_All_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in H_common_intersectionfinal: Ribose_common_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Ribose_Common_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with common lig atom and residues for table Ribose_Common_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Ribose_Common_combine_Lig_Res_H.items()} Ribose_CommonH_Lig_Resdict['%s'%id]=Ribose_Common_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for common group Ribose_Common_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Ribose_Common_combine_Lig_Res_H_distance_uniquify={k:list(set(j)) for k,j in Ribose_Common_combine_Lig_Res_H_distance.items()} Ribose_CommonH_Lig_Resdict_distance['%s'%id]=Ribose_Common_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in Adenin: Adenin_lresidueH.append(resnumH) Adenin_latomH.append(atmH) Adenin_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Adenin_All_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with all lig atom and residues for table Adenin_All_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Adenin_All_combine_Lig_Res_H.items()} Adenin_allH_Lig_Resdict['%s'%id]=Adenin_All_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for all group Adenin_All_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Adenin_All_combine_Lig_Res_H_distance_uniquify= {k:list(set(j)) for k,j in Adenin_All_combine_Lig_Res_H_distance.items()} Adenin_allH_Lig_Resdict_distance['%s'%id]=Adenin_All_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group if atmH in H_common_intersectionfinal: Adenin_common_graphdicH.setdefault('%s'%atmH,[]).append(resnumH) Adenin_Common_combine_Lig_Res_H.setdefault('%s'%atmH,[]).append(resnumH)#creating dictionary with common lig atom and residues for table Adenin_Common_combine_Lig_Res_H_uniquify={k:list(set(j)) for k,j in Adenin_Common_combine_Lig_Res_H.items()} Adenin_CommonH_Lig_Resdict['%s'%id]=Adenin_Common_combine_Lig_Res_H_uniquify#final dic for table with pdb id , lig atom and residues for common group Adenin_Common_combine_Lig_Res_H_distance.setdefault('%s'%atmH,[]).append(distanceH)#creating dictionary with all lig atom and distance for table Adenin_Common_combine_Lig_Res_H_distance_uniquify={k:list(set(j)) for k,j in Adenin_Common_combine_Lig_Res_H_distance.items()} Adenin_CommonH_Lig_Resdict_distance['%s'%id]=Adenin_Common_combine_Lig_Res_H_distance_uniquify#final dic for table with pdb id , lig atom and distance for all group else: if line.startswith(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')): #print "NHB", line lineNH=line.split() lignameNH=lineNH[9] atmNH=lineNH[8] resNH=lineNH[3] residuenumNH=lineNH[4] distanceNH=lineNH[12] resnumNH=resNH+residuenumNH # #appending each residue and its position to list called lresidue lresidueNH.append(resnumNH) #appending each ligand atom to list called latom latomNH.append(atmNH) #appending distance of each interaction to ldistance ldistanceNH.append(distanceNH) #creating a set for residue with position residue_seenNH.add(resnumNH) #creating a set for each ligand atom atom_seenNH.add(atmNH) #making a dictionary with list comtaining residue name and position residueNH.setdefault('%s'%id,[]).append(resnumNH) #making a dictionary with list comataing ligand atoms atmnameNH.setdefault('%s'%id,[]).append(atmNH) if atmNH in Nicot: Nicot_lresidueNH.append(resnumNH) Nicot_latomNH.append(atmNH) Nicot_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Nicot_All_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with all lig atom and residues for table Nicot_All_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Nicot_All_combine_Lig_Res_NH.items()} Nicot_allNH_Lig_Resdict['%s'%id]=Nicot_All_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for all group Nicot_All_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with all lig atom and residues for table Nicot_All_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Nicot_All_combine_Lig_Res_NH_distance.items()} Nicot_allNH_Lig_Resdict_distance['%s'%id]=Nicot_All_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for all group if atmNH in NONHcommon_intersectionfinal: Nicot_common_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Nicot_Common_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with common lig atom and residues for table Nicot_Common_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Nicot_Common_combine_Lig_Res_NH.items()} Nicot_CommonNH_Lig_Resdict['%s'%id]=Nicot_Common_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for common group Nicot_Common_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with common lig atom and residues for table Nicot_Common_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Nicot_Common_combine_Lig_Res_NH_distance.items()} Nicot_CommonNH_Lig_Resdict_distance['%s'%id]=Nicot_Common_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for common group if atmNH in Ribitol: Ribitol_lresidueNH.append(resnumNH) Ribitol_latomNH.append(atmNH) Ribitol_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Ribitol_All_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with all lig atom and residues for table Ribitol_All_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Ribitol_All_combine_Lig_Res_NH.items()} Ribitol_allNH_Lig_Resdict['%s'%id]=Ribitol_All_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for all group Ribitol_All_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with all lig atom and residues for table Ribitol_All_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Ribitol_All_combine_Lig_Res_NH_distance.items()} Ribitol_allNH_Lig_Resdict_distance['%s'%id]=Ribitol_All_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for all group if atmNH in NONHcommon_intersectionfinal: Ribitol_common_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Ribitol_Common_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with common lig atom and residues for table Ribitol_Common_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Ribitol_Common_combine_Lig_Res_NH.items()} Ribitol_CommonNH_Lig_Resdict['%s'%id]=Ribitol_Common_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for common group Ribitol_Common_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with common lig atom and residues for table Ribitol_Common_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Ribitol_Common_combine_Lig_Res_NH_distance.items()} Ribitol_CommonNH_Lig_Resdict_distance['%s'%id]=Ribitol_Common_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for common group if atmNH in phosphate: phosphate_lresidueNH.append(resnumNH) phosphate_latomNH.append(atmNH) phosphate_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) phosphate_All_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with all lig atom and residues for table phosphate_All_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in phosphate_All_combine_Lig_Res_NH.items()} phosphate_allNH_Lig_Resdict['%s'%id]=phosphate_All_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for all group phosphate_All_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with all lig atom and residues for table phosphate_All_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in phosphate_All_combine_Lig_Res_NH_distance.items()} phosphate_allNH_Lig_Resdict_distance['%s'%id]=phosphate_All_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for all group if atmNH in NONHcommon_intersectionfinal: phosphate_common_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) phosphate_Common_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with common lig atom and residues for table phosphate_Common_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in phosphate_Common_combine_Lig_Res_NH.items()} phosphate_CommonNH_Lig_Resdict['%s'%id]=phosphate_Common_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for common group phosphate_Common_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with common lig atom and residues for table phosphate_Common_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in phosphate_Common_combine_Lig_Res_NH_distance.items()} phosphate_CommonNH_Lig_Resdict_distance['%s'%id]=phosphate_Common_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for common group if atmNH in Ribose: Ribose_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Ribose_All_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with all lig atom and residues for table Ribose_All_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Ribose_All_combine_Lig_Res_NH.items()} Ribose_allNH_Lig_Resdict['%s'%id]=Ribose_All_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for all group Ribose_All_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with all lig atom and residues for table Ribose_All_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Ribose_All_combine_Lig_Res_NH_distance.items()} Ribose_allNH_Lig_Resdict_distance['%s'%id]=Ribose_All_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for all group if atmNH in NONHcommon_intersectionfinal: Ribose_common_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Ribose_Common_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with common lig atom and residues for table Ribose_Common_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Ribose_Common_combine_Lig_Res_NH.items()} Ribose_CommonNH_Lig_Resdict['%s'%id]=Ribose_Common_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for common group Ribose_Common_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with common lig atom and residues for table Ribose_Common_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Ribose_Common_combine_Lig_Res_NH_distance.items()} Ribose_CommonNH_Lig_Resdict_distance['%s'%id]=Ribose_Common_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for common group if atmNH in Adenin: Adenin_lresidueNH.append(resnumNH) Adenin_latomNH.append(atmNH) Adenin_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Adenin_All_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with all lig atom and residues for table Adenin_All_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Adenin_All_combine_Lig_Res_NH.items()} Adenin_allNH_Lig_Resdict['%s'%id]=Adenin_All_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for all group Adenin_All_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with all lig atom and residues for table Adenin_All_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Adenin_All_combine_Lig_Res_NH_distance.items()} Adenin_allNH_Lig_Resdict_distance['%s'%id]=Adenin_All_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for all group if atmNH in NONHcommon_intersectionfinal: Adenin_common_graphdicNH.setdefault('%s'%atmNH,[]).append(resnumNH) Adenin_Common_combine_Lig_Res_NH.setdefault('%s'%atmNH,[]).append(resnumNH)#creating dictionary with common lig atom and residues for table Adenin_Common_combine_Lig_Res_NH_uniquify= {k:list(set(j)) for k,j in Adenin_Common_combine_Lig_Res_NH.items()} Adenin_CommonNH_Lig_Resdict['%s'%id]=Adenin_Common_combine_Lig_Res_NH_uniquify#final dic for table with pdb id , lig atom and residues for common group Adenin_Common_combine_Lig_Res_NH_distance.setdefault('%s'%atmNH,[]).append(distanceNH)#creating dictionary with common lig atom and residues for table Adenin_Common_combine_Lig_Res_NH_distance_uniquify= {k:list(set(j)) for k,j in Adenin_Common_combine_Lig_Res_NH_distance.items()} Adenin_CommonNH_Lig_Resdict_distance['%s'%id]=Adenin_Common_combine_Lig_Res_NH_distance_uniquify#final dic for table with pdb id , lig atom and residues for common group Nicot_listdata_H=[] Nicot_listdata_NH=[] Nicot_lresidueH=[] Nicot_latomH=[] Nicot_lresidueNH=[] Nicot_latomNH=[] Nicot_All_combine_Lig_Res_H={} Nicot_Common_combine_Lig_Res_H={} Nicot_All_combine_Lig_Res_NH={} Nicot_Common_combine_Lig_Res_NH={} Nicot_All_combine_Lig_Res_H_distance={} Nicot_Common_combine_Lig_Res_H_distance={} Nicot_All_combine_Lig_Res_NH_distance={} Nicot_Common_combine_Lig_Res_NH_distance={} Nicot_common_listdata_H=[] Nicot_common_listdata_NH=[] Nicot_finalsetH.clear() Nicot_finalsetNH.clear() Ribitol_listdata_H=[] Ribitol_listdata_NH=[] Ribitol_lresidueH=[] Ribitol_latomH=[] Ribitol_lresidueNH=[] Ribitol_latomNH=[] Ribitol_All_combine_Lig_Res_H={} Ribitol_Common_combine_Lig_Res_H={} Ribitol_All_combine_Lig_Res_NH={} Ribitol_Common_combine_Lig_Res_NH={} Ribitol_All_combine_Lig_Res_H_distance={} Ribitol_Common_combine_Lig_Res_H_distance={} Ribitol_All_combine_Lig_Res_NH_distance={} Ribitol_Common_combine_Lig_Res_NH_distance={} phosphate_listdata_H=[] phosphate_listdata_NH=[] phosphate_lresidueH=[] phosphate_latomH=[] phosphate_lresidueNH=[] phosphate_latomNH=[] phosphate_All_combine_Lig_Res_H={} phosphate_Common_combine_Lig_Res_H={} phosphate_All_combine_Lig_Res_NH={} phosphate_Common_combine_Lig_Res_NH={} phosphate_All_combine_Lig_Res_H_distance={} phosphate_Common_combine_Lig_Res_H_distance={} phosphate_All_combine_Lig_Res_NH_distance={} phosphate_Common_combine_Lig_Res_NH_distance={} phosphate_common_listdata_H=[] phosphate_common_listdata_NH=[] phosphate_finalsetH.clear() phosphate_finalsetNH.clear() Ribose_listdata_H=[] Ribose_listdata_NH=[] Ribose_All_combine_Lig_Res_H={} Ribose_Common_combine_Lig_Res_H={} Ribose_All_combine_Lig_Res_NH={} Ribose_Common_combine_Lig_Res_NH={} Ribose_All_combine_Lig_Res_H_distance={} Ribose_Common_combine_Lig_Res_H_distance={} Ribose_All_combine_Lig_Res_NH_distance={} Ribose_Common_combine_Lig_Res_NH_distance={} Adenin_lresidueH=[] Adenin_latomH=[] Adenin_lresidueNH=[] Adenin_latomNH=[] Adenin_listdata_H=[] Adenin_listdata_NH=[] Adenin_All_combine_Lig_Res_H={} Adenin_Common_combine_Lig_Res_H={} Adenin_All_combine_Lig_Res_NH={} Adenin_Common_combine_Lig_Res_NH={} Adenin_All_combine_Lig_Res_H_distance={} Adenin_Common_combine_Lig_Res_H_distance={} Adenin_All_combine_Lig_Res_NH_distance={} Adenin_Common_combine_Lig_Res_NH_distance={} Ribitol_common_listdata_H=[] Ribitol_common_listdata_NH=[] Ribose_common_listdata_H=[] Ribose_common_listdata_NH=[] Adenin_common_listdata_H=[] Adenin_common_listdata_NH=[] lresidueH=[] latomH=[] ldistanceH=[] lresidueNH=[] latomNH=[] ldistanceNH=[] combines_listdata=[] residue_seenH.clear() Ribitol_finalsetH.clear() Ribitol_finalsetNH.clear() Adenin_finalsetH.clear() Adenin_finalsetNH.clear() finalsetH.clear() finalsetNH.clear() ####################Define function for Statistics ################################ def percentage(dictname,subgroup): Count_Atom={} percentage_Atom={} atmlist=[] if bool(dictname): for key, value in dictname.iteritems(): for atom in subgroup: for key1,value1 in value.iteritems(): #for i in dict1.keys(): if atom == key1: Count_Atom[key1]=1 percentage_Atom['%s'%key]=Count_Atom #print percent Count_Atom={} tabl=pd.DataFrame.from_dict(percentage_Atom).fillna(0) Num_cols = len (PDBID_LIST) for atms in percentage_Atom.values(): for atms_key in atms.keys(): atmlist.append(atms_key) count_atmlist=list(set(atmlist)) tabl['Percentage of Interaction']= (tabl.sum(axis=1)/Num_cols)*100 tabl['Percentage of Interaction']=tabl['Percentage of Interaction'].round(2) print "<br/>"," No. of Ligand atoms:", len(count_atmlist), "/",len(subgroup), "<br/>" print tabl.T.to_html(justify='center'),"<br/>" #print tabl.style.background_gradient(cmap='summer') #sns.heatmap(tabl['Percentage of Interaction'], annot=True) Highest_value= tabl['Percentage of Interaction'][tabl['Percentage of Interaction']==tabl['Percentage of Interaction'].max()] Highest_value=Highest_value.to_dict() print "Highest percenrage of Interactions identified","<br/>" Max_tabl=pd.DataFrame(Highest_value.items()) Max_tabl.columns = ['Ligand Atom', 'Percentage'] Max_tabl.rename(index={0: 'Highest'}) #Max_tabl=pd.Series(Highest_value).to_frame() #Max_tabl.index.rename = 'index' #Max_tabl.rename(index={0:'zero'}, inplace=True) #df1.rename(index={0: 'a'}) print Max_tabl.T.to_html(justify='center') else: print "No Interactions Observed" ######End of Percentage section### ####Start of Distance section## #####Start of Distance section### def distance_calc(dictnames): DistMean_dict={} DistFinal_pdb={} if bool(dictnames): for key,value in dictnames.iteritems(): for key1,value1 in value.iteritems(): results = map(float, value1) #print value1, np.mean(results) mean1=round(np.float64(np.mean(results)), 2) DistMean_dict[key1]=mean1 DistFinal_pdb[key]=DistMean_dict DistMean_dict={} Distance_tabl=pd.DataFrame.from_dict(DistFinal_pdb) print Distance_tabl.T.to_html(justify='center'),"<br/>" print Distance_tabl.apply(pd.Series.describe, axis=1)[['count','mean','std']].dropna().round(2).T.to_html(justify='center'),"<br/>" #Distance_tabl['Standard Deviation']=Distance_tabl.std(axis=1) #Distance_tabl['Standard Deviation']=Distance_tabl['Standard Deviation'].round(2) else: print "No Interactions Observed","<br/>" #End of distance section## ####################End of Define function for Statistics ################################ aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} ### List of filenames for csv download ########## CSVrandom_name= str(uuid.uuid4()) Nicot_allH='tmp/'+'Nicot_allH' +CSVrandom_name+'.csv' Nicot_allNH='tmp/'+'Nicot_allNH' +CSVrandom_name+'.csv' Nicot_CommonH='tmp/'+'Nicot_CommonH' +CSVrandom_name+'.csv' Nicot_CommonNH='tmp/'+'Nicot_CommonNH' +CSVrandom_name+'.csv' Ribitol_allH='tmp/'+'Ribitol_allH' +CSVrandom_name+'.csv' Ribitol_allNH='tmp/'+'Ribitol_allNH' +CSVrandom_name+'.csv' Ribitol_CommonH='tmp/'+'Ribitol_CommonH' +CSVrandom_name+'.csv' Ribitol_CommonNH='tmp/'+'Ribitol_CommonNH' +CSVrandom_name+'.csv' phosphate_allH='tmp/'+'phosphate_allH' +CSVrandom_name+'.csv' phosphate_allNH='tmp/'+'phosphate_allNH' +CSVrandom_name+'.csv' phosphate_CommonH='tmp/'+'phosphate_CommonH' +CSVrandom_name+'.csv' phosphate_CommonNH='tmp/'+'phosphate_CommonNH' +CSVrandom_name+'.csv' Ribose_allH='tmp/'+'Ribose_allH' +CSVrandom_name+'.csv' Ribose_allNH='tmp/'+'Ribose_allNH' +CSVrandom_name+'.csv' Ribose_CommonH='tmp/'+'Ribose_CommonH' +CSVrandom_name+'.csv' Ribose_CommonNH='tmp/'+'Ribose_CommonNH' +CSVrandom_name+'.csv' Adenin_allH='tmp/'+'Adenin_allH' +CSVrandom_name+'.csv' Adenin_allNH='tmp/'+'Adenin_allNH' +CSVrandom_name+'.csv' Adenin_CommonH='tmp/'+'Adenin_CommonH' +CSVrandom_name+'.csv' Adenin_CommonNH='tmp/'+'Adenin_CommonNH' +CSVrandom_name+'.csv' #### dict to csv ### Nicot_allH_df=pd.DataFrame(Nicot_allH_Lig_Resdict) Nicot_allH_df.to_csv(Nicot_allH) Nicot_allNH_df=pd.DataFrame(Nicot_allNH_Lig_Resdict) Nicot_allNH_df.to_csv(Nicot_allNH) Nicot_CommonH_df=pd.DataFrame(Nicot_CommonH_Lig_Resdict) Nicot_CommonH_df.to_csv(Nicot_CommonH) Nicot_CommonNH_df=pd.DataFrame(Nicot_CommonNH_Lig_Resdict) Nicot_CommonNH_df.to_csv(Nicot_CommonNH) Ribitol_allH_df=pd.DataFrame(Ribitol_allH_Lig_Resdict) Ribitol_allH_df.to_csv(Ribitol_allH) Ribitol_allNH_df=pd.DataFrame(Ribitol_allNH_Lig_Resdict) Ribitol_allNH_df.to_csv(Ribitol_allNH) Ribitol_CommonH_df=pd.DataFrame(Ribitol_CommonH_Lig_Resdict) Ribitol_CommonH_df.to_csv(Ribitol_CommonH) Ribitol_CommonNH_df=pd.DataFrame(Ribitol_CommonNH_Lig_Resdict) Ribitol_CommonNH_df.to_csv(Ribitol_CommonNH) phosphate_allH_df=pd.DataFrame(phosphate_allH_Lig_Resdict) phosphate_allH_df.to_csv(phosphate_allH) phosphate_allNH_df=pd.DataFrame(phosphate_allNH_Lig_Resdict) phosphate_allNH_df.to_csv(phosphate_allNH) phosphate_CommonH_df=pd.DataFrame(phosphate_CommonH_Lig_Resdict) phosphate_CommonH_df.to_csv(phosphate_CommonH) phosphate_CommonNH_df=pd.DataFrame(phosphate_CommonNH_Lig_Resdict) phosphate_CommonNH_df.to_csv(phosphate_CommonNH) Ribose_allH_df=pd.DataFrame(Ribose_allH_Lig_Resdict) Ribose_allH_df.to_csv(Ribose_allH) Ribose_allNH_df=pd.DataFrame(Ribose_allNH_Lig_Resdict) Ribose_allNH_df.to_csv(Ribose_allNH) Ribose_CommonH_df=pd.DataFrame(Ribose_CommonH_Lig_Resdict) Ribose_CommonH_df.to_csv(Ribose_CommonH) Ribose_CommonNH_df=pd.DataFrame(Ribose_CommonNH_Lig_Resdict) Ribose_CommonNH_df.to_csv(Ribose_CommonNH) Adenin_allH_df=pd.DataFrame(Adenin_allH_Lig_Resdict) Adenin_allH_df.to_csv(Adenin_allH) Adenin_allNH_df=pd.DataFrame(Adenin_allNH_Lig_Resdict) Adenin_allNH_df.to_csv(Adenin_allNH) Adenin_CommonH_df=pd.DataFrame(Adenin_CommonH_Lig_Resdict) Adenin_CommonH_df.to_csv(Adenin_CommonH) Adenin_CommonNH_df=pd.DataFrame(Adenin_CommonNH_Lig_Resdict) Adenin_CommonNH_df.to_csv(Adenin_CommonNH) #############END of filenames for csv download ############ print "<p align='center'>################################################################","</p>" print "<p style='font-size:20px; color:blue' align='center'>Nicot sub group structure","</p>" print '<p style=text-align:center>Download: <a href=%s download>All bonded,</a> '% Nicot_allH print ' <a href=%s download>All non-bonded,</a>'% Nicot_allNH print ' <a href=%s download>Common bonded,</a>'% Nicot_CommonH print ' <a href=%s download>Common non-bonded,</a>'% Nicot_CommonNH ,'</p>' print "<p align='center'>################################################################" ,"</p>" print "<button class='collapsible'>I. Compiled Bonded Interactions - Click to read Basic Statistics Information</button>"#Start of click drop down print "<div class='contentsection'>" print "<p style='font-size:20px; color:black' align='center'>" print " Number of Ligand atoms:", len(Nicot), "<br/>" print " Number of PDB IDs:", len(Nicot_allNH_Lig_Resdict.keys()), "<br/>" print "<div class='row'>"# spliting into two columns print "<div class='column'>"# spliting into two columns if bool(Nicot_allH_Lig_Resdict): print "[1: Intercating and 0: Not Interacting]" , "<br/>" print percentage(Nicot_allH_Lig_Resdict, Nicot) if bool(Nicot_allH_Lig_Resdict_distance): print distance_calc(Nicot_allH_Lig_Resdict_distance) print "</div>"# closing of first columns print "<div class='column'>" if bool(Nicot_allNH_Lig_Resdict): print "Statistics of Non-Bonded Intercations" print percentage(Nicot_allNH_Lig_Resdict,Nicot) if bool(Nicot_allNH_Lig_Resdict_distance): print distance_calc(Nicot_allNH_Lig_Resdict_distance) print "</div>"# closing of second columns print "</div>"#closing of row print "</div>"#End of click drop down print "<br/>" print """ <div class="grid"> <div class="col-2-3"> <div class="module"> """ if bool(Nicot_allH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" df_Nicot_allH_Lig_Resdict=pd.DataFrame.from_dict(Nicot_allH_Lig_Resdict).fillna('NIL') print (df_Nicot_allH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Nicot_allH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################All Residues Colored Table for Nicot: H bonded################################ ####################All Residues Colored Table for Nicot: H bonded################################ H_templist4graph=[] H_graphdic1={} if bool(Nicot_graphdicH): for k,v in Nicot_graphdicH.iteritems(): #print k for value in v: H_templist4graph.append(value) samp=sorted(list(set(H_templist4graph))) H_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) H_templist4graph=[] length_listofcompiledresidues=[] for key,value in H_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(H_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in H_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Nicot_allNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" df_Nicot_allNH_Lig_Resdict=pd.DataFrame.from_dict(Nicot_allNH_Lig_Resdict).fillna('NIL') print (df_Nicot_allNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Nicot_allNH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" print "No Interactions" ####################All Residues Colored Table for Nicot: NON bonded################################ NH_templist4graph=[] NH_graphdic1={} if bool(Nicot_graphdicNH): for k,v in Nicot_graphdicNH.iteritems(): #print k for value in v: NH_templist4graph.append(value) samp=sorted(list(set(NH_templist4graph))) NH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) #print temlist #print samp NH_templist4graph=[] length_listofcompiledresidues=[] for key,value in NH_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(NH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in NH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "No Interactions" print """ </div> </div> """#closing of col-2-3 and module print """ <div class="col-2-3"> <div class="module"> """# initializing the middle column if bool(Nicot_CommonH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" df_Nicot_CommonH_Lig_Resdict=pd.DataFrame.from_dict(Nicot_CommonH_Lig_Resdict).fillna('NIL') print (df_Nicot_CommonH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Nicot_CommonH_Lig_Resdict).to_html(justify='center')#for common ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################Common Residues Colored Table for Nicot : H bonded################################ CommH_templist4graph=[] CommH_graphdic1={} if bool(Nicot_common_graphdicH): for k,v in Nicot_common_graphdicH.iteritems(): for value in v: CommH_templist4graph.append(value) samp=sorted(list(set(CommH_templist4graph))) CommH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommH_templist4graph=[] length_listofcompiled_Common_residues=[] for key,value in CommH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommH_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Nicot_CommonNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" df_Nicot_CommonNH_Lig_Resdict=pd.DataFrame.from_dict(Nicot_CommonNH_Lig_Resdict).fillna('NIL') print (df_Nicot_CommonNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Nicot_CommonNH_Lig_Resdict).to_html(justify='center')#for Common ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" print "No Interactions" ####################Common Residues Colored Table for Nicot: NON bonded################################ CommNH_templist4graph=[] CommNH_graphdic1={} if bool(Nicot_common_graphdicNH): for k,v in Nicot_common_graphdicNH.iteritems(): #print k for value in v: CommNH_templist4graph.append(value) samp=sorted(list(set(CommNH_templist4graph))) CommNH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommNH_templist4graph=[] length_listofcompile_Common_dresidues=[] for key,value in CommNH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommNH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommNH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "No Interactions" print """ </div> </div> """# closinf of column and module div ###############Web logo for Common Residues Section: H bonding####################### print """ <div class="col-2-3"> <div class="module"> """ Nicot_graph_filename = str(uuid.uuid4()) Weblogo_dict_H={} Weblogo_dict_H1={} if bool (CommH_graphdic1): for key in sorted(CommH_graphdic1): for i in CommH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_H.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_H.iteritems(): counted=dict(Counter(n)) Weblogo_dict_H1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Nicot_graph_filename+'_Hbonding'+'.zip' Nicot_aminoacid_singlecode={} aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} recoded={} for Nicot_ligand_key, Nicot_amino_frequency in Weblogo_dict_H1.iteritems(): #print ligand_key for i in Nicot_ligand_key: for Nicot_amino,Nicot_frequency in Nicot_amino_frequency.iteritems(): for Nicot_amino_3letter,Nicot_code_frequency in aminoacid_code.iteritems(): if Nicot_amino == Nicot_amino_3letter: recoded[Nicot_code_frequency]=Nicot_frequency Nicot_aminoacid_singlecode.setdefault('%s'%Nicot_ligand_key,{}).update(recoded) recoded={} Nicot_Frequency=1 instances=[] Nicot_weblogo_collection=[] for Nicot_ligand_key1, amino_frequency1 in Nicot_aminoacid_singlecode.iteritems(): for Nicot_Amino1, Nicot_number in amino_frequency1.iteritems(): Nicot_Frequency=1 while Nicot_Frequency <= Nicot_number: instances.append(Seq(Nicot_Amino1, IUPAC.protein)) Nicot_Frequency=Nicot_Frequency+1 Nicot_motif = motifs.create(instances) Nicot_mymotif ='tmp/'+ Nicot_graph_filename+ '_H_'+ Nicot_ligand_key1 +'.svg' Nicot_motif.weblogo('%s'%Nicot_mymotif,format='SVG',xaxis_label= '%s' %Nicot_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Nicot_weblogo_collection.append(Nicot_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Nicot_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" for Nicot_image in sorted(Nicot_weblogo_collection): print "<div class='weblogo_column'>" print "<embed src='%s#page=1&view=FitH ' />" %Nicot_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='100' border='0'></iframe>"%Nicot_image print "</div>" print "</div>" ####zip file with ZipFile('%s'%zipfilename, 'w') as Nicot_myzip: for Nicot_Images in Nicot_weblogo_collection: Nicot_myzip.write(Nicot_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Bonded Interactions:</p>" print "No Interactions" ###############Web logo for Common Residues Section: NON bonding####################### Weblogo_dict_NH={} Weblogo_dict_NH1={} if bool(CommNH_graphdic1): for key in sorted(CommNH_graphdic1): for i in CommNH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_NH.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_NH.iteritems(): counted=dict(Counter(n)) Weblogo_dict_NH1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Nicot_graph_filename+'_NHbonding'+'.zip' Nicot_aminoacid_singlecode={} recoded={} for Nicot_ligand_key, Nicot_amino_frequency in Weblogo_dict_NH1.iteritems(): #print ligand_key for i in Nicot_ligand_key: for Nicot_amino,Nicot_frequency in Nicot_amino_frequency.iteritems(): for Nicot_amino_3letter,Nicot_code_frequency in aminoacid_code.iteritems(): if Nicot_amino == Nicot_amino_3letter: recoded[Nicot_code_frequency]=Nicot_frequency Nicot_aminoacid_singlecode.setdefault('%s'%Nicot_ligand_key,{}).update(recoded) recoded={} Nicot_Frequency=1 instances=[] Nicot_weblogo_collection=[] for Nicot_ligand_key1, amino_frequency1 in Nicot_aminoacid_singlecode.iteritems(): for Nicot_Amino1, Nicot_number in amino_frequency1.iteritems(): Nicot_Frequency=1 while Nicot_Frequency <= Nicot_number: instances.append(Seq(Nicot_Amino1, IUPAC.protein)) Nicot_Frequency=Nicot_Frequency+1 Nicot_motif = motifs.create(instances) Nicot_mymotif ='tmp/'+ Nicot_graph_filename+ '_NH_'+ Nicot_ligand_key1 +'.svg' Nicot_motif.weblogo('%s'%Nicot_mymotif,format='SVG',xaxis_label= '%s' %Nicot_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Nicot_weblogo_collection.append(Nicot_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Nicot_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" #initiation of weblog_row for Nicot_image in sorted(Nicot_weblogo_collection): print "<div class='weblogo_column'>" #initiation of weblog_column print "<embed src='%s#page=1&view=FitH ' />" %Nicot_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='200' border='0'></iframe>"%Nicot_image print "</div>"#closing of weblog_column print "</div>"#closing of weblog_row ####zip file with ZipFile('%s'%zipfilename, 'w') as Nicot_myzip: for Nicot_Images in Nicot_weblogo_collection: Nicot_myzip.write(Nicot_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Nonbonded Interactions:</p>" print "No Interactions" print """ </div> </div> </div> """ # closing of Nicot section print "<p align='center'>################################################################","</p>" print "<p style='font-size:20px; color:blue' align='center'>Ribitol sub group structure","</p>" print '<p style=text-align:center>Download: <a href=%s download>All bonded,</a> '% Ribitol_allH print ' <a href=%s download>All non-bonded,</a>'% Ribitol_allNH print ' <a href=%s download>Common bonded,</a>'% Ribitol_CommonH print ' <a href=%s download>Common non-bonded,</a>'% Ribitol_CommonNH ,'</p>' print "<p align='center'>################################################################" ,"</p>" print "<button class='collapsible'>I. Compiled Bonded Interactions - Click to read Basic Statistics Information</button>"#Start of click drop down print "<div class='contentsection'>" print "<p style='font-size:20px; color:black' align='center'>" print " Number of Ligand atoms:", len(Ribitol), "<br/>" print " Number of PDB IDs:", len(Ribitol_allNH_Lig_Resdict.keys()), "<br/>" print "<div class='row'>"# spliting into two columns print "<div class='column'>"# spliting into two columns if bool(Ribitol_allH_Lig_Resdict): print "Statistics of Bonded Intercations" print percentage(Ribitol_allH_Lig_Resdict,Ribitol) if bool(Ribitol_allH_Lig_Resdict_distance): print distance_calc(Ribitol_allH_Lig_Resdict_distance) print "</div>"# closing of first columns print "<div class='column'>" if bool(Ribitol_allNH_Lig_Resdict): print "Statistics of Non-Bonded Intercations" print percentage(Ribitol_allNH_Lig_Resdict,Ribitol) if bool(Ribitol_allNH_Lig_Resdict_distance): print distance_calc(Ribitol_allNH_Lig_Resdict_distance) print "</div>"# closing of second columns print "</div>"#closing of row print "</div>"#End of click drop down print "<br/>" print """ <div class="grid"> <div class="col-2-3"> <div class="module"> """ if bool(Ribitol_allH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" df_Ribitol_allH_Lig_Resdict=pd.DataFrame.from_dict(Ribitol_allH_Lig_Resdict).fillna('NIL') print (df_Ribitol_allH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribitol_allH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################All Residues Colored Table for Ribitol: H bonded################################ ####################All Residues Colored Table for Ribitol: H bonded################################ H_templist4graph=[] H_graphdic1={} if bool(Ribitol_graphdicH): for k,v in Ribitol_graphdicH.iteritems(): #print k for value in v: H_templist4graph.append(value) samp=sorted(list(set(H_templist4graph))) H_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) H_templist4graph=[] length_listofcompiledresidues=[] for key,value in H_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(H_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in H_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Ribitol_allNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" df_Ribitol_allNH_Lig_Resdict=pd.DataFrame.from_dict(Ribitol_allNH_Lig_Resdict).fillna('NIL') print (df_Ribitol_allNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribitol_allNH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" print "No Interactions" ####################All Residues Colored Table for Ribitol: NON bonded################################ NH_templist4graph=[] NH_graphdic1={} if bool(Ribitol_graphdicNH): for k,v in Ribitol_graphdicNH.iteritems(): #print k for value in v: NH_templist4graph.append(value) samp=sorted(list(set(NH_templist4graph))) NH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) #print temlist #print samp NH_templist4graph=[] length_listofcompiledresidues=[] for key,value in NH_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(NH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in NH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "No Interactions" print """ </div> </div> """#closing of col-2-3 and module print """ <div class="col-2-3"> <div class="module"> """# initializing the middle column if bool(Ribitol_CommonH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" df_Ribitol_CommonH_Lig_Resdict=pd.DataFrame.from_dict(Ribitol_CommonH_Lig_Resdict).fillna('NIL') print (df_Ribitol_CommonH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribitol_CommonH_Lig_Resdict).to_html(justify='center')#for common ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################Common Residues Colored Table for Ribitol : H bonded################################ CommH_templist4graph=[] CommH_graphdic1={} if bool(Ribitol_common_graphdicH): for k,v in Ribitol_common_graphdicH.iteritems(): for value in v: CommH_templist4graph.append(value) samp=sorted(list(set(CommH_templist4graph))) CommH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommH_templist4graph=[] length_listofcompiled_Common_residues=[] for key,value in CommH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommH_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Ribitol_CommonNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" df_Ribitol_CommonNH_Lig_Resdict=pd.DataFrame.from_dict(Ribitol_CommonNH_Lig_Resdict).fillna('NIL') print (df_Ribitol_CommonNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribitol_CommonNH_Lig_Resdict).to_html(justify='center')#for Common ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" print "No Interactions" ####################Common Residues Colored Table for Ribitol: NON bonded################################ CommNH_templist4graph=[] CommNH_graphdic1={} if bool(Ribitol_common_graphdicNH): for k,v in Ribitol_common_graphdicNH.iteritems(): #print k for value in v: CommNH_templist4graph.append(value) samp=sorted(list(set(CommNH_templist4graph))) CommNH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommNH_templist4graph=[] length_listofcompile_Common_dresidues=[] for key,value in CommNH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommNH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommNH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "No Interactions" print """ </div> </div> """# closinf of column and module div ###############Web logo for Common Residues Section: H bonding####################### print """ <div class="col-2-3"> <div class="module"> """ Ribitol_graph_filename = str(uuid.uuid4()) Weblogo_dict_H={} Weblogo_dict_H1={} if bool (CommH_graphdic1): for key in sorted(CommH_graphdic1): for i in CommH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_H.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_H.iteritems(): counted=dict(Counter(n)) Weblogo_dict_H1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Ribitol_graph_filename+'_Hbonding'+'.zip' Ribitol_aminoacid_singlecode={} aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} recoded={} for Ribitol_ligand_key, Ribitol_amino_frequency in Weblogo_dict_H1.iteritems(): #print ligand_key for i in Ribitol_ligand_key: for Ribitol_amino,Ribitol_frequency in Ribitol_amino_frequency.iteritems(): for Ribitol_amino_3letter,Ribitol_code_frequency in aminoacid_code.iteritems(): if Ribitol_amino == Ribitol_amino_3letter: recoded[Ribitol_code_frequency]=Ribitol_frequency Ribitol_aminoacid_singlecode.setdefault('%s'%Ribitol_ligand_key,{}).update(recoded) recoded={} Ribitol_Frequency=1 instances=[] Ribitol_weblogo_collection=[] for Ribitol_ligand_key1, amino_frequency1 in Ribitol_aminoacid_singlecode.iteritems(): for Ribitol_Amino1, Ribitol_number in amino_frequency1.iteritems(): Ribitol_Frequency=1 while Ribitol_Frequency <= Ribitol_number: instances.append(Seq(Ribitol_Amino1, IUPAC.protein)) Ribitol_Frequency=Ribitol_Frequency+1 Ribitol_motif = motifs.create(instances) Ribitol_mymotif ='tmp/'+ Ribitol_graph_filename+ '_H_'+ Ribitol_ligand_key1 +'.svg' Ribitol_motif.weblogo('%s'%Ribitol_mymotif,format='SVG',xaxis_label= '%s' %Ribitol_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Ribitol_weblogo_collection.append(Ribitol_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Ribitol_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" for Ribitol_image in sorted(Ribitol_weblogo_collection): print "<div class='weblogo_column'>" print "<embed src='%s#page=1&view=FitH ' />" %Ribitol_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='100' border='0'></iframe>"%Ribitol_image print "</div>" print "</div>" ####zip file with ZipFile('%s'%zipfilename, 'w') as Ribitol_myzip: for Ribitol_Images in Ribitol_weblogo_collection: Ribitol_myzip.write(Ribitol_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Bonded Interactions:</p>" print "No Interactions" ###############Web logo for Common Residues Section: NON bonding####################### Weblogo_dict_NH={} Weblogo_dict_NH1={} if bool(CommNH_graphdic1): for key in sorted(CommNH_graphdic1): for i in CommNH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_NH.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_NH.iteritems(): counted=dict(Counter(n)) Weblogo_dict_NH1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Ribitol_graph_filename+'_NHbonding'+'.zip' Ribitol_aminoacid_singlecode={} recoded={} for Ribitol_ligand_key, Ribitol_amino_frequency in Weblogo_dict_NH1.iteritems(): #print ligand_key for i in Ribitol_ligand_key: for Ribitol_amino,Ribitol_frequency in Ribitol_amino_frequency.iteritems(): for Ribitol_amino_3letter,Ribitol_code_frequency in aminoacid_code.iteritems(): if Ribitol_amino == Ribitol_amino_3letter: recoded[Ribitol_code_frequency]=Ribitol_frequency Ribitol_aminoacid_singlecode.setdefault('%s'%Ribitol_ligand_key,{}).update(recoded) recoded={} Ribitol_Frequency=1 instances=[] Ribitol_weblogo_collection=[] for Ribitol_ligand_key1, amino_frequency1 in Ribitol_aminoacid_singlecode.iteritems(): for Ribitol_Amino1, Ribitol_number in amino_frequency1.iteritems(): Ribitol_Frequency=1 while Ribitol_Frequency <= Ribitol_number: instances.append(Seq(Ribitol_Amino1, IUPAC.protein)) Ribitol_Frequency=Ribitol_Frequency+1 Ribitol_motif = motifs.create(instances) Ribitol_mymotif ='tmp/'+ Ribitol_graph_filename+ '_NH_'+ Ribitol_ligand_key1 +'.svg' Ribitol_motif.weblogo('%s'%Ribitol_mymotif,format='SVG',xaxis_label= '%s' %Ribitol_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Ribitol_weblogo_collection.append(Ribitol_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Ribitol_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" #initiation of weblog_row for Ribitol_image in sorted(Ribitol_weblogo_collection): print "<div class='weblogo_column'>" #initiation of weblog_column print "<embed src='%s#page=1&view=FitH ' />" %Ribitol_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='200' border='0'></iframe>"%Ribitol_image print "</div>"#closing of weblog_column print "</div>"#closing of weblog_row ####zip file with ZipFile('%s'%zipfilename, 'w') as Ribitol_myzip: for Ribitol_Images in Ribitol_weblogo_collection: Ribitol_myzip.write(Ribitol_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Nonbonded Interactions:</p>" print "No Interactions" print """ </div> </div> </div> """ # closing of Ribitol section print "<p align='center'>################################################################","</p>" print "<p style='font-size:20px; color:blue' align='center'>phosphate sub group structure","</p>" print '<p style=text-align:center>Download: <a href=%s download>All bonded,</a> '% phosphate_allH print ' <a href=%s download>All non-bonded,</a>'% phosphate_allNH print ' <a href=%s download>Common bonded,</a>'% phosphate_CommonH print ' <a href=%s download>Common non-bonded,</a>'% phosphate_CommonNH ,'</p>' print "<p align='center'>################################################################" ,"</p>" print "<button class='collapsible'>I. Compiled Bonded Interactions - Click to read Basic Statistics Information</button>"#Start of click drop down print "<div class='contentsection'>" print "<p style='font-size:20px; color:black' align='center'>" print " Number of Ligand atoms:", len(phosphate), "<br/>" print " Number of PDB IDs:", len(phosphate_allNH_Lig_Resdict.keys()), "<br/>" print "<div class='row'>"# spliting into two columns print "<div class='column'>"# spliting into two columns if bool(phosphate_allH_Lig_Resdict): print "Statistics of Bonded Intercations" print percentage(phosphate_allH_Lig_Resdict,phosphate) if bool(phosphate_allH_Lig_Resdict_distance): print distance_calc(phosphate_allH_Lig_Resdict_distance) print "</div>"# closing of first columns print "<div class='column'>" if bool(phosphate_allNH_Lig_Resdict): print "Statistics of Non-Bonded Intercations" print percentage(phosphate_allNH_Lig_Resdict,phosphate) if bool(phosphate_allNH_Lig_Resdict_distance): print distance_calc(phosphate_allNH_Lig_Resdict_distance) print "</div>"# closing of second columns print "</div>"#closing of row print "</div>"#End of click drop down print "<br/>" print """ <div class="grid"> <div class="col-2-3"> <div class="module"> """ if bool(phosphate_allH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" df_phosphate_allH_Lig_Resdict=pd.DataFrame.from_dict(phosphate_allH_Lig_Resdict).fillna('NIL') print (df_phosphate_allH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(phosphate_allH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################All Residues Colored Table for phosphate: H bonded################################ ####################All Residues Colored Table for phosphate: H bonded################################ H_templist4graph=[] H_graphdic1={} if bool(phosphate_graphdicH): for k,v in phosphate_graphdicH.iteritems(): #print k for value in v: H_templist4graph.append(value) samp=sorted(list(set(H_templist4graph))) H_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) H_templist4graph=[] length_listofcompiledresidues=[] for key,value in H_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(H_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in H_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(phosphate_allNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" df_phosphate_allNH_Lig_Resdict=pd.DataFrame.from_dict(phosphate_allNH_Lig_Resdict).fillna('NIL') print (df_phosphate_allNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(phosphate_allNH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" print "No Interactions" ####################All Residues Colored Table for phosphate: NON bonded################################ NH_templist4graph=[] NH_graphdic1={} if bool(phosphate_graphdicNH): for k,v in phosphate_graphdicNH.iteritems(): #print k for value in v: NH_templist4graph.append(value) samp=sorted(list(set(NH_templist4graph))) NH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) #print temlist #print samp NH_templist4graph=[] length_listofcompiledresidues=[] for key,value in NH_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(NH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in NH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "No Interactions" print """ </div> </div> """#closing of col-2-3 and module print """ <div class="col-2-3"> <div class="module"> """# initializing the middle column if bool(phosphate_CommonH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" df_phosphate_CommonH_Lig_Resdict=pd.DataFrame.from_dict(phosphate_CommonH_Lig_Resdict).fillna('NIL') print (df_phosphate_CommonH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(phosphate_CommonH_Lig_Resdict).to_html(justify='center')#for common ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################Common Residues Colored Table for phosphate : H bonded################################ CommH_templist4graph=[] CommH_graphdic1={} if bool(phosphate_common_graphdicH): for k,v in phosphate_common_graphdicH.iteritems(): for value in v: CommH_templist4graph.append(value) samp=sorted(list(set(CommH_templist4graph))) CommH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommH_templist4graph=[] length_listofcompiled_Common_residues=[] for key,value in CommH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommH_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(phosphate_CommonNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" df_phosphate_CommonNH_Lig_Resdict=pd.DataFrame.from_dict(phosphate_CommonNH_Lig_Resdict).fillna('NIL') print (df_phosphate_CommonNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(phosphate_CommonNH_Lig_Resdict).to_html(justify='center')#for Common ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" print "No Interactions" ####################Common Residues Colored Table for phosphate: NON bonded################################ CommNH_templist4graph=[] CommNH_graphdic1={} if bool(phosphate_common_graphdicNH): for k,v in phosphate_common_graphdicNH.iteritems(): #print k for value in v: CommNH_templist4graph.append(value) samp=sorted(list(set(CommNH_templist4graph))) CommNH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommNH_templist4graph=[] length_listofcompile_Common_dresidues=[] for key,value in CommNH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommNH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommNH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "No Interactions" print """ </div> </div> """# closinf of column and module div ###############Web logo for Common Residues Section: H bonding####################### print """ <div class="col-2-3"> <div class="module"> """ phosphate_graph_filename = str(uuid.uuid4()) Weblogo_dict_H={} Weblogo_dict_H1={} if bool (CommH_graphdic1): for key in sorted(CommH_graphdic1): for i in CommH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_H.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_H.iteritems(): counted=dict(Counter(n)) Weblogo_dict_H1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+phosphate_graph_filename+'_Hbonding'+'.zip' phosphate_aminoacid_singlecode={} aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} recoded={} for phosphate_ligand_key, phosphate_amino_frequency in Weblogo_dict_H1.iteritems(): #print ligand_key for i in phosphate_ligand_key: for phosphate_amino,phosphate_frequency in phosphate_amino_frequency.iteritems(): for phosphate_amino_3letter,phosphate_code_frequency in aminoacid_code.iteritems(): if phosphate_amino == phosphate_amino_3letter: recoded[phosphate_code_frequency]=phosphate_frequency phosphate_aminoacid_singlecode.setdefault('%s'%phosphate_ligand_key,{}).update(recoded) recoded={} phosphate_Frequency=1 instances=[] phosphate_weblogo_collection=[] for phosphate_ligand_key1, amino_frequency1 in phosphate_aminoacid_singlecode.iteritems(): for phosphate_Amino1, phosphate_number in amino_frequency1.iteritems(): phosphate_Frequency=1 while phosphate_Frequency <= phosphate_number: instances.append(Seq(phosphate_Amino1, IUPAC.protein)) phosphate_Frequency=phosphate_Frequency+1 phosphate_motif = motifs.create(instances) phosphate_mymotif ='tmp/'+ phosphate_graph_filename+ '_H_'+ phosphate_ligand_key1 +'.svg' phosphate_motif.weblogo('%s'%phosphate_mymotif,format='SVG',xaxis_label= '%s' %phosphate_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') phosphate_weblogo_collection.append(phosphate_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in phosphate_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" for phosphate_image in sorted(phosphate_weblogo_collection): print "<div class='weblogo_column'>" print "<embed src='%s#page=1&view=FitH ' />" %phosphate_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='100' border='0'></iframe>"%phosphate_image print "</div>" print "</div>" ####zip file with ZipFile('%s'%zipfilename, 'w') as phosphate_myzip: for phosphate_Images in phosphate_weblogo_collection: phosphate_myzip.write(phosphate_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Bonded Interactions:</p>" print "No Interactions" ###############Web logo for Common Residues Section: NON bonding####################### Weblogo_dict_NH={} Weblogo_dict_NH1={} if bool(CommNH_graphdic1): for key in sorted(CommNH_graphdic1): for i in CommNH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_NH.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_NH.iteritems(): counted=dict(Counter(n)) Weblogo_dict_NH1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+phosphate_graph_filename+'_NHbonding'+'.zip' phosphate_aminoacid_singlecode={} recoded={} for phosphate_ligand_key, phosphate_amino_frequency in Weblogo_dict_NH1.iteritems(): #print ligand_key for i in phosphate_ligand_key: for phosphate_amino,phosphate_frequency in phosphate_amino_frequency.iteritems(): for phosphate_amino_3letter,phosphate_code_frequency in aminoacid_code.iteritems(): if phosphate_amino == phosphate_amino_3letter: recoded[phosphate_code_frequency]=phosphate_frequency phosphate_aminoacid_singlecode.setdefault('%s'%phosphate_ligand_key,{}).update(recoded) recoded={} phosphate_Frequency=1 instances=[] phosphate_weblogo_collection=[] for phosphate_ligand_key1, amino_frequency1 in phosphate_aminoacid_singlecode.iteritems(): for phosphate_Amino1, phosphate_number in amino_frequency1.iteritems(): phosphate_Frequency=1 while phosphate_Frequency <= phosphate_number: instances.append(Seq(phosphate_Amino1, IUPAC.protein)) phosphate_Frequency=phosphate_Frequency+1 phosphate_motif = motifs.create(instances) phosphate_mymotif ='tmp/'+ phosphate_graph_filename+ '_NH_'+ phosphate_ligand_key1 +'.svg' phosphate_motif.weblogo('%s'%phosphate_mymotif,format='SVG',xaxis_label= '%s' %phosphate_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') phosphate_weblogo_collection.append(phosphate_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in phosphate_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" #initiation of weblog_row for phosphate_image in sorted(phosphate_weblogo_collection): print "<div class='weblogo_column'>" #initiation of weblog_column print "<embed src='%s#page=1&view=FitH ' />" %phosphate_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='200' border='0'></iframe>"%phosphate_image print "</div>"#closing of weblog_column print "</div>"#closing of weblog_row ####zip file with ZipFile('%s'%zipfilename, 'w') as phosphate_myzip: for phosphate_Images in phosphate_weblogo_collection: phosphate_myzip.write(phosphate_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo showing Common Nonbonded Interactions:</p>" print "No Interactions" print """ </div> </div> </div> """ # closing of phosphate section ##################################################### print "<p align='center'>################################################################","</p>" print "<p style='font-size:20px; color:blue' align='center'>Ribose sub group structure","</p>" print '<p style=text-align:center>Download: <a href=%s download>All bonded,</a> '% Ribose_allH print ' <a href=%s download>All non-bonded,</a>'% Ribose_allNH print ' <a href=%s download>Common bonded,</a>'% Ribose_CommonH print ' <a href=%s download>Common non-bonded,</a>'% Ribose_CommonNH ,'</p>' print "<p align='center'>################################################################" ,"</p>" print "<button class='collapsible'>I. Compiled Bonded Interactions - Click to read Basic Statistics Information</button>"#Start of click drop down print "<div class='contentsection'>" print "<p style='font-size:20px; color:black' align='center'>" print " Number of Ligand atoms:", len(Ribose), "<br/>" print " Number of PDB IDs:", len(Ribose_allNH_Lig_Resdict.keys()), "<br/>" print "<div class='row'>"# spliting into two columns print "<div class='column'>"# spliting into two columns if bool(Ribose_allH_Lig_Resdict): print "Statistics of Bonded Intercations" print percentage(Ribose_allH_Lig_Resdict,Ribose) if bool(Ribose_allH_Lig_Resdict_distance): print distance_calc(Ribose_allH_Lig_Resdict_distance) print "</div>"# closing of first columns print "<div class='column'>" if bool(Ribose_allNH_Lig_Resdict): print "Statistics of Non-Bonded Intercations" print percentage(Ribose_allNH_Lig_Resdict,Ribose) if bool(Ribose_allNH_Lig_Resdict_distance): print distance_calc(Ribose_allNH_Lig_Resdict_distance) print "</div>"# closing of second columns print "</div>"#closing of row print "</div>"#End of click drop down print "<br/>" print """ <div class="grid"> <div class="col-2-3"> <div class="module"> """#start of Ribose grid section #print Ribose_allH_Lig_Resdict if bool(Ribose_allH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" df_Ribose_allH_Lig_Resdict=pd.DataFrame.from_dict(Ribose_allH_Lig_Resdict).fillna('NIL') print (df_Ribose_allH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribose_allH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################All Residues Colored Table for Ribose: H bonded################################ H_templist4graph=[] H_graphdic1={} if bool(Ribose_graphdicH): for k,v in Ribose_graphdicH.iteritems(): #print k for value in v: H_templist4graph.append(value) samp=sorted(list(set(H_templist4graph))) H_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) H_templist4graph=[] length_listofcompiledresidues=[] for key,value in H_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(H_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in H_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Ribose_allNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" df_Ribose_allNH_Lig_Resdict=pd.DataFrame.from_dict(Ribose_allNH_Lig_Resdict).fillna('NIL') print (df_Ribose_allNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribose_allNH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" print "NO Interactions" ####################All Residues Colored Table for NON bonded################################ NH_templist4graph=[] NH_graphdic1={} if bool(Ribose_graphdicNH): for k,v in Ribose_graphdicNH.iteritems(): #print k for value in v: NH_templist4graph.append(value) samp=sorted(list(set(NH_templist4graph))) NH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) #print temlist #print samp NH_templist4graph=[] length_listofcompiledresidues=[] for key,value in NH_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(NH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in NH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "No Interactions" print """ </div> </div> """#closing of first col-2-3 and module print """ <div class="col-2-3"> <div class="module"> """ #initializing of second column if bool(Ribose_CommonH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" df_Ribose_CommonH_Lig_Resdict=pd.DataFrame.from_dict(Ribose_CommonH_Lig_Resdict).fillna('NIL') print (df_Ribose_CommonH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribose_CommonH_Lig_Resdict).to_html(justify='center')#for common ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################Common Residues Colored Table for Ribose : H bonded################################ CommH_templist4graph=[] CommH_graphdic1={} if bool(Ribose_common_graphdicH): for k,v in Ribose_common_graphdicH.iteritems(): for value in v: CommH_templist4graph.append(value) samp=sorted(list(set(CommH_templist4graph))) CommH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommH_templist4graph=[] length_listofcompiled_Common_residues=[] for key,value in CommH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommH_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Ribose_CommonNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" df_Ribose_CommonNH_Lig_Resdict=pd.DataFrame.from_dict(Ribose_CommonNH_Lig_Resdict).fillna('NIL') print (df_Ribose_CommonNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Ribose_CommonNH_Lig_Resdict).to_html(justify='center')#for Common ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" print "No Interactions" ####################Common Residues Colored Table for Ribose: NON bonded################################ CommNH_templist4graph=[] CommNH_graphdic1={} if bool(Ribose_common_graphdicNH): for k,v in Ribose_common_graphdicNH.iteritems(): #print k for value in v: CommNH_templist4graph.append(value) samp=sorted(list(set(CommNH_templist4graph))) CommNH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommNH_templist4graph=[] length_listofcompile_Common_dresidues=[] for key,value in CommNH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommNH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommNH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "No Interactions" print """ </div> </div> """# closinf of second column and module divi ###############Web logo for Common Residues Section: H bonding####################### print """ <div class="col-2-3"> <div class="module"> """ Ribose_graph_filename = str(uuid.uuid4()) Weblogo_dict_H={} Weblogo_dict_H1={} if bool (CommH_graphdic1): for key in sorted(CommH_graphdic1): for i in CommH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_H.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_H.iteritems(): counted=dict(Counter(n)) Weblogo_dict_H1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Ribose_graph_filename+'_Hbonding'+'.zip' Ribose_aminoacid_singlecode={} aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} recoded={} for Ribose_ligand_key, Ribose_amino_frequency in Weblogo_dict_H1.iteritems(): #print ligand_key for i in Ribose_ligand_key: for Ribose_amino,Ribose_frequency in Ribose_amino_frequency.iteritems(): for Ribose_amino_3letter,Ribose_code_frequency in aminoacid_code.iteritems(): if Ribose_amino == Ribose_amino_3letter: recoded[Ribose_code_frequency]=Ribose_frequency Ribose_aminoacid_singlecode.setdefault('%s'%Ribose_ligand_key,{}).update(recoded) recoded={} Ribose_Frequency=1 instances=[] Ribose_weblogo_collection=[] for Ribose_ligand_key1, amino_frequency1 in Ribose_aminoacid_singlecode.iteritems(): for Ribose_Amino1, Ribose_number in amino_frequency1.iteritems(): Ribose_Frequency=1 while Ribose_Frequency <= Ribose_number: instances.append(Seq(Ribose_Amino1, IUPAC.protein)) Ribose_Frequency=Ribose_Frequency+1 Ribose_motif = motifs.create(instances) Ribose_mymotif ='tmp/'+ Ribose_graph_filename+ '_H_'+ Ribose_ligand_key1 +'.svg' Ribose_motif.weblogo('%s'%Ribose_mymotif,format='SVG',xaxis_label= '%s' %Ribose_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Ribose_weblogo_collection.append(Ribose_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Ribose_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" for Ribose_image in sorted(Ribose_weblogo_collection): print "<div class='weblogo_column'>" print "<embed src='%s#page=1&view=FitH ' />" %Ribose_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='100' border='0'></iframe>"%Ribose_image print "</div>" print "</div>" ####zip file with ZipFile('%s'%zipfilename, 'w') as Ribose_myzip: for Ribose_Images in Ribose_weblogo_collection: Ribose_myzip.write(Ribose_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo for Common Bonded Interactions:</p>" print "NO Interactions" ###############Web logo for Common Residues Section: NON bonding####################### Weblogo_dict_NH={} Weblogo_dict_NH1={} if bool(CommNH_graphdic1): for key in sorted(CommNH_graphdic1): for i in CommNH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_NH.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_NH.iteritems(): counted=dict(Counter(n)) Weblogo_dict_NH1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Ribose_graph_filename+'_NHbonding'+'.zip' Ribose_aminoacid_singlecode={} recoded={} for Ribose_ligand_key, Ribose_amino_frequency in Weblogo_dict_NH1.iteritems(): #print ligand_key for i in Ribose_ligand_key: for Ribose_amino,Ribose_frequency in Ribose_amino_frequency.iteritems(): for Ribose_amino_3letter,Ribose_code_frequency in aminoacid_code.iteritems(): if Ribose_amino == Ribose_amino_3letter: recoded[Ribose_code_frequency]=Ribose_frequency Ribose_aminoacid_singlecode.setdefault('%s'%Ribose_ligand_key,{}).update(recoded) recoded={} Ribose_Frequency=1 instances=[] Ribose_weblogo_collection=[] for Ribose_ligand_key1, amino_frequency1 in Ribose_aminoacid_singlecode.iteritems(): for Ribose_Amino1, Ribose_number in amino_frequency1.iteritems(): Ribose_Frequency=1 while Ribose_Frequency <= Ribose_number: instances.append(Seq(Ribose_Amino1, IUPAC.protein)) Ribose_Frequency=Ribose_Frequency+1 Ribose_motif = motifs.create(instances) Ribose_mymotif ='tmp/'+ Ribose_graph_filename+ '_NH_'+ Ribose_ligand_key1 +'.svg' Ribose_motif.weblogo('%s'%Ribose_mymotif,format='SVG',xaxis_label= '%s' %Ribose_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Ribose_weblogo_collection.append(Ribose_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Ribose_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:" print "<div class='weblogo_row'>" #initiation of weblog_row for Ribose_image in sorted(Ribose_weblogo_collection): print "<div class='weblogo_column'>" #initiation of weblog_column print "<embed src='%s#page=1&view=FitH ' />" %Ribose_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='200' border='0'></iframe>"%Ribose_image print "</div>"#closing of weblog_column print "</div>"#closing of weblog_row ####zip file with ZipFile('%s'%zipfilename, 'w') as Ribose_myzip: for Ribose_Images in Ribose_weblogo_collection: Ribose_myzip.write(Ribose_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo for Common Nonbonded Interactions:</p>" print "No Interaction" print """ </div> </div> </div> """ # closing of RiboSE section ############################## print "<p align='center'>################################################################","</p>" print "<p style='font-size:20px; color:blue' align='center'>Adenin sub group structure","</p>" print '<p style=text-align:center>Download: <a href=%s download>All bonded,</a> '% Adenin_allH print ' <a href=%s download>All non-bonded,</a>'% Adenin_allNH print ' <a href=%s download>Common bonded,</a>'% Adenin_CommonH print ' <a href=%s download>Common non-bonded,</a>'% Adenin_CommonNH ,'</p>' print "<p align='center'>################################################################" ,"</p>" print "<button class='collapsible'>I. Compiled Bonded Interactions - Click to read Basic Statistics Information</button>"#Start of click drop down print "<div class='contentsection'>" print "<p style='font-size:20px; color:black' align='center'>" print " Number of Ligand atoms:", len(Adenin), "<br/>" print " Number of PDB IDs:", len(Adenin_allNH_Lig_Resdict.keys()), "<br/>" print "<div class='row'>"# spliting into two columns print "<div class='column'>"# spliting into two columns if bool(Adenin_allH_Lig_Resdict): print "Statistics of Bonded Intercations" print percentage(Adenin_allH_Lig_Resdict,Adenin) else: print "No data" if bool(Adenin_allH_Lig_Resdict_distance): print distance_calc(Adenin_allH_Lig_Resdict_distance) print "</div>"# closing of first columns print "<div class='column'>" if bool(Adenin_allNH_Lig_Resdict): print "Statistics of Non-Bonded Intercations" print percentage(Adenin_allNH_Lig_Resdict,Adenin) if bool(Adenin_allNH_Lig_Resdict_distance): print distance_calc(Adenin_allNH_Lig_Resdict_distance) print "</div>"# closing of second columns print "</div>"#closing of row print "</div>"#End of click drop down print "<br/>" print """ <div class="grid"> <div class="col-2-3"> <div class="module"> """#Initialization of Adenin grid section if bool(Adenin_allH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" df_Adenin_allH_Lig_Resdict=pd.DataFrame.from_dict(Adenin_allH_Lig_Resdict).fillna('NIL') print (df_Adenin_allH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Adenin_allH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: hydrogen bonds contacts" ,"</p>" print "No Interactions" ####################All Residues Colored Table for Adenin: H bonded################################ H_templist4graph=[] H_graphdic1={} if bool(Adenin_graphdicH): for k,v in Adenin_graphdicH.iteritems(): #print k for value in v: H_templist4graph.append(value) samp=sorted(list(set(H_templist4graph))) H_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) H_templist4graph=[] length_listofcompiledresidues=[] for key,value in H_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(H_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in H_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: hydrogen bonds contacts ","</p>" print "No Interactions" if bool(Adenin_allNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" df_Adenin_allNH_Lig_Resdict=pd.DataFrame.from_dict(Adenin_allNH_Lig_Resdict).fillna('NIL') print (df_Adenin_allNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Adenin_allNH_Lig_Resdict).to_html(justify='center')#for all ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of residues: non-bonded contacts","</p>" print "No Interactions" ####################All Residues Colored Table for NON bonded################################ NH_templist4graph=[] NH_graphdic1={} if bool(Adenin_graphdicNH): for k,v in Adenin_graphdicNH.iteritems(): #print k for value in v: NH_templist4graph.append(value) samp=sorted(list(set(NH_templist4graph))) NH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) #print temlist #print samp NH_templist4graph=[] length_listofcompiledresidues=[] for key,value in NH_graphdic1.iteritems(): for i in value: valu=i.split(', ') #print valu #print len(valu) length_listofcompiledresidues.append(len(valu)) length_ofcell=max(length_listofcompiledresidues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(NH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in NH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of amino acids: non-bonded contacts","</p>" print "No Interactions" print """ </div> </div> """#closing of col-2-3 and module print """ <div class="col-2-3"> <div class="module"> """ if bool(Adenin_CommonH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" df_Adenin_CommonH_Lig_Resdict=pd.DataFrame.from_dict(Adenin_CommonH_Lig_Resdict).fillna('NIL') print (df_Adenin_CommonH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Adenin_CommonH_Lig_Resdict).to_html(justify='center')#for common ligand atoms - hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: hydrogen bonds contacts" ,"</p>" print "<p> No Common Interactions</p>" ####################Common Residues Colored Table for Adenin : H bonded################################ CommH_templist4graph=[] CommH_graphdic1={} if bool(Adenin_common_graphdicH): for k,v in Adenin_common_graphdicH.iteritems(): for value in v: CommH_templist4graph.append(value) samp=sorted(list(set(CommH_templist4graph))) CommH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommH_templist4graph=[] length_listofcompiled_Common_residues=[] for key,value in CommH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) #print "<br/>" print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommH_graphdic1[key]: dat1= g1.split(', ') for H_k3 in dat1: print "<td align='center'>" #print k3 if H_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%H_k3 if H_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%H_k3 if H_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%H_k3 if H_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%H_k3 if H_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%H_k3 if H_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%H_k3 if H_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%H_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based color-coding of common amino acids: hydrogen bonds contacts ","</p>" print "<p> No Common Atoms Identified</p>" if bool(Adenin_CommonNH_Lig_Resdict): print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" df_Adenin_CommonNH_Lig_Resdict=pd.DataFrame.from_dict(Adenin_CommonNH_Lig_Resdict).fillna('NIL') print (df_Adenin_CommonNH_Lig_Resdict.to_html(justify='center')) #print pd.DataFrame.from_dict(Adenin_CommonNH_Lig_Resdict).to_html(justify='center')#for Common ligand atoms - Non hydrogen bonded else: print "<p style='font-size:20px; color:brown'>List of common residues: non-bonded contacts","</p>" print "No Interactions" ####################Common Residues Colored Table for Adenin: NON bonded################################ CommNH_templist4graph=[] CommNH_graphdic1={} if bool(Adenin_common_graphdicNH): for k,v in Adenin_common_graphdicNH.iteritems(): #print k for value in v: CommNH_templist4graph.append(value) samp=sorted(list(set(CommNH_templist4graph))) CommNH_graphdic1.setdefault('%s'%k,[]).append(', '.join(samp)) CommNH_templist4graph=[] length_listofcompile_Common_dresidues=[] for key,value in CommNH_graphdic1.iteritems(): for i in value: valu=i.split(', ') length_listofcompiled_Common_residues.append(len(valu)) length_ofcell=max(length_listofcompiled_Common_residues) print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "<table border='1'>" print "<tr>" print "<th col width='60'>Ligand Atoms</th>" print "<th colspan='%d'>Compiled List of Common Residues From Analysed Protein Structures</th>"% length_ofcell print "</tr>" for key in sorted(CommNH_graphdic1.iterkeys()): print "<td align='center'>%s</td>" %key for g1 in CommNH_graphdic1[key]: dat1= g1.split(', ') for NH_k3 in dat1: print "<td align='center'>" #print k3 if NH_k3.startswith(('ALA','ILE','LEU','MET','MSE','VAL')): print "<b><font color='pink'>%s</font></b>"%NH_k3 if NH_k3.startswith(('PHE','TRP', 'TYR')): print " <b><font color='orange'>%s</font></b>"%NH_k3 if NH_k3.startswith(('LYS','ARG', 'HIS')): print " <b><font color='red'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLU','ASP')): print " <b><font color='green'>%s</font></b>"%NH_k3 if NH_k3.startswith(('ASN','GLN','SER','THR')): print " <b><font color='blue'>%s</font></b>"%NH_k3 if NH_k3.startswith(('GLY','PRO')): print " <b><font color='magenta'>%s</font></b>"%NH_k3 if NH_k3.startswith(('CYS','CME')): print " <b><font color='yellow'>%s</font></b>"%NH_k3 print "</td>" #print "<tr>" print "</tr>" print "</table>" else: print "<p style='font-size:20px; color:brown'> Physicochemical property based coloring of Common amino acids:Nonbonded Contacts","</p>" print "No Interactions" print """ </div> </div> """# closinf of column and module divi ###############Web logo for Common Residues Section: H bonding####################### print """ <div class="col-2-3"> <div class="module"> """ Adenin_graph_filename = str(uuid.uuid4()) Weblogo_dict_H={} Weblogo_dict_H1={} if bool(CommH_graphdic1): for key in sorted(CommH_graphdic1): for i in CommH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_H.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_H.iteritems(): counted=dict(Counter(n)) Weblogo_dict_H1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Adenin_graph_filename+'_Hbonding'+'.zip' Adenin_aminoacid_singlecode={} aminoacid_code={'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} recoded={} for Adenin_ligand_key, Adenin_amino_frequency in Weblogo_dict_H1.iteritems(): #print ligand_key for i in Adenin_ligand_key: for Adenin_amino,Adenin_frequency in Adenin_amino_frequency.iteritems(): for Adenin_amino_3letter,Adenin_code_frequency in aminoacid_code.iteritems(): if Adenin_amino == Adenin_amino_3letter: recoded[Adenin_code_frequency]=Adenin_frequency Adenin_aminoacid_singlecode.setdefault('%s'%Adenin_ligand_key,{}).update(recoded) recoded={} Adenin_Frequency=1 instances=[] Adenin_weblogo_collection=[] for Adenin_ligand_key1, amino_frequency1 in Adenin_aminoacid_singlecode.iteritems(): for Adenin_Amino1, Adenin_number in amino_frequency1.iteritems(): Adenin_Frequency=1 while Adenin_Frequency <= Adenin_number: instances.append(Seq(Adenin_Amino1, IUPAC.protein)) Adenin_Frequency=Adenin_Frequency+1 Adenin_motif = motifs.create(instances) Adenin_mymotif ='tmp/'+ Adenin_graph_filename+ '_H_'+ Adenin_ligand_key1 +'.svg' Adenin_motif.weblogo('%s'%Adenin_mymotif,format='SVG',xaxis_label= '%s' %Adenin_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Adenin_weblogo_collection.append(Adenin_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Adenin_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:</p>" print "<div class='weblogo_row'>" for Adenin_image in sorted(Adenin_weblogo_collection): print "<div class='weblogo_column'>" print "<embed src='%s#page=1&view=FitH ' />" %Adenin_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='100' border='0'></iframe>"%Adenin_image print "</div>" print "</div>" ####zip file with ZipFile('%s'%zipfilename, 'w') as Adenin_myzip: for Adenin_Images in Adenin_weblogo_collection: Adenin_myzip.write(Adenin_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo for Common bonded Interactions:</p>" print "No Interactions" ###############Web logo for Common Residues Section: NON bonding####################### Weblogo_dict_NH={} Weblogo_dict_NH1={} if bool(CommNH_graphdic1): for key in sorted(CommNH_graphdic1): for i in CommNH_graphdic1[key]: tems=i.split(', ') for items in tems: se=re.split('([0-9])' , items) Weblogo_dict_NH.setdefault('%s'%key,[]).append(se[0]) for m,n in Weblogo_dict_NH.iteritems(): counted=dict(Counter(n)) Weblogo_dict_NH1.setdefault('%s'%m,{}).update(counted) zipfilename='tmp/'+Adenin_graph_filename+'_NHbonding'+'.zip' Adenin_aminoacid_singlecode={} recoded={} for Adenin_ligand_key, Adenin_amino_frequency in Weblogo_dict_NH1.iteritems(): #print ligand_key for i in Adenin_ligand_key: for Adenin_amino,Adenin_frequency in Adenin_amino_frequency.iteritems(): for Adenin_amino_3letter,Adenin_code_frequency in aminoacid_code.iteritems(): if Adenin_amino == Adenin_amino_3letter: recoded[Adenin_code_frequency]=Adenin_frequency Adenin_aminoacid_singlecode.setdefault('%s'%Adenin_ligand_key,{}).update(recoded) recoded={} Adenin_Frequency=1 instances=[] Adenin_weblogo_collection=[] for Adenin_ligand_key1, amino_frequency1 in Adenin_aminoacid_singlecode.iteritems(): for Adenin_Amino1, Adenin_number in amino_frequency1.iteritems(): Adenin_Frequency=1 while Adenin_Frequency <= Adenin_number: instances.append(Seq(Adenin_Amino1, IUPAC.protein)) Adenin_Frequency=Adenin_Frequency+1 Adenin_motif = motifs.create(instances) Adenin_mymotif ='tmp/'+ Adenin_graph_filename+ '_NH_'+ Adenin_ligand_key1 +'.svg' Adenin_motif.weblogo('%s'%Adenin_mymotif,format='SVG',xaxis_label= '%s' %Adenin_ligand_key1,show_errorbars= False, color_scheme= 'color_chemistry') Adenin_weblogo_collection.append(Adenin_mymotif) instances=[] weblogo_images=' '.join(str(x) for x in Adenin_weblogo_collection) print "<p style='font-size:20px; color:brown'> Weblogo showing the frequency of Residues binding to Ligand atoms for the selected structures:</p>" print "<div class='weblogo_row'>" #initiation of weblog_row for Adenin_image in sorted(Adenin_weblogo_collection): print "<div class='weblogo_column'>" #initiation of weblog_column print "<embed src='%s#page=1&view=FitH ' />" %Adenin_image #print "<iframe src='%s#page=1&view=FitH ' width='200' height='200' border='0'></iframe>"%Adenin_image print "</div>"#closing of weblog_column print "</div>"#closing of weblog_row ####zip file with ZipFile('%s'%zipfilename, 'w') as Adenin_myzip: for Adenin_Images in Adenin_weblogo_collection: Adenin_myzip.write(Adenin_Images) else: print "<p style='font-size:20px; color:brown'> Weblogo for Common Nonbonded Interactions:</p>" print "No Interactions" ###########To write the dataframes to excel for download Nicot_allH=pd.DataFrame.from_dict(Nicot_allH_Lig_Resdict) Nicot_allH.to_excel(writer, sheet_name='Nicot_allH') Nicot_allNH=pd.DataFrame.from_dict(Nicot_allNH_Lig_Resdict) Nicot_allNH.to_excel(writer, sheet_name='Nicot_allNH') Nicot_CommonH=pd.DataFrame.from_dict(Nicot_CommonH_Lig_Resdict) Nicot_CommonH.to_excel(writer, sheet_name='Nicot_CommonH') Nicot_CommonNH=pd.DataFrame.from_dict(Nicot_CommonNH_Lig_Resdict) Nicot_CommonNH.to_excel(writer, sheet_name='Nicot_CommonNH') Ribitol_allH=pd.DataFrame.from_dict(Ribitol_allH_Lig_Resdict) Ribitol_allH.to_excel(writer, sheet_name='Ribitol_allH') Ribitol_allNH=pd.DataFrame.from_dict(Ribitol_allNH_Lig_Resdict) Ribitol_allNH.to_excel(writer, sheet_name='Ribitol_allNH') Ribitol_CommonH=pd.DataFrame.from_dict(Ribitol_CommonH_Lig_Resdict) Ribitol_CommonH.to_excel(writer, sheet_name='Ribitol_CommonH') Ribitol_CommonNH=pd.DataFrame.from_dict(Ribitol_CommonNH_Lig_Resdict) Ribitol_CommonNH.to_excel(writer, sheet_name='Ribitol_CommonNH') phosphate_allH=pd.DataFrame.from_dict(phosphate_allH_Lig_Resdict) phosphate_allH.to_excel(writer, sheet_name='phosphate_allH') phosphate_allNH=pd.DataFrame.from_dict(phosphate_allNH_Lig_Resdict) phosphate_allNH.to_excel(writer, sheet_name='phosphate_allNH') phosphate_CommonH=pd.DataFrame.from_dict(phosphate_CommonH_Lig_Resdict) phosphate_CommonH.to_excel(writer, sheet_name='phosphate_CommonH') phosphate_CommonNH=pd.DataFrame.from_dict(phosphate_CommonNH_Lig_Resdict) phosphate_CommonNH.to_excel(writer, sheet_name='phosphate_CommonNH') Ribose_allH=pd.DataFrame.from_dict(Ribose_allH_Lig_Resdict) Ribose_allH.to_excel(writer, sheet_name='Ribose_allH') Ribose_allNH=pd.DataFrame.from_dict(Ribose_allNH_Lig_Resdict) Ribose_allNH.to_excel(writer, sheet_name='Ribose_allNH') Ribose_CommonH=pd.DataFrame.from_dict(Ribose_CommonH_Lig_Resdict) Ribose_CommonH.to_excel(writer, sheet_name='Ribose_CommonH') Ribose_CommonNH=pd.DataFrame.from_dict(Ribose_CommonNH_Lig_Resdict) Ribose_CommonNH.to_excel(writer, sheet_name='Ribose_CommonNH') Adenin_allH=pd.DataFrame.from_dict(Adenin_allH_Lig_Resdict) Adenin_allH.to_excel(writer, sheet_name='Adenin_allH') Adenin_allNH=pd.DataFrame.from_dict(Adenin_allNH_Lig_Resdict) Adenin_allNH.to_excel(writer, sheet_name='Adenin_allNH') Adenin_CommonH=pd.DataFrame.from_dict(Adenin_CommonH_Lig_Resdict) Adenin_CommonH.to_excel(writer, sheet_name='Adenin_CommonH') Adenin_CommonNH=pd.DataFrame.from_dict(Adenin_CommonNH_Lig_Resdict) Adenin_CommonNH.to_excel(writer, sheet_name='Adenin_CommonNH') writer.save() print """ </div> </div> </div> """ # closing of Adenin section ####Java script#### print """ <script> var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); } </script> """ ################### print "</body>" print "</html>"
43.124659
230
0.602736
21,083
173,663
4.729071
0.031637
0.026679
0.031293
0.021063
0.871047
0.853886
0.820888
0.775022
0.733639
0.714121
0
0.011495
0.255593
173,663
4,026
231
43.13537
0.759747
0.103741
0
0.684043
0
0.041489
0.224477
0.059838
0.010638
0
0
0
0
0
null
null
0
0.007092
null
null
0.26844
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
7
46be58177ae663a555c829902f79d75560404140
9,698
py
Python
main.py
AkeelMedina22/Packet-Filtering-using-Splay-Trees-and-Skip-Lists
28ccc7ef410e8de763b4ac55af2a2a8342f0a239
[ "MIT" ]
null
null
null
main.py
AkeelMedina22/Packet-Filtering-using-Splay-Trees-and-Skip-Lists
28ccc7ef410e8de763b4ac55af2a2a8342f0a239
[ "MIT" ]
null
null
null
main.py
AkeelMedina22/Packet-Filtering-using-Splay-Trees-and-Skip-Lists
28ccc7ef410e8de763b4ac55af2a2a8342f0a239
[ "MIT" ]
null
null
null
from Rule_Set import Rule_Set from Packet import Packet from Skip_List import SkipList from splaytree import SplayTree import matplotlib.pyplot as plt import numpy as np import time # ACL2 IP Packets and Rule Set rules = Rule_Set() rules.get_rules("Data_set/acl2/acl2_8k/acl2-8k.txt") packet_8k = Packet() packet_8k.get_packets("Data_set/acl2/acl2_8k/acl8k_header8k/skewness 0.txt") packet_32k = Packet() packet_32k.get_packets("Data_set/acl2/acl2_8k/acl8k_header32k/skewness 0.txt") packet_128k = Packet() packet_128k.get_packets( "Data_set/acl2/acl2_8k/acl8k_header128/skewness 0.txt") # ICP2 IP Packets and Rule Set # rules = Rule_Set() # rules.get_rules("Data_set/ip2/ipc2_8k/ipc2-8k.txt") # packet_8k = Packet() # packet_8k.get_packets("Data_set/ip2/ipc2_8k/ipc8k_header8k/skewness 0.txt") # packet_32k = Packet() # packet_32k.get_packets("Data_set/ip2/ipc2_8k/ipc8k_header32k/skewness 0.txt") # packet_128k = Packet() # packet_128k.get_packets( # "Data_set/ip2/ipc2_8k/ipc8k_header128k/skewness 0.txt") # ########################################################################################## # Start of Protocol Search Packet print("Protocol Search: ") print() # Skip List skip_rules = SkipList() for i, j in rules.protocol.items(): skip_rules.insert(i, j) skip_times = [] start = time.time() output = [] for j in packet_8k.packets: if skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 8k Skip List: ", end-start) start = time.time() output = [] for j in packet_32k.packets: if skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 32k Skip List: ", end-start) start = time.time() output = [] for j in packet_128k.packets: if skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 128k Skip List: ", end-start) print() plt.scatter([8, 32, 128], skip_times, color='red') plt.plot([8, 32, 128], skip_times, color='red') # ################################################################################## # Splay Tree Protocol Search splay_rules = SplayTree() for i, j in rules.protocol.items(): splay_rules.insert(i, j) splay_times = [] start = time.time() output = [] for j in packet_8k.packets: if splay_rules.find(j[5]): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 8k Splay tree: ", end-start) start = time.time() output = [] for j in packet_32k.packets: if splay_rules.find(j[5]): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 32k splay tree: ", end-start) start = time.time() output = [] for j in packet_128k.packets: if isinstance(splay_rules.find(j[5]), int): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 128k splay tree: ", end-start) print() plt.scatter([8, 32, 128], splay_times, color='blue') plt.plot([8, 32, 128], splay_times, color='blue') labels = ['Skip List', 'Splay Tree'] plt.legend(labels=labels) plt.ylabel("Time") plt.xlabel("Number of Packets") plt.title("Protocol Search") plt.show() ################################################################################## # Start of IP Packet Search print("IP Packet Search: ") print() # Skip List source_IP_skip_rules = SkipList() dest_IP_skip_rules = SkipList() source_Port_skip_rules = SkipList() dest_Port_skip_rules = SkipList() protocol_skip_rules = SkipList() for i, j in rules.source_IP.items(): source_IP_skip_rules.insert(int(i), j) for i, j in rules.dest_IP.items(): dest_IP_skip_rules.insert(int(i), j) for i, j in rules.source_Port.items(): source_Port_skip_rules.insert(int(i), j) for i, j in rules.dest_Port.items(): dest_Port_skip_rules.insert(int(i), j) for i, j in rules.protocol.items(): protocol_skip_rules.insert(int(i), j) start = time.time() output = [] skip_times = [] for j in packet_8k.packets: if source_IP_skip_rules.find(j[1]) and dest_IP_skip_rules.find(j[2]) and \ source_Port_skip_rules.find(j[3]) and dest_Port_skip_rules.find(j[4]) and \ protocol_skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 8k Skip List: ", end-start) try: file = open("Data_set/acl2/acl2_8k/acl8k_header8k/SkipListFilter.txt", "x") except: file = open("Data_set/acl2/acl2_8k/acl8k_header8k/SkipListFilter.txt", "w") for element in output: packet = [str(i) for i in packet_8k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() start = time.time() output = [] for j in packet_32k.packets: if source_IP_skip_rules.find(j[1]) and dest_IP_skip_rules.find(j[2]) and \ source_Port_skip_rules.find(j[3]) and dest_Port_skip_rules.find(j[4]) and \ protocol_skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 32k Skip List: ", end-start) try: file = open("Data_set/acl2/acl2_8k/acl8k_header32k/SkipListFilter.txt", "x") except: file = open("Data_set/acl2/acl2_8k/acl8k_header32k/SkipListFilter.txt", "w") for element in output: packet = [str(i) for i in packet_32k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() start = time.time() output = [] for j in packet_128k.packets: if source_IP_skip_rules.find(j[1]) and dest_IP_skip_rules.find(j[2]) and \ source_Port_skip_rules.find(j[3]) and dest_Port_skip_rules.find(j[4]) and \ protocol_skip_rules.find(j[5]): output.append(j[0]) end = time.time() skip_times.append(end-start) print("Time 128k Skip List: ", end-start) print() try: file = open("Data_set/acl2/acl2_8k/acl8k_header128/SkipListFilter.txt", "x") except: file = open("Data_set/acl2/acl2_8k/acl8k_header128/SkipListFilter.txt", "w") for element in output: packet = [str(i) for i in packet_128k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() plt.scatter([8, 32, 128], skip_times, color='red') plt.plot([8, 32, 128], skip_times, color='red') ################################################################################## # Splay Tree source_IP_splay_rules = SplayTree() dest_IP_splay_rules = SplayTree() source_Port_splay_rules = SplayTree() dest_Port_splay_rules = SplayTree() protocol_splay_rules = SplayTree() for i, j in rules.source_IP.items(): source_IP_splay_rules.insert(int(i), j) for i, j in rules.dest_IP.items(): dest_IP_splay_rules.insert(int(i), j) for i, j in rules.source_Port.items(): source_Port_splay_rules.insert(int(i), j) for i, j in rules.dest_Port.items(): dest_Port_splay_rules.insert(int(i), j) for i, j in rules.protocol.items(): protocol_splay_rules.insert(int(i), j) start = time.time() output = [] splay_times = [] for j in packet_8k.packets: if source_IP_splay_rules.find(j[1]) and dest_IP_splay_rules.find(j[2]) and \ source_Port_splay_rules.find(j[3]) and dest_Port_splay_rules.find(j[4]) and \ protocol_splay_rules.find(j[5]): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 8k Splay tree: ", end-start) try: file = open("Data_set/acl2/acl2_8k/acl8k_header8k/SplayTreeFilter.txt", "x") except: file = open("Data_set/acl2/acl2_8k/acl8k_header8k/SplayTreeFilter.txt", "w") for element in output: packet = [str(i) for i in packet_8k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() start = time.time() output = [] for j in packet_32k.packets: if source_IP_splay_rules.find(j[1]) and dest_IP_splay_rules.find(j[2]) and \ source_Port_splay_rules.find(j[3]) and dest_Port_splay_rules.find(j[4]) and \ protocol_splay_rules.find(j[5]): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 32k splay tree: ", end-start) try: file = open("Data_set/acl2/acl2_8k/acl8k_header32k/SplayTreeFilter.txt", "x") except: file = open("Data_set/acl2/acl2_8k/acl8k_header32k/SplayTreeFilter.txt", "w") for element in output: packet = [str(i) for i in packet_32k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() start = time.time() output = [] for j in packet_128k.packets: if source_IP_splay_rules.find(j[1]) and dest_IP_splay_rules.find(j[2]) and \ source_Port_splay_rules.find(j[3]) and dest_Port_splay_rules.find(j[4]) and \ protocol_splay_rules.find(j[5]): output.append(j[0]) end = time.time() splay_times.append(end-start) print("Time 128k splay tree: ", end-start) try: file = open( "Data_set/acl2/acl2_8k/acl8k_header128/SplayTreeFilter.txt", "x") except: file = open( "Data_set/acl2/acl2_8k/acl8k_header128/SplayTreeFilter.txt", "w") for element in output: packet = [str(i) for i in packet_128k.packets[element][1:]] file.write(" ".join(packet) + "\n") file.close() plt.scatter([8, 32, 128], splay_times, color='blue') plt.plot([8, 32, 128], splay_times, color='blue') labels = ['Skip List', 'Splay Tree'] plt.legend(labels=labels) plt.ylabel("Time") plt.xlabel("Number of Packets") plt.title("IP Packet Search") plt.show()
23.945679
93
0.641163
1,473
9,698
4.029192
0.065173
0.054591
0.060657
0.04246
0.888795
0.882898
0.881382
0.875484
0.843808
0.832013
0
0.039359
0.182615
9,698
404
94
24.004951
0.709348
0.056816
0
0.763485
0
0
0.156433
0.100632
0
0
0
0
0
1
0
false
0
0.029046
0
0.029046
0.078838
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
46d9da4b9a2e4061ad0ec881ba6d3301b4377f97
50,964
py
Python
tigershark/parsers/M270_4010_X092_A1.py
CloudCray/TigerShark
e27f1e775652576743518d9f2dfd57266f0c541f
[ "BSD-3-Clause" ]
19
2016-05-09T01:30:37.000Z
2022-03-15T15:51:24.000Z
tigershark/parsers/M270_4010_X092_A1.py
CloudCray/TigerShark
e27f1e775652576743518d9f2dfd57266f0c541f
[ "BSD-3-Clause" ]
10
2016-04-11T14:55:54.000Z
2021-08-07T15:41:14.000Z
tigershark/parsers/M270_4010_X092_A1.py
CloudCray/TigerShark
e27f1e775652576743518d9f2dfd57266f0c541f
[ "BSD-3-Clause" ]
11
2015-10-15T16:12:39.000Z
2021-03-22T19:33:56.000Z
# # Generated by TigerShark.tools.convertPyX12 on 2012-10-03 14:38:27.454816 # from tigershark.X12.parse import Message, Loop, Segment, Composite, Element, Properties parsed_270_HEADER = Loop( u'HEADER', Properties(looptype=u'wrapper',repeat=u'1',pos=u'015',req_sit=u'R',desc=u'Table 1 - Header'), Segment( u'BHT', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'020',desc=u'Beginning of Hierarchical Transaction'), Element( u'BHT01', Properties(desc=u'Hierarchical Structure Code', req_sit=u'R', data_type=(u'ID',u'4',u'4'), position=1, codes=[u'0022'] ) ), Element( u'BHT02', Properties(desc=u'Transaction Set Purpose Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=2, codes=[u'01', u'13', u'36'] ) ), Element( u'BHT03', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=3, codes=[] ) ), Element( u'BHT04', Properties(desc=u'Date', req_sit=u'R', data_type=(u'DT',u'8',u'8'), position=4, codes=[] ) ), Element( u'BHT05', Properties(desc=u'Time', req_sit=u'R', data_type=(u'TM',u'4',u'8'), position=5, codes=[] ) ), Element( u'BHT06', Properties(desc=u'Transaction Type Code', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=6, codes=[u'RT', u'RU'] ) ), ), ) parsed_270_2100A = Loop( u'2100A', Properties(looptype='',repeat=u'1',pos=u'030',req_sit=u'R',desc=u'Information Source Name'), Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Information Source Name'), Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'2B', u'36', u'GP', u'P5', u'PR'] ) ), Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2, codes=[u'1', u'2'] ) ), Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3, codes=[] ) ), Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4, codes=[] ) ), Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5, codes=[] ) ), Element( u'NM106', Properties(desc=u'Name Prefix', req_sit=u'N', data_type=(u'AN',u'1',u'10'), position=6, codes=[] ) ), Element( u'NM107', Properties(desc=u'Name Suffix', req_sit=u'S', data_type=(u'AN',u'1',u'10'), position=7, codes=[] ) ), Element( u'NM108', Properties(desc=u'Identification Code Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=8, codes=[u'24', u'46', u'FI', u'NI', u'PI', u'XV', u'XX'] ) ), Element( u'NM109', Properties(desc=u'Identification Code', req_sit=u'R', data_type=(u'AN',u'2',u'80'), position=9, codes=[] ) ), Element( u'NM110', Properties(desc=u'Entity Relationship Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=10, codes=[] ) ), Element( u'NM111', Properties(desc=u'Entity Identifier Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), ), ) parsed_270_2100B = Loop( u'2100B', Properties(looptype='',repeat=u'1',pos=u'030',req_sit=u'R',desc=u'Information Receiver Name'), Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Information Receiver Name'), Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'1P', u'2B', u'36', u'80', u'FA', u'GP', u'P5', u'PR'] ) ), Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2, codes=[u'1', u'2'] ) ), Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3, codes=[] ) ), Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4, codes=[] ) ), Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5, codes=[] ) ), Element( u'NM106', Properties(desc=u'Name Prefix', req_sit=u'N', data_type=(u'AN',u'1',u'10'), position=6, codes=[] ) ), Element( u'NM107', Properties(desc=u'Name Suffix', req_sit=u'S', data_type=(u'AN',u'1',u'10'), position=7, codes=[] ) ), Element( u'NM108', Properties(desc=u'Identification Code Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=8, codes=[u'24', u'34', u'FI', u'PI', u'PP', u'SV', u'XV', u'XX'] ) ), Element( u'NM109', Properties(desc=u'Identification Code', req_sit=u'R', data_type=(u'AN',u'2',u'80'), position=9, codes=[] ) ), Element( u'NM110', Properties(desc=u'Entity Relationship Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=10, codes=[] ) ), Element( u'NM111', Properties(desc=u'Entity Identifier Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), ), Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Information Receiver Additional Identification'), Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'0B', u'1C', u'1D', u'1J', u'4A', u'CT', u'EL', u'EO', u'JD', u'N5', u'N7', u'Q4', u'SY', u'TJ', u'HPI'] ) ), Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'REF03', Properties(desc=u'Description', req_sit=u'S', data_type=(u'AN',u'1',u'80'), position=3, codes=[] ) ), Composite( u'C040', Properties(req_sit=u'N',refdes='',seq=u'04',desc=u'Reference Identifier'), ), ), Segment( u'N3', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'060',desc=u'Information Receiver Address'), Element( u'N301', Properties(desc=u'Address Information', req_sit=u'R', data_type=(u'AN',u'1',u'55'), position=1, codes=[] ) ), Element( u'N302', Properties(desc=u'Address Information', req_sit=u'S', data_type=(u'AN',u'1',u'55'), position=2, codes=[] ) ), ), Segment( u'N4', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'070',desc=u'Information Receiver City/State/Zip Code'), Element( u'N401', Properties(desc=u'City Name', req_sit=u'R', data_type=(u'AN',u'2',u'30'), position=1, codes=[] ) ), Element( u'N402', Properties(desc=u'State or Province Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=2, codes=[] ) ), Element( u'N403', Properties(desc=u'Postal Code', req_sit=u'R', data_type=(u'ID',u'3',u'15'), position=3, codes=[] ) ), Element( u'N404', Properties(desc=u'Country Code', req_sit=u'S', data_type=(u'ID',u'2',u'3'), position=4, codes=[] ) ), Element( u'N405', Properties(desc=u'Location Qualifier', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=5, codes=[] ) ), Element( u'N406', Properties(desc=u'Location Identifier', req_sit=u'N', data_type=(u'AN',u'1',u'30'), position=6, codes=[] ) ), ), Segment( u'PER', Properties(syntax='',req_sit=u'S',repeat=u'3',pos=u'080',desc=u'Information Receiver Contact Information'), Element( u'PER01', Properties(desc=u'Contact Function Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=1, codes=[u'IC'] ) ), Element( u'PER02', Properties(desc=u'Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=2, codes=[] ) ), Element( u'PER03', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=3, codes=[u'ED', u'EM', u'FX', u'TE'] ) ), Element( u'PER04', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=4, codes=[] ) ), Element( u'PER05', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=5, codes=[u'ED', u'EM', u'EX', u'FX', u'TE'] ) ), Element( u'PER06', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=6, codes=[] ) ), Element( u'PER07', Properties(desc=u'Communication Number Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=7, codes=[u'ED', u'EM', u'EX', u'FX', u'TE'] ) ), Element( u'PER08', Properties(desc=u'Communication Number', req_sit=u'S', data_type=(u'AN',u'1',u'256'), position=8, codes=[] ) ), Element( u'PER09', Properties(desc=u'Contact Inquiry Reference', req_sit=u'N', data_type=(u'AN',u'1',u'20'), position=9, codes=[] ) ), ), Segment( u'PRV', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'090',desc=u'Information Receiver Provider Information'), Element( u'PRV01', Properties(desc=u'Provider Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ), Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'ZZ'] ) ), Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3, codes=[] ) ), Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4, codes=[] ) ), Composite( u'C035', Properties(req_sit=u'N',refdes='',seq=u'05',desc=u'Provider Specialty Information'), ), Element( u'PRV06', Properties(desc=u'Provider Organization Code', req_sit=u'N', data_type=(u'ID',u'3',u'3'), position=6, codes=[] ) ), ), ) parsed_270_2110C = Loop( u'2110C', Properties(looptype='',repeat=u'99',pos=u'130',req_sit=u'S',desc=u'Subscriber Eligibility or Benefit Inquiry Information'), Segment( u'EQ', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'130',desc=u'Subscriber Eligibility or Benefit Inquiry Information'), Element( u'EQ01', Properties(desc=u'Service Type Code', req_sit=u'S', data_type=(u'ID',u'1',u'2'), position=1, codes=[u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13', u'14', u'15', u'16', u'17', u'18', u'19', u'20', u'21', u'22', u'23', u'24', u'25', u'26', u'27', u'28', u'30', u'32', u'33', u'34', u'35', u'36', u'37', u'38', u'39', u'40', u'41', u'42', u'43', u'44', u'45', u'46', u'47', u'48', u'49', u'50', u'51', u'52', u'53', u'54', u'55', u'56', u'57', u'58', u'59', u'60', u'61', u'62', u'63', u'64', u'65', u'66', u'67', u'68', u'69', u'70', u'71', u'72', u'73', u'74', u'75', u'76', u'77', u'78', u'79', u'80', u'81', u'82', u'83', u'84', u'85', u'86', u'87', u'88', u'89', u'90', u'91', u'92', u'93', u'94', u'95', u'96', u'97', u'98', u'99', u'A0', u'A1', u'A2', u'A3', u'A4', u'A5', u'A6', u'A7', u'A8', u'A9', u'AA', u'AB', u'AC', u'AD', u'AE', u'AF', u'AG', u'AH', u'AI', u'AJ', u'AK', u'AL', u'AM', u'AN', u'AO', u'AQ', u'AR', u'BA', u'BB', u'BC', u'BD', u'BE', u'BF', u'BG', u'BH', u'BI', u'BJ', u'BK', u'BL', u'BM', u'BN', u'BP', u'BQ', u'BR', u'BS'] ) ), Composite( u'C003', Properties(req_sit=u'S',refdes='',seq=u'02',desc=u'Composite Medical Procedure Identifier'), Element( u'EQ02-01', Properties(desc=u'Product/Service ID Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=0, codes=[u'AD', u'CJ', u'HC', u'ID', u'IV', u'N4', u'ZZ'] ) ), Element( u'EQ02-02', Properties(desc=u'Product/Service ID', req_sit=u'R', data_type=(u'AN',u'1',u'48'), position=1, codes=[] ) ), Element( u'EQ02-03', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=2, codes=[] ) ), Element( u'EQ02-04', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=3, codes=[] ) ), Element( u'EQ02-05', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=4, codes=[] ) ), Element( u'EQ02-06', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=5, codes=[] ) ), Element( u'EQ02-07', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=6, codes=[] ) ), ), Element( u'EQ03', Properties(desc=u'Coverage Level Code', req_sit=u'S', data_type=(u'ID',u'3',u'3'), position=3, codes=[u'CHD', u'DEP', u'ECH', u'EMP', u'ESP', u'FAM', u'IND', u'SPC', u'SPO'] ) ), Element( u'EQ04', Properties(desc=u'Insurance Type Code', req_sit=u'S', data_type=(u'ID',u'1',u'3'), position=4, codes=[u'AP', u'C1', u'CO', u'GP', u'HM', u'HN', u'IP', u'MA', u'MB', u'MC', u'PR', u'PS', u'SP', u'WC'] ) ), ), Segment( u'AMT', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'135',desc=u'Subscriber Spend Down Amount'), Element( u'AMT01', Properties(desc=u'Amount Qualifier Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'R'] ) ), Element( u'AMT02', Properties(desc=u'Monetary Amount', req_sit=u'R', data_type=(u'R',u'1',u'18'), position=2, codes=[] ) ), Element( u'AMT03', Properties(desc=u'Credit/Debit Flag Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=3, codes=[] ) ), ), Segment( u'III', Properties(syntax='',req_sit=u'S',repeat=u'10',pos=u'170',desc=u'Subscriber Eligibility or Benefit Additional Inquiry Information'), Element( u'III01', Properties(desc=u'Code List Qualifier Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'BF', u'BK', u'ZZ'] ) ), Element( u'III02', Properties(desc=u'Industry Code', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2, codes=[] ) ), Element( u'III03', Properties(desc=u'Code Category', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=3, codes=[] ) ), Element( u'III04', Properties(desc=u'Free-form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4, codes=[] ) ), Element( u'III05', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=5, codes=[] ) ), Composite( u'C001', Properties(req_sit=u'N',refdes='',seq=u'06',desc=u'Composite Unit of Measure'), ), Element( u'III07', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=7, codes=[] ) ), Element( u'III08', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=8, codes=[] ) ), Element( u'III09', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=9, codes=[] ) ), ), Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'190',desc=u'Subscriber Additional Information'), Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'9F', u'G1'] ) ), Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3, codes=[] ) ), Composite( u'C040', Properties(req_sit=u'N',refdes='',seq=u'04',desc=u'Reference Identifier'), ), ), Segment( u'DTP', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'200',desc=u'Subscriber Eligibility/Benefit Date'), Element( u'DTP01', Properties(desc=u'Date/Time Qualifier', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=1, codes=[u'307', u'435', u'472'] ) ), Element( u'DTP02', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'D8', u'RD8'] ) ), Element( u'DTP03', Properties(desc=u'Date Time Period', req_sit=u'R', data_type=(u'AN',u'1',u'35'), position=3, codes=[] ) ), ), ) parsed_270_2100C = Loop( u'2100C', Properties(looptype='',repeat=u'1',pos=u'030',req_sit=u'R',desc=u'Subscriber Name'), Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Subscriber Name'), Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'IL'] ) ), Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2, codes=[u'1'] ) ), Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3, codes=[] ) ), Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4, codes=[] ) ), Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5, codes=[] ) ), Element( u'NM106', Properties(desc=u'Name Prefix', req_sit=u'N', data_type=(u'AN',u'1',u'10'), position=6, codes=[] ) ), Element( u'NM107', Properties(desc=u'Name Suffix', req_sit=u'S', data_type=(u'AN',u'1',u'10'), position=7, codes=[] ) ), Element( u'NM108', Properties(desc=u'Identification Code Qualifier', req_sit=u'S', data_type=(u'ID',u'1',u'2'), position=8, codes=[u'MI', u'ZZ'] ) ), Element( u'NM109', Properties(desc=u'Identification Code', req_sit=u'S', data_type=(u'AN',u'2',u'80'), position=9, codes=[] ) ), Element( u'NM110', Properties(desc=u'Entity Relationship Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=10, codes=[] ) ), Element( u'NM111', Properties(desc=u'Entity Identifier Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), ), Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Subscriber Additional Identification'), Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'18', u'1L', u'1W', u'49', u'6P', u'A6', u'CT', u'EA', u'EJ', u'F6', u'GH', u'HJ', u'IG', u'N6', u'NQ', u'SY'] ) ), Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3, codes=[] ) ), Composite( u'C040', Properties(req_sit=u'N',refdes='',seq=u'04',desc=u'Reference Identifier'), ), ), Segment( u'N3', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'060',desc=u'Subscriber Address'), Element( u'N301', Properties(desc=u'Address Information', req_sit=u'R', data_type=(u'AN',u'1',u'55'), position=1, codes=[] ) ), Element( u'N302', Properties(desc=u'Address Information', req_sit=u'S', data_type=(u'AN',u'1',u'55'), position=2, codes=[] ) ), ), Segment( u'N4', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'070',desc=u'Subscriber City/State/ZIP Code'), Element( u'N401', Properties(desc=u'City Name', req_sit=u'S', data_type=(u'AN',u'2',u'30'), position=1, codes=[] ) ), Element( u'N402', Properties(desc=u'State or Province Code', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=2, codes=[] ) ), Element( u'N403', Properties(desc=u'Postal Code', req_sit=u'S', data_type=(u'ID',u'3',u'15'), position=3, codes=[] ) ), Element( u'N404', Properties(desc=u'Country Code', req_sit=u'S', data_type=(u'ID',u'2',u'3'), position=4, codes=[] ) ), Element( u'N405', Properties(desc=u'Location Qualifier', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=5, codes=[] ) ), Element( u'N406', Properties(desc=u'Location Identifier', req_sit=u'N', data_type=(u'AN',u'1',u'30'), position=6, codes=[] ) ), ), Segment( u'PRV', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'090',desc=u'Provider Information'), Element( u'PRV01', Properties(desc=u'Provider Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ), Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'9K', u'D3', u'EI', u'HPI', u'SY', u'TJ', u'ZZ'] ) ), Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3, codes=[] ) ), Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4, codes=[] ) ), Composite( u'C035', Properties(req_sit=u'N',refdes='',seq=u'05',desc=u'Provider Specialty Information'), ), Element( u'PRV06', Properties(desc=u'Provider Organization Code', req_sit=u'N', data_type=(u'ID',u'3',u'3'), position=6, codes=[] ) ), ), Segment( u'DMG', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'100',desc=u'Subscriber Demographic Information'), Element( u'DMG01', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'D8'] ) ), Element( u'DMG02', Properties(desc=u'Date Time Period', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=2, codes=[] ) ), Element( u'DMG03', Properties(desc=u'Gender Code', req_sit=u'S', data_type=(u'ID',u'1',u'1'), position=3, codes=[u'F', u'M'] ) ), Element( u'DMG04', Properties(desc=u'Marital Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=4, codes=[] ) ), Element( u'DMG05', Properties(desc=u'Race or Ethnicity Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=5, codes=[] ) ), Element( u'DMG06', Properties(desc=u'Citizenship Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=6, codes=[] ) ), Element( u'DMG07', Properties(desc=u'Country Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=7, codes=[] ) ), Element( u'DMG08', Properties(desc=u'Basis of Verification Code', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=8, codes=[] ) ), Element( u'DMG09', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=9, codes=[] ) ), ), Segment( u'INS', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'110',desc=u'Subscriber Relationship'), Element( u'INS01', Properties(desc=u'Yes/No Condition or Response Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=1, codes=[u'Y'] ) ), Element( u'INS02', Properties(desc=u'Individual Relationship Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=2, codes=[u'18'] ) ), Element( u'INS03', Properties(desc=u'Maintenance Type Code', req_sit=u'N', data_type=(u'ID',u'3',u'3'), position=3, codes=[] ) ), Element( u'INS04', Properties(desc=u'Maintenance Reason Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=4, codes=[] ) ), Element( u'INS05', Properties(desc=u'Benefit Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=5, codes=[] ) ), Element( u'INS06', Properties(desc=u'Medicare Plan Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=6, codes=[] ) ), Element( u'INS07', Properties(desc=u'Consolidated Omnibus Budget Reconciliation Act (COBRA) Qualifying', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=7, codes=[] ) ), Element( u'INS08', Properties(desc=u'Employment Status Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=8, codes=[] ) ), Element( u'INS09', Properties(desc=u'Student Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=9, codes=[] ) ), Element( u'INS10', Properties(desc=u'Yes/No Condition or Response Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=10, codes=[] ) ), Element( u'INS11', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), Element( u'INS12', Properties(desc=u'Date Time Period', req_sit=u'N', data_type=(u'AN',u'1',u'35'), position=12, codes=[] ) ), Element( u'INS13', Properties(desc=u'Confidentiality Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=13, codes=[] ) ), Element( u'INS14', Properties(desc=u'City Name', req_sit=u'N', data_type=(u'AN',u'2',u'30'), position=14, codes=[] ) ), Element( u'INS15', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=15, codes=[] ) ), Element( u'INS16', Properties(desc=u'Country Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=16, codes=[] ) ), Element( u'INS17', Properties(desc=u'Number', req_sit=u'R', data_type=(u'N0',u'1',u'9'), position=17, codes=[] ) ), ), Segment( u'DTP', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'120',desc=u'Subscriber Date'), Element( u'DTP01', Properties(desc=u'Date/Time Qualifier', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=1, codes=[u'102', u'307', u'435', u'472'] ) ), Element( u'DTP02', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'D8', u'RD8'] ) ), Element( u'DTP03', Properties(desc=u'Date Time Period', req_sit=u'R', data_type=(u'AN',u'1',u'35'), position=3, codes=[] ) ), ), parsed_270_2110C, ) parsed_270_2110D = Loop( u'2110D', Properties(looptype='',repeat=u'99',pos=u'130',req_sit=u'R',desc=u'Dependent Eligibility or Benefit Inquiry Information'), Segment( u'EQ', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'130',desc=u'Dependent Eligibility or Benefit Inquiry Information'), Element( u'EQ01', Properties(desc=u'Service Type Code', req_sit=u'S', data_type=(u'ID',u'1',u'2'), position=1, codes=[u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'10', u'11', u'12', u'13', u'14', u'15', u'16', u'17', u'18', u'19', u'20', u'21', u'22', u'23', u'24', u'25', u'26', u'27', u'28', u'30', u'32', u'33', u'34', u'35', u'36', u'37', u'38', u'39', u'40', u'41', u'42', u'43', u'44', u'45', u'46', u'47', u'48', u'49', u'50', u'51', u'52', u'53', u'54', u'55', u'56', u'57', u'58', u'59', u'60', u'61', u'62', u'63', u'64', u'65', u'66', u'67', u'68', u'69', u'70', u'71', u'72', u'73', u'74', u'75', u'76', u'77', u'78', u'79', u'80', u'81', u'82', u'83', u'84', u'85', u'86', u'87', u'88', u'89', u'90', u'91', u'92', u'93', u'94', u'95', u'96', u'97', u'98', u'99', u'A0', u'A1', u'A2', u'A3', u'A4', u'A5', u'A6', u'A7', u'A8', u'A9', u'AA', u'AB', u'AC', u'AD', u'AE', u'AF', u'AG', u'AH', u'AI', u'AJ', u'AK', u'AL', u'AM', u'AN', u'AO', u'AQ', u'AR', u'BA', u'BB', u'BC', u'BD', u'BE', u'BF', u'BG', u'BH', u'BI', u'BJ', u'BK', u'BL', u'BM', u'BN', u'BP', u'BQ', u'BR', u'BS'] ) ), Composite( u'C003', Properties(req_sit=u'S',refdes='',seq=u'02',desc=u'Composite Medical Procedure Identifier'), Element( u'EQ02-01', Properties(desc=u'Product/Service ID Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=0, codes=[u'AD', u'CJ', u'HC', u'ID', u'IV', u'N4', u'ZZ'] ) ), Element( u'EQ02-02', Properties(desc=u'Product/Service ID', req_sit=u'R', data_type=(u'AN',u'1',u'48'), position=1, codes=[] ) ), Element( u'EQ02-03', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=2, codes=[] ) ), Element( u'EQ02-04', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=3, codes=[] ) ), Element( u'EQ02-05', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=4, codes=[] ) ), Element( u'EQ02-06', Properties(desc=u'Procedure Modifier', req_sit=u'S', data_type=(u'AN',u'2',u'2'), position=5, codes=[] ) ), Element( u'EQ02-07', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=6, codes=[] ) ), ), Element( u'EQ03', Properties(desc=u'Coverage Level Code', req_sit=u'S', data_type=(u'ID',u'3',u'3'), position=3, codes=[u'CHD', u'DEP', u'ECH', u'EMP', u'ESP', u'FAM', u'IND', u'SPC', u'SPO'] ) ), Element( u'EQ04', Properties(desc=u'Insurance Type Code', req_sit=u'S', data_type=(u'ID',u'1',u'3'), position=4, codes=[u'AP', u'C1', u'CO', u'GP', u'HM', u'IP', u'MA', u'MB', u'MC', u'PR', u'PS', u'SP', u'WC'] ) ), ), Segment( u'III', Properties(syntax='',req_sit=u'S',repeat=u'10',pos=u'170',desc=u'Dependent Eligibility or Benefit Additional Inquiry Information'), Element( u'III01', Properties(desc=u'Code List Qualifier Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'BF', u'BK', u'ZZ'] ) ), Element( u'III02', Properties(desc=u'Industry Code', req_sit=u'R', data_type=(u'AN',u'1',u'30'), position=2, codes=[] ) ), Element( u'III03', Properties(desc=u'Code Category', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=3, codes=[] ) ), Element( u'III04', Properties(desc=u'Free-form Message Text', req_sit=u'N', data_type=(u'AN',u'1',u'264'), position=4, codes=[] ) ), Element( u'III05', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=5, codes=[] ) ), Composite( u'C001', Properties(req_sit=u'N',refdes='',seq=u'06',desc=u'Composite Unit of Measure'), ), Element( u'III07', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=7, codes=[] ) ), Element( u'III08', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=8, codes=[] ) ), Element( u'III09', Properties(desc=u'Surface/Layer/Position Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=9, codes=[] ) ), ), Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'190',desc=u'Dependent Additional Information'), Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'9F', u'G1'] ) ), Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3, codes=[] ) ), Composite( u'C040', Properties(req_sit=u'N',refdes='',seq=u'04',desc=u'Reference Identifier'), ), ), Segment( u'DTP', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'200',desc=u'Dependent Eligibility/Benefit Date'), Element( u'DTP01', Properties(desc=u'Date/Time Qualifier', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=1, codes=[u'307', u'435', u'472'] ) ), Element( u'DTP02', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'D8', u'RD8'] ) ), Element( u'DTP03', Properties(desc=u'Date Time Period', req_sit=u'R', data_type=(u'AN',u'1',u'35'), position=3, codes=[] ) ), ), ) parsed_270_2100D = Loop( u'2100D', Properties(looptype='',repeat=u'1',pos=u'030',req_sit=u'R',desc=u'Dependent Name'), Segment( u'NM1', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Dependent Name'), Element( u'NM101', Properties(desc=u'Entity Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'03'] ) ), Element( u'NM102', Properties(desc=u'Entity Type Qualifier', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=2, codes=[u'1'] ) ), Element( u'NM103', Properties(desc=u'Name Last or Organization Name', req_sit=u'S', data_type=(u'AN',u'1',u'60'), position=3, codes=[] ) ), Element( u'NM104', Properties(desc=u'Name First', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=4, codes=[] ) ), Element( u'NM105', Properties(desc=u'Name Middle', req_sit=u'S', data_type=(u'AN',u'1',u'25'), position=5, codes=[] ) ), Element( u'NM106', Properties(desc=u'Name Prefix', req_sit=u'N', data_type=(u'AN',u'1',u'10'), position=6, codes=[] ) ), Element( u'NM107', Properties(desc=u'Name Suffix', req_sit=u'S', data_type=(u'AN',u'1',u'10'), position=7, codes=[] ) ), Element( u'NM108', Properties(desc=u'Identification Code Qualifier', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=8, codes=[] ) ), Element( u'NM109', Properties(desc=u'Identification Code', req_sit=u'N', data_type=(u'AN',u'2',u'80'), position=9, codes=[] ) ), Element( u'NM110', Properties(desc=u'Entity Relationship Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=10, codes=[] ) ), Element( u'NM111', Properties(desc=u'Entity Identifier Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), ), Segment( u'REF', Properties(syntax='',req_sit=u'S',repeat=u'9',pos=u'040',desc=u'Dependent Additional Identification'), Element( u'REF01', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'18', u'1L', u'6P', u'A6', u'CT', u'EA', u'EJ', u'F6', u'GH', u'HJ', u'IF', u'IG', u'N6', u'SY'] ) ), Element( u'REF02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'REF03', Properties(desc=u'Description', req_sit=u'N', data_type=(u'AN',u'1',u'80'), position=3, codes=[] ) ), Composite( u'C040', Properties(req_sit=u'N',refdes='',seq=u'04',desc=u'Reference Identifier'), ), ), Segment( u'N3', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'060',desc=u'Dependent Address'), Element( u'N301', Properties(desc=u'Address Information', req_sit=u'R', data_type=(u'AN',u'1',u'55'), position=1, codes=[] ) ), Element( u'N302', Properties(desc=u'Address Information', req_sit=u'S', data_type=(u'AN',u'1',u'55'), position=2, codes=[] ) ), ), Segment( u'N4', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'070',desc=u'Dependent City/State/ZIP Code'), Element( u'N401', Properties(desc=u'City Name', req_sit=u'S', data_type=(u'AN',u'2',u'30'), position=1, codes=[] ) ), Element( u'N402', Properties(desc=u'State or Province Code', req_sit=u'S', data_type=(u'ID',u'2',u'2'), position=2, codes=[] ) ), Element( u'N403', Properties(desc=u'Postal Code', req_sit=u'S', data_type=(u'ID',u'3',u'15'), position=3, codes=[] ) ), Element( u'N404', Properties(desc=u'Country Code', req_sit=u'S', data_type=(u'ID',u'2',u'3'), position=4, codes=[] ) ), Element( u'N405', Properties(desc=u'Location Qualifier', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=5, codes=[] ) ), Element( u'N406', Properties(desc=u'Location Identifier', req_sit=u'N', data_type=(u'AN',u'1',u'30'), position=6, codes=[] ) ), ), Segment( u'PRV', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'090',desc=u'Provider Information'), Element( u'PRV01', Properties(desc=u'Provider Code', req_sit=u'R', data_type=(u'ID',u'1',u'3'), position=1, codes=[u'AD', u'AT', u'BI', u'CO', u'CV', u'H', u'HH', u'LA', u'OT', u'P1', u'P2', u'PC', u'PE', u'R', u'RF', u'SB', u'SK', u'SU'] ) ), Element( u'PRV02', Properties(desc=u'Reference Identification Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'9K', u'D3', u'EI', u'HPI', u'SY', u'TJ', u'ZZ'] ) ), Element( u'PRV03', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=3, codes=[] ) ), Element( u'PRV04', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=4, codes=[] ) ), Composite( u'C035', Properties(req_sit=u'N',refdes='',seq=u'05',desc=u'Provider Specialty Information'), ), Element( u'PRV06', Properties(desc=u'Provider Organization Code', req_sit=u'N', data_type=(u'ID',u'3',u'3'), position=6, codes=[] ) ), ), Segment( u'DMG', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'100',desc=u'Dependent Demographic Information'), Element( u'DMG01', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'S', data_type=(u'ID',u'2',u'3'), position=1, codes=[u'D8'] ) ), Element( u'DMG02', Properties(desc=u'Date Time Period', req_sit=u'S', data_type=(u'AN',u'1',u'35'), position=2, codes=[] ) ), Element( u'DMG03', Properties(desc=u'Gender Code', req_sit=u'S', data_type=(u'ID',u'1',u'1'), position=3, codes=[u'F', u'M'] ) ), Element( u'DMG04', Properties(desc=u'Marital Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=4, codes=[] ) ), Element( u'DMG05', Properties(desc=u'Race or Ethnicity Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=5, codes=[] ) ), Element( u'DMG06', Properties(desc=u'Citizenship Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=6, codes=[] ) ), Element( u'DMG07', Properties(desc=u'Country Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=7, codes=[] ) ), Element( u'DMG08', Properties(desc=u'Basis of Verification Code', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=8, codes=[] ) ), Element( u'DMG09', Properties(desc=u'Quantity', req_sit=u'N', data_type=(u'R',u'1',u'15'), position=9, codes=[] ) ), ), Segment( u'INS', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'110',desc=u'Dependent Relationship'), Element( u'INS01', Properties(desc=u'Yes/No Condition or Response Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=1, codes=[u'N'] ) ), Element( u'INS02', Properties(desc=u'Individual Relationship Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=2, codes=[u'01', u'19', u'34'] ) ), Element( u'INS03', Properties(desc=u'Maintenance Type Code', req_sit=u'N', data_type=(u'ID',u'3',u'3'), position=3, codes=[] ) ), Element( u'INS04', Properties(desc=u'Maintenance Reason Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=4, codes=[] ) ), Element( u'INS05', Properties(desc=u'Benefit Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=5, codes=[] ) ), Element( u'INS06', Properties(desc=u'Medicare Plan Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=6, codes=[] ) ), Element( u'INS07', Properties(desc=u'Consolidated Omnibus Budget Reconciliation Act (COBRA) Qualifying', req_sit=u'N', data_type=(u'ID',u'1',u'2'), position=7, codes=[] ) ), Element( u'INS08', Properties(desc=u'Employment Status Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=8, codes=[] ) ), Element( u'INS09', Properties(desc=u'Student Status Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=9, codes=[] ) ), Element( u'INS10', Properties(desc=u'Yes/No Condition or Response Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=10, codes=[] ) ), Element( u'INS11', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=11, codes=[] ) ), Element( u'INS12', Properties(desc=u'Date Time Period', req_sit=u'N', data_type=(u'AN',u'1',u'35'), position=12, codes=[] ) ), Element( u'INS13', Properties(desc=u'Confidentiality Code', req_sit=u'N', data_type=(u'ID',u'1',u'1'), position=13, codes=[] ) ), Element( u'INS14', Properties(desc=u'City Name', req_sit=u'N', data_type=(u'AN',u'2',u'30'), position=14, codes=[] ) ), Element( u'INS15', Properties(desc=u'State or Province Code', req_sit=u'N', data_type=(u'ID',u'2',u'2'), position=15, codes=[] ) ), Element( u'INS16', Properties(desc=u'Country Code', req_sit=u'N', data_type=(u'ID',u'2',u'3'), position=16, codes=[] ) ), Element( u'INS17', Properties(desc=u'Number', req_sit=u'S', data_type=(u'N0',u'1',u'9'), position=17, codes=[] ) ), ), Segment( u'DTP', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'120',desc=u'Dependent Date'), Element( u'DTP01', Properties(desc=u'Date/Time Qualifier', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=1, codes=[u'102', u'307', u'435', u'472'] ) ), Element( u'DTP02', Properties(desc=u'Date Time Period Format Qualifier', req_sit=u'R', data_type=(u'ID',u'2',u'3'), position=2, codes=[u'D8', u'RD8'] ) ), Element( u'DTP03', Properties(desc=u'Date Time Period', req_sit=u'R', data_type=(u'AN',u'1',u'35'), position=3, codes=[] ) ), ), parsed_270_2110D, ) parsed_270_2000D = Loop( u'2000D', Properties(looptype='',repeat=u'>1',pos=u'040',req_sit=u'S',desc=u'Dependent Level'), Segment( u'HL', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Dependent Level'), Element( u'HL01', Properties(desc=u'Hierarchical ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=1, codes=[] ) ), Element( u'HL02', Properties(desc=u'Hierarchical Parent ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=2, codes=[] ) ), Element( u'HL03', Properties(desc=u'Hierarchical Level Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=3, codes=[u'23'] ) ), Element( u'HL04', Properties(desc=u'Hierarchical Child Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=4, codes=[u'0'] ) ), ), Segment( u'TRN', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'020',desc=u'Dependent Trace Number'), Element( u'TRN01', Properties(desc=u'Trace Type Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=1, codes=[u'1'] ) ), Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'TRN03', Properties(desc=u'Originating Company Identifier', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=3, codes=[] ) ), Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=4, codes=[] ) ), ), parsed_270_2100D, ) parsed_270_2000C = Loop( u'2000C', Properties(looptype='',repeat=u'>1',pos=u'040',req_sit=u'R',desc=u'Subscriber Level'), Segment( u'HL', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Subscriber Level'), Element( u'HL01', Properties(desc=u'Hierarchical ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=1, codes=[] ) ), Element( u'HL02', Properties(desc=u'Hierarchical Parent ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=2, codes=[] ) ), Element( u'HL03', Properties(desc=u'Hierarchical Level Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=3, codes=[u'22'] ) ), Element( u'HL04', Properties(desc=u'Hierarchical Child Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=4, codes=[u'0', u'1'] ) ), ), Segment( u'TRN', Properties(syntax='',req_sit=u'S',repeat=u'2',pos=u'020',desc=u'Subscriber Trace Number'), Element( u'TRN01', Properties(desc=u'Trace Type Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=1, codes=[u'1'] ) ), Element( u'TRN02', Properties(desc=u'Reference Identification', req_sit=u'R', data_type=(u'AN',u'1',u'50'), position=2, codes=[] ) ), Element( u'TRN03', Properties(desc=u'Originating Company Identifier', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=3, codes=[] ) ), Element( u'TRN04', Properties(desc=u'Reference Identification', req_sit=u'S', data_type=(u'AN',u'1',u'50'), position=4, codes=[] ) ), ), parsed_270_2100C, parsed_270_2000D, ) parsed_270_2000B = Loop( u'2000B', Properties(looptype='',repeat=u'>1',pos=u'040',req_sit=u'R',desc=u'Information Receiver Level'), Segment( u'HL', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Information Receiver Level'), Element( u'HL01', Properties(desc=u'Hierarchical ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=1, codes=[] ) ), Element( u'HL02', Properties(desc=u'Hierarchical Parent ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=2, codes=[] ) ), Element( u'HL03', Properties(desc=u'Hierarchical Level Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=3, codes=[u'21'] ) ), Element( u'HL04', Properties(desc=u'Hierarchical Child Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=4, codes=[u'1'] ) ), ), parsed_270_2100B, parsed_270_2000C, ) parsed_270_2000A = Loop( u'2000A', Properties(looptype='',repeat=u'>1',pos=u'010',req_sit=u'R',desc=u'Information Source Level'), Segment( u'HL', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Information Source Level'), Element( u'HL01', Properties(desc=u'Hierarchical ID Number', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=1, codes=[] ) ), Element( u'HL02', Properties(desc=u'Hierarchical Parent ID Number', req_sit=u'N', data_type=(u'AN',u'1',u'12'), position=2, codes=[] ) ), Element( u'HL03', Properties(desc=u'Hierarchical Level Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=3, codes=[u'20'] ) ), Element( u'HL04', Properties(desc=u'Hierarchical Child Code', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=4, codes=[u'1'] ) ), ), parsed_270_2100A, parsed_270_2000B, ) parsed_270_DETAIL = Loop( u'DETAIL', Properties(looptype=u'wrapper',repeat=u'>1',pos=u'020',req_sit=u'S',desc=u'Table 2 - Detail'), parsed_270_2000A, ) parsed_270_ST_LOOP = Loop( u'ST_LOOP', Properties(looptype=u'explicit',repeat=u'>1',pos=u'020',req_sit=u'R',desc=u'Transaction Set Header'), Segment( u'ST', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Transaction Set Header'), Element( u'ST01', Properties(desc=u'Transaction Set Identifier Code', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=1, codes=[u'270'] ) ), Element( u'ST02', Properties(desc=u'Transaction Set Control Number', req_sit=u'R', data_type=(u'AN',u'4',u'9'), position=2, codes=[] ) ), ), parsed_270_HEADER, parsed_270_DETAIL, Segment( u'SE', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'210',desc=u'Transaction Set Trailer'), Element( u'SE01', Properties(desc=u'Number of Included Segments', req_sit=u'R', data_type=(u'N0',u'1',u'10'), position=1, codes=[] ) ), Element( u'SE02', Properties(desc=u'Transaction Set Control Number', req_sit=u'R', data_type=(u'AN',u'4',u'9'), position=2, codes=[] ) ), ), ) parsed_270_GS_LOOP = Loop( u'GS_LOOP', Properties(looptype=u'explicit',repeat=u'>1',pos=u'020',req_sit=u'R',desc=u'Functional Group Header'), Segment( u'GS', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Functional Group Header'), Element( u'GS01', Properties(desc=u'Functional Identifier Code', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=1, codes=[u'HS'] ) ), Element( u'GS02', Properties(desc=u'Application Senders Code', req_sit=u'R', data_type=(u'AN',u'2',u'15'), position=2, codes=[] ) ), Element( u'GS03', Properties(desc=u'124', req_sit=u'R', data_type=(u'AN',u'2',u'15'), position=3, codes=[] ) ), Element( u'GS04', Properties(desc=u'Date', req_sit=u'R', data_type=(u'DT',u'8',u'8'), position=4, codes=[] ) ), Element( u'GS05', Properties(desc=u'Time', req_sit=u'R', data_type=(u'TM',u'4',u'8'), position=5, codes=[] ) ), Element( u'GS06', Properties(desc=u'Group Control Number', req_sit=u'R', data_type=(u'N0',u'1',u'9'), position=6, codes=[] ) ), Element( u'GS07', Properties(desc=u'Responsible Agency Code', req_sit=u'R', data_type=(u'ID',u'1',u'2'), position=7, codes=[u'X'] ) ), Element( u'GS08', Properties(desc=u'Version / Release / Industry Identifier Code', req_sit=u'R', data_type=(u'AN',u'1',u'12'), position=8, codes=[u'004010X092A1'] ) ), ), parsed_270_ST_LOOP, Segment( u'GE', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Functional Group Trailer'), Element( u'GE01', Properties(desc=u'97', req_sit=u'R', data_type=(u'N0',u'1',u'6'), position=1, codes=[] ) ), Element( u'GE02', Properties(desc=u'Group Control Number', req_sit=u'R', data_type=(u'N0',u'1',u'9'), position=2, codes=[] ) ), ), ) parsed_270_ISA_LOOP = Loop( u'ISA_LOOP', Properties(looptype=u'explicit',repeat=u'>1',pos=u'001',req_sit=u'R',desc=u'Interchange Control Header'), Segment( u'ISA', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'010',desc=u'Interchange Control Header'), Element( u'ISA01', Properties(desc=u'I01', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=1, codes=[u'00', u'03'] ) ), Element( u'ISA02', Properties(desc=u'I02', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=2, codes=[] ) ), Element( u'ISA03', Properties(desc=u'I03', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=3, codes=[u'00', u'01'] ) ), Element( u'ISA04', Properties(desc=u'I04', req_sit=u'R', data_type=(u'AN',u'10',u'10'), position=4, codes=[] ) ), Element( u'ISA05', Properties(desc=u'I05', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=5, codes=[u'01', u'14', u'20', u'27', u'28', u'29', u'30', u'33', u'ZZ'] ) ), Element( u'ISA06', Properties(desc=u'I06', req_sit=u'R', data_type=(u'AN',u'15',u'15'), position=6, codes=[] ) ), Element( u'ISA07', Properties(desc=u'I05', req_sit=u'R', data_type=(u'ID',u'2',u'2'), position=7, codes=[u'01', u'14', u'20', u'27', u'28', u'29', u'30', u'33', u'ZZ'] ) ), Element( u'ISA08', Properties(desc=u'I07', req_sit=u'R', data_type=(u'AN',u'15',u'15'), position=8, codes=[] ) ), Element( u'ISA09', Properties(desc=u'I08', req_sit=u'R', data_type=(u'DT',u'6',u'6'), position=9, codes=[] ) ), Element( u'ISA10', Properties(desc=u'I09', req_sit=u'R', data_type=(u'TM',u'4',u'4'), position=10, codes=[] ) ), Element( u'ISA11', Properties(desc=u'I10', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=11, codes=[u'U'] ) ), Element( u'ISA12', Properties(desc=u'I11', req_sit=u'R', data_type=(u'ID',u'5',u'5'), position=12, codes=[u'00401'] ) ), Element( u'ISA13', Properties(desc=u'I12', req_sit=u'R', data_type=(u'N0',u'9',u'9'), position=13, codes=[] ) ), Element( u'ISA14', Properties(desc=u'I13', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=14, codes=[u'0', u'1'] ) ), Element( u'ISA15', Properties(desc=u'I14', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=15, codes=[u'P', u'T'] ) ), Element( u'ISA16', Properties(desc=u'I15', req_sit=u'R', data_type=(u'AN',u'1',u'1'), position=16, codes=[] ) ), ), parsed_270_GS_LOOP, Segment( u'TA1', Properties(syntax='',req_sit=u'S',repeat=u'1',pos=u'020',desc=u'Interchange Acknowledgement'), Element( u'TA101', Properties(desc=u'I12', req_sit=u'R', data_type=(u'N0',u'9',u'9'), position=1, codes=[] ) ), Element( u'TA102', Properties(desc=u'I08', req_sit=u'R', data_type=(u'DT',u'6',u'6'), position=2, codes=[] ) ), Element( u'TA103', Properties(desc=u'I09', req_sit=u'R', data_type=(u'TM',u'4',u'4'), position=3, codes=[] ) ), Element( u'TA104', Properties(desc=u'I17', req_sit=u'R', data_type=(u'ID',u'1',u'1'), position=4, codes=[u'A', u'E', u'R'] ) ), Element( u'TA105', Properties(desc=u'I18', req_sit=u'R', data_type=(u'ID',u'3',u'3'), position=5, codes=[u'000', u'001', u'002', u'003', u'004', u'005', u'006', u'007', u'008', u'009', u'010', u'011', u'012', u'013', u'014', u'015', u'016', u'017', u'018', u'019', u'020', u'021', u'022', u'023', u'024', u'025', u'026', u'027', u'028', u'029', u'030', u'031'] ) ), ), Segment( u'IEA', Properties(syntax='',req_sit=u'R',repeat=u'1',pos=u'030',desc=u'Interchange Control Trailer'), Element( u'IEA01', Properties(desc=u'I16', req_sit=u'R', data_type=(u'N0',u'1',u'5'), position=1, codes=[] ) ), Element( u'IEA02', Properties(desc=u'I12', req_sit=u'R', data_type=(u'N0',u'9',u'9'), position=2, codes=[] ) ), ), ) parsed_270 = Message( u'270', Properties(desc=u'HIPAA Health Care Eligibility Inquiry X092A1-270'), parsed_270_ISA_LOOP, )
70.489627
1,000
0.629837
9,439
50,964
3.326835
0.071088
0.055888
0.078021
0.039743
0.911248
0.891026
0.888447
0.884466
0.879403
0.875709
0
0.065534
0.113433
50,964
722
1,001
70.587258
0.629462
0.001413
0
0.725627
1
0
0.239943
0.002594
0
0
0
0
0
1
0
false
0
0.001393
0
0.001393
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
9
200f04ee442f9aa62304f99e6bceed48f3c78d52
1,414
py
Python
tests/end_to_end/scenarios/mam_on_fixed_server.py
norayr/biboumi
805671032d25ee6ce09ed75e8a385c04e9563cdd
[ "Zlib" ]
68
2015-01-29T21:07:37.000Z
2022-03-20T14:48:07.000Z
tests/end_to_end/scenarios/mam_on_fixed_server.py
norayr/biboumi
805671032d25ee6ce09ed75e8a385c04e9563cdd
[ "Zlib" ]
5
2016-10-24T18:34:30.000Z
2021-08-31T13:30:37.000Z
tests/end_to_end/scenarios/mam_on_fixed_server.py
norayr/biboumi
805671032d25ee6ce09ed75e8a385c04e9563cdd
[ "Zlib" ]
13
2015-12-11T15:19:05.000Z
2021-08-31T13:24:35.000Z
from scenarios import * conf = 'fixed_server' scenario = ( scenarios.channel_join_on_fixed_irc_server.scenario, send_stanza("<message from='{jid_one}/{resource_one}' to='#foo@{biboumi_host}' type='groupchat'><body>coucou</body></message>"), expect_stanza("/message[@from='#foo@{biboumi_host}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou']"), send_stanza("<message from='{jid_one}/{resource_one}' to='#foo@{biboumi_host}' type='groupchat'><body>coucou 2</body></message>"), expect_stanza("/message[@from='#foo@{biboumi_host}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']"), # Retrieve the complete archive send_stanza("<iq to='#foo@{biboumi_host}' from='{jid_one}/{resource_one}' type='set' id='id1'><query xmlns='urn:xmpp:mam:2' queryid='qid1' /></iq>"), expect_stanza("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay", "/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo@{biboumi_host}/{nick_one}'][@type='groupchat']/client:body[text()='coucou']"), expect_stanza("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay", "/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo@{biboumi_host}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 2']"), )
64.272727
181
0.677511
185
1,414
4.994595
0.264865
0.075758
0.106061
0.091991
0.799784
0.772727
0.772727
0.772727
0.772727
0.772727
0
0.007752
0.087694
1,414
21
182
67.333333
0.708527
0.020509
0
0.142857
0
0.5
0.768619
0.68402
0
0
0
0
0
1
0
false
0
0.071429
0
0.071429
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
1
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
202ad4fa42c11ab180e333b37b7f51c8fc95814c
904
py
Python
cms_articles/signals/title.py
snegovick/django-cms-articles
f7397bd5e303be6ed50bc53b71e27e40f4087f94
[ "BSD-3-Clause" ]
9
2016-04-18T15:59:50.000Z
2019-09-12T07:11:15.000Z
cms_articles/signals/title.py
snegovick/django-cms-articles
f7397bd5e303be6ed50bc53b71e27e40f4087f94
[ "BSD-3-Clause" ]
6
2019-01-22T17:53:48.000Z
2020-07-19T17:35:31.000Z
cms_articles/signals/title.py
snegovick/django-cms-articles
f7397bd5e303be6ed50bc53b71e27e40f4087f94
[ "BSD-3-Clause" ]
4
2017-02-10T17:19:30.000Z
2020-02-02T16:58:20.000Z
def pre_save_title(instance, **kwargs): ''' Update article.languages ''' if instance.article.languages: languages = instance.article.languages.split(',') else: languages = [] if instance.language not in languages: languages.append(instance.language) instance.article.languages = ','.join(languages) instance.article._publisher_keep_state = True instance.article.save(no_signals=True) def pre_delete_title(instance, **kwargs): ''' Update article.languages ''' if instance.article.languages: languages = instance.article.languages.split(',') else: languages = [] if instance.language in languages: languages.remove(instance.language) instance.article.languages = ','.join(languages) instance.article._publisher_keep_state = True instance.article.save(no_signals=True)
33.481481
57
0.669248
93
904
6.376344
0.268817
0.252951
0.242833
0.084317
0.870152
0.870152
0.870152
0.870152
0.870152
0.870152
0
0
0.215708
904
26
58
34.769231
0.836389
0.059735
0
0.7
0
0
0.004808
0
0
0
0
0
0
1
0.1
false
0
0
0
0.1
0
0
0
0
null
1
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
204bc73f8264be5840571820b7b0e7b92b44a563
30,165
py
Python
lib/fast_rcnn/test.py
VitoChien/py-mask-rcnn-multiGPU
0aaf997204442626f126bfcb86ca12e8c6d31725
[ "MIT" ]
9
2018-10-09T14:13:33.000Z
2021-04-12T08:22:52.000Z
lib/fast_rcnn/test.py
VitoChien/py-mask-rcnn-multiGPU
0aaf997204442626f126bfcb86ca12e8c6d31725
[ "MIT" ]
4
2018-12-08T02:42:18.000Z
2020-12-11T07:11:30.000Z
lib/fast_rcnn/test.py
VitoChien/py-mask-rcnn-multiGPU
0aaf997204442626f126bfcb86ca12e8c6d31725
[ "MIT" ]
5
2018-12-07T08:09:23.000Z
2019-12-06T07:52:24.000Z
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- """Test a Fast R-CNN network on an imdb (image database).""" from fast_rcnn.config import cfg, get_output_dir from fast_rcnn.bbox_transform import clip_boxes, bbox_transform_inv import argparse from utils.timer import Timer import numpy as np import cv2 import os os.environ['GLOG_minloglevel'] = '2' import caffe from fast_rcnn.nms_wrapper import nms import cPickle from utils.blob import im_list_to_blob import os def _get_image_blob(im): """Converts an image into a network input. Arguments: im (ndarray): a color image in BGR order Returns: blob (ndarray): a data blob holding an image pyramid im_scale_factors (list): list of image scales (relative to im) used in the image pyramid """ im_orig = im.astype(np.float32, copy=True) im_orig -= cfg.PIXEL_MEANS im_shape = im_orig.shape im_size_min = np.min(im_shape[0:2]) im_size_max = np.max(im_shape[0:2]) processed_ims = [] im_scale_factors = [] for target_size in cfg.TEST.SCALES: im_scale = float(target_size) / float(im_size_min) # Prevent the biggest axis from being more than MAX_SIZE if np.round(im_scale * im_size_max) > cfg.TEST.MAX_SIZE: im_scale = float(cfg.TEST.MAX_SIZE) / float(im_size_max) im = cv2.resize(im_orig, None, None, fx=im_scale, fy=im_scale, interpolation=cv2.INTER_LINEAR) im_scale_factors.append(im_scale) processed_ims.append(im) # Create a blob to hold the input images blob = im_list_to_blob(processed_ims) return blob, np.array(im_scale_factors) def _get_rois_blob(im_rois, im_scale_factors): """Converts RoIs into network inputs. Arguments: im_rois (ndarray): R x 4 matrix of RoIs in original image coordinates im_scale_factors (list): scale factors as returned by _get_image_blob Returns: blob (ndarray): R x 5 matrix of RoIs in the image pyramid """ rois, levels = _project_im_rois(im_rois, im_scale_factors) rois_blob = np.hstack((levels, rois)) return rois_blob.astype(np.float32, copy=False) def _project_im_rois(im_rois, scales): """Project image RoIs into the image pyramid built by _get_image_blob. Arguments: im_rois (ndarray): R x 4 matrix of RoIs in original image coordinates scales (list): scale factors as returned by _get_image_blob Returns: rois (ndarray): R x 4 matrix of projected RoI coordinates levels (list): image pyramid levels used by each projected RoI """ im_rois = im_rois.astype(np.float, copy=False) if len(scales) > 1: widths = im_rois[:, 2] - im_rois[:, 0] + 1 heights = im_rois[:, 3] - im_rois[:, 1] + 1 areas = widths * heights scaled_areas = areas[:, np.newaxis] * (scales[np.newaxis, :] ** 2) diff_areas = np.abs(scaled_areas - 224 * 224) levels = diff_areas.argmin(axis=1)[:, np.newaxis] else: levels = np.zeros((im_rois.shape[0], 1), dtype=np.int) rois = im_rois * scales[levels] return rois, levels def _get_blobs(im, rois, mask=False): """Convert an image and RoIs within that image into network inputs.""" blobs = {'data' : None, 'rois' : None} blobs['data'], im_scale_factors = _get_image_blob(im) if not cfg.TEST.HAS_RPN or mask: blobs['rois'] = _get_rois_blob(rois, im_scale_factors) return blobs, im_scale_factors def im_detect(net, im, boxes=None): """Detect object classes in an image given object proposals. Arguments: net (caffe.Net): Fast R-CNN network to use im (ndarray): color image to test (in BGR order) boxes (ndarray): R x 4 array of object proposals or None (for RPN) Returns: scores (ndarray): R x K array of object class scores (K includes background as object category 0) boxes (ndarray): R x (4*K) array of predicted bounding boxes """ blobs, im_scales = _get_blobs(im, boxes) # When mapping from image ROIs to feature map ROIs, there's some aliasing # (some distinct image ROIs get mapped to the same feature ROI). # Here, we identify duplicate feature ROIs, so we only compute features # on the unique subset. if cfg.DEDUP_BOXES > 0 and not cfg.TEST.HAS_RPN: v = np.array([1, 1e3, 1e6, 1e9, 1e12]) hashes = np.round(blobs['rois'] * cfg.DEDUP_BOXES).dot(v) _, index, inv_index = np.unique(hashes, return_index=True, return_inverse=True) blobs['rois'] = blobs['rois'][index, :] boxes = boxes[index, :] if cfg.TEST.HAS_RPN: im_blob = blobs['data'] blobs['im_info'] = np.array( [[im_blob.shape[2], im_blob.shape[3], im_scales[0]]], dtype=np.float32) # reshape network inputs net.blobs['data'].reshape(*(blobs['data'].shape)) if cfg.TEST.HAS_RPN: net.blobs['im_info'].reshape(*(blobs['im_info'].shape)) else: net.blobs['rois'].reshape(*(blobs['rois'].shape)) # do forward forward_kwargs = {'data': blobs['data'].astype(np.float32, copy=False)} if cfg.TEST.HAS_RPN: forward_kwargs['im_info'] = blobs['im_info'].astype(np.float32, copy=False) else: forward_kwargs['rois'] = blobs['rois'].astype(np.float32, copy=False) blobs_out = net.forward(**forward_kwargs) if cfg.TEST.HAS_RPN: assert len(im_scales) == 1, "Only single-image batch implemented" rois = net.blobs['rois'].data.copy() # unscale back to raw image space boxes = rois[:, 1:5] / im_scales[0] if cfg.TEST.SVM: # use the raw scores before softmax under the assumption they # were trained as linear SVMs scores = net.blobs['cls_score'].data else: # use softmax estimated probabilities scores = blobs_out['cls_prob'] if cfg.TEST.BBOX_REG: # Apply bounding-box regression deltas box_deltas = blobs_out['bbox_pred'] pred_boxes = bbox_transform_inv(boxes, box_deltas) pred_boxes = clip_boxes(pred_boxes, im.shape) else: # Simply repeat the boxes, once for each class pred_boxes = np.tile(boxes, (1, scores.shape[1])) if cfg.DEDUP_BOXES > 0 and not cfg.TEST.HAS_RPN: # Map scores and predictions back to the original set of boxes scores = scores[inv_index, :] pred_boxes = pred_boxes[inv_index, :] return scores, pred_boxes def im_det(net, im, boxes=None): """Detect object classes in an image given object proposals. Arguments: net (caffe.Net): Fast R-CNN network to use im (ndarray): color image to test (in BGR order) boxes (ndarray): R x 4 array of object proposals or None (for RPN) Returns: scores (ndarray): R x K array of object class scores (K includes background as object category 0) boxes (ndarray): R x (4*K) array of predicted bounding boxes """ blobs, im_scales = _get_blobs(im, boxes) # When mapping from image ROIs to feature map ROIs, there's some aliasing # (some distinct image ROIs get mapped to the same feature ROI). # Here, we identify duplicate feature ROIs, so we only compute features # on the unique subset. if cfg.DEDUP_BOXES > 0 and not cfg.TEST.HAS_RPN: v = np.array([1, 1e3, 1e6, 1e9, 1e12]) hashes = np.round(blobs['rois'] * cfg.DEDUP_BOXES).dot(v) _, index, inv_index = np.unique(hashes, return_index=True, return_inverse=True) blobs['rois'] = blobs['rois'][index, :] boxes = boxes[index, :] if cfg.TEST.HAS_RPN: im_blob = blobs['data'] blobs['im_info'] = np.array( [[im_blob.shape[2], im_blob.shape[3], im_scales[0]]], dtype=np.float32) # reshape network inputs net.blobs['data'].reshape(*(blobs['data'].shape)) if cfg.TEST.HAS_RPN: net.blobs['im_info'].reshape(*(blobs['im_info'].shape)) else: net.blobs['rois'].reshape(*(blobs['rois'].shape)) # do forward print(im_blob.shape) forward_kwargs = {'data': blobs['data'].astype(np.float32, copy=False)} if cfg.TEST.HAS_RPN: forward_kwargs['im_info'] = blobs['im_info'].astype(np.float32, copy=False) else: forward_kwargs['rois'] = blobs['rois'].astype(np.float32, copy=False) blobs_out = net.forward(**forward_kwargs) if cfg.TEST.HAS_RPN: assert len(im_scales) == 1, "Only single-image batch implemented" rois = net.blobs['rois'].data.copy() # unscale back to raw image space boxes = rois[:, 1:5] / im_scales[0] scores = blobs_out['cls_prob'] if cfg.TEST.BBOX_REG: # Apply bounding-box regression deltas box_deltas = blobs_out['bbox_pred'] pred_boxes = bbox_transform_inv(boxes, box_deltas) pred_boxes = clip_boxes(pred_boxes, im.shape) else: # Simply repeat the boxes, once for each class pred_boxes = np.tile(boxes, (1, scores.shape[1])) if cfg.DEDUP_BOXES > 0 and not cfg.TEST.HAS_RPN: # Map scores and predictions back to the original set of boxes scores = scores[inv_index, :] pred_boxes = pred_boxes[inv_index, :] feat = net.blobs['res4f'].data.copy() return scores, pred_boxes, feat def im_seg(net, im, feat, boxes=None): """Detect object classes in an image given object proposals. Arguments: net (caffe.Net): Fast R-CNN network to use im (ndarray): color image to test (in BGR order) boxes (ndarray): R x 4 array of object proposals or None (for RPN) Returns: scores (ndarray): R x K array of object class scores (K includes background as object category 0) boxes (ndarray): R x (4*K) array of predicted bounding boxes """ blobs, im_scales = _get_blobs(im, boxes, mask=True) # blobs['rois']=blobs['rois'][:,1:] # reshape network inputs net.blobs['res4f'].reshape(*(feat.shape)) net.blobs['rois'].reshape(*(blobs['rois'].shape)) # do forward # print(feat) net.blobs['res4f'].data[...] = feat net.blobs['rois'].data[...] = blobs['rois'] forward_kwargs = {'rois': blobs['rois'].astype(np.float32, copy=False), 'res4f': feat} blobs_out = net.forward() seg_result = blobs_out['mask_prob'] # print(seg_result) # print(np.unique(seg_result)) # print(np.unique(feat)) seg_result = np.array(seg_result > 0.5, dtype=np.int32) return seg_result def im_detect_rpn(net, im): """Detect object classes in an image given object proposals. Arguments: net (caffe.Net): Fast R-CNN network to use im (ndarray): color image to test (in BGR order) boxes (ndarray): R x 4 array of object proposals or None (for RPN) Returns: scores (ndarray): R x K array of object class scores (K includes background as object category 0) boxes (ndarray): R x (4*K) array of predicted bounding boxes """ blobs, im_scales = _get_blobs(im, None) # When mapping from image ROIs to feature map ROIs, there's some aliasing # (some distinct image ROIs get mapped to the same feature ROI). # Here, we identify duplicate feature ROIs, so we only compute features # on the unique subset. im_blob = blobs['data'] blobs['im_info'] = np.array( [[im_blob.shape[2], im_blob.shape[3], im_scales[0]]], dtype=np.float32) # reshape network inputs net.blobs['data'].reshape(*(blobs['data'].shape)) net.blobs['im_info'].reshape(*(blobs['im_info'].shape)) # do forward forward_kwargs = {'data': blobs['data'].astype(np.float32, copy=False)} forward_kwargs['im_info'] = blobs['im_info'].astype(np.float32, copy=False) blobs_out = net.forward(**forward_kwargs) assert len(im_scales) == 1, "Only single-image batch implemented" rois = net.blobs['rois'].data.copy() # unscale back to raw image space boxes = rois[:, 1:5] / im_scales[0] scores = net.blobs['scores'].data return scores, boxes def im_detect_mask(net, im, boxes=None): """Detect object classes in an image given object proposals. Arguments: net (caffe.Net): Fast R-CNN network to use im (ndarray): color image to test (in BGR order) boxes (ndarray): R x 4 array of object proposals or None (for RPN) Returns: masks (ndarray): R x M x M array of predicted masks """ boxes = boxes.reshape((-1,4)) blobs, im_scales = _get_blobs(im, boxes) # When mapping from image ROIs to feature map ROIs, there's some aliasing # (some distinct image ROIs get mapped to the same feature ROI). # Here, we identify duplicate feature ROIs, so we only compute features # on the unique subset. # reshape network inputs net.blobs['data'].reshape(*(blobs['data'].shape)) net.blobs['rois'].reshape(*(blobs['rois'].shape)) # do forward forward_kwargs = {'data': blobs['data'].astype(np.float32, copy=False)} forward_kwargs['rois'] = blobs['rois'].astype(np.float32, copy=False) blobs_out = net.forward(**forward_kwargs) masks = blobs_out['mask_prob'] return masks def vis_detections(im, class_name, dets, thresh=0.3): """Visual debugging of detections.""" import matplotlib.pyplot as plt im = im[:, :, (2, 1, 0)] for i in xrange(np.minimum(10, dets.shape[0])): bbox = dets[i, :4] score = dets[i, -1] if score > thresh: plt.cla() plt.imshow(im) plt.gca().add_patch( plt.Rectangle((bbox[0], bbox[1]), bbox[2] - bbox[0], bbox[3] - bbox[1], fill=False, edgecolor='g', linewidth=3) ) plt.title('{} {:.3f}'.format(class_name, score)) plt.show() def apply_nms(all_boxes, thresh): """Apply non-maximum suppression to all predicted boxes output by the test_net method. """ num_classes = len(all_boxes) num_images = len(all_boxes[0]) nms_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(num_classes)] for cls_ind in xrange(num_classes): for im_ind in xrange(num_images): dets = all_boxes[cls_ind][im_ind] if dets == []: continue # CPU NMS is much faster than GPU NMS when the number of boxes # is relative small (e.g., < 10k) # TODO(rbg): autotune NMS dispatch keep = nms(dets, thresh, force_cpu=True) if len(keep) == 0: continue nms_boxes[cls_ind][im_ind] = dets[keep, :].copy() return nms_boxes def test_net(net, imdb, max_per_image=400, thresh=-np.inf, vis=False, mask=False): """Test a Fast R-CNN network on an image database.""" num_images = len(imdb.image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score) all_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(imdb.num_classes)] output_dir = get_output_dir(imdb, net) # timers _t = {'im_detect' : Timer(), 'misc' : Timer()} if not cfg.TEST.HAS_RPN: roidb = imdb.roidb for i in xrange(num_images): # filter out any ground truth boxes if cfg.TEST.HAS_RPN: box_proposals = None else: # The roidb may contain ground-truth rois (for example, if the roidb # comes from the training or val split). We only want to evaluate # detection on the *non*-ground-truth rois. We select those the rois # that have the gt_classes field set to 0, which means there's no # ground truth. box_proposals = roidb[i]['boxes'][roidb[i]['gt_classes'] == 0] im = cv2.imread(imdb.image_path_at(i)) _t['im_detect'].tic() scores, boxes = im_detect(net, im, box_proposals) _t['im_detect'].toc() _t['misc'].tic() # skip j = 0, because it's the background class for j in xrange(1, imdb.num_classes): inds = np.where(scores[:, j] > thresh)[0] cls_scores = scores[inds, j] if cfg.TEST.AGNOSTIC: cls_boxes = boxes[inds, 4:8] else: cls_boxes = boxes[inds, j*4:(j+1)*4] cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis])) \ .astype(np.float32, copy=False) keep = nms(cls_dets, cfg.TEST.NMS) cls_dets = cls_dets[keep, :] if vis: vis_detections(im, imdb.classes[j], cls_dets) all_boxes[j][i] = cls_dets # Limit to max_per_image detections *over all classes* if max_per_image > 0: image_scores = np.hstack([all_boxes[j][i][:, -1] for j in xrange(1, imdb.num_classes)]) if len(image_scores) > max_per_image: image_thresh = np.sort(image_scores)[-max_per_image] for j in xrange(1, imdb.num_classes): keep = np.where(all_boxes[j][i][:, -1] >= image_thresh)[0] all_boxes[j][i] = all_boxes[j][i][keep, :] # _t['misc'].toc() # # _t['im_detect'].tic() # seg = im_seg(net, im, all_boxes[:][i]) # _t['im_detect'].toc() # # _t['misc'].tic() print 'im_detect: {:d}/{:d} {:.3f}s {:.3f}s' \ .format(i + 1, num_images, _t['im_detect'].average_time, _t['misc'].average_time) det_file = os.path.join(output_dir, 'detections.pkl') with open(det_file, 'wb') as f: cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL) print 'Evaluating detections' imdb.evaluate_detections(all_boxes, output_dir) def test_rpn(net, imdb, max_per_image=400, thresh=-np.inf, vis=False): """Test a Fast R-CNN network on an image database.""" num_images = len(imdb.image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score) all_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(2)] output_dir = get_output_dir(imdb, net) # timers _t = {'im_detect' : Timer(), 'misc' : Timer()} if not cfg.TEST.HAS_RPN: roidb = imdb.roidb for i in xrange(num_images): im = cv2.imread(imdb.image_path_at(i)) _t['im_detect'].tic() scores, boxes = im_detect_rpn(net, im) _t['im_detect'].toc() _t['misc'].tic() # skip j = 0, because it's the background class inds = np.where(scores[:] > thresh)[0] cls_scores = scores[inds] cls_boxes = boxes[inds, :] cls_dets = np.hstack((cls_boxes, cls_scores)) \ .astype(np.float32, copy=False) keep = nms(cls_dets, cfg.TEST.NMS) cls_dets = cls_dets[keep, :] if vis: vis_detections(im, imdb.classes[1], cls_dets) all_boxes[1][i] = cls_dets # Limit to max_per_image detections *over all classes* if max_per_image > 0: image_scores = np.hstack([all_boxes[1][i][:, -1] for j in xrange(1, 2)]) if len(image_scores) > max_per_image: image_thresh = np.sort(image_scores)[-max_per_image] for j in xrange(1, 2): keep = np.where(all_boxes[j][i][:, -1] >= image_thresh)[0] all_boxes[j][i] = all_boxes[j][i][keep, :] _t['misc'].toc() print 'im_detect: {:d}/{:d} {:.3f}s {:.3f}s' \ .format(i + 1, num_images, _t['im_detect'].average_time, _t['misc'].average_time) det_file = os.path.join(output_dir, 'detections.pkl') with open(det_file, 'wb') as f: cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL) print 'Evaluating detections' imdb.evaluate_detections(all_boxes, output_dir) def test_net_mask(net, net_mask, imdb, max_per_image=400, thresh=-np.inf, vis=False, save_path="./output/"): """Test a Fast R-CNN network on an image database.""" num_images = len(imdb.image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score) all_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(imdb.num_classes)] output_dir = get_output_dir(imdb, net) if not os.path.exists(save_path): os.makedirs(save_path) # timers _t = {'im_detect' : Timer(), 'im_seg' : Timer(),'misc' : Timer()} if not cfg.TEST.HAS_RPN: roidb = imdb.roidb for i in xrange(num_images): # filter out any ground truth boxes if cfg.TEST.HAS_RPN: box_proposals = None else: # The roidb may contain ground-truth rois (for example, if the roidb # comes from the training or val split). We only want to evaluate # detection on the *non*-ground-truth rois. We select those the rois # that have the gt_classes field set to 0, which means there's no # ground truth. box_proposals = roidb[i]['boxes'][roidb[i]['gt_classes'] == 0] im = cv2.imread(imdb.image_path_at(i)) print(im.shape) _t['im_detect'].tic() scores, boxes, feat = im_det(net, im, box_proposals) _t['im_detect'].toc() _t['misc'].tic() # skip j = 0, because it's the background class for j in xrange(1, imdb.num_classes): inds = np.where(scores[:, j] > thresh)[0] cls_scores = scores[inds, j] if cfg.TEST.AGNOSTIC: cls_boxes = boxes[inds, 4:8] else: cls_boxes = boxes[inds, j*4:(j+1)*4] cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis])) \ .astype(np.float32, copy=False) keep = nms(cls_dets, cfg.TEST.NMS) cls_dets = cls_dets[keep, :] if vis: vis_detections(im, imdb.classes[j], cls_dets) all_boxes[j][i] = cls_dets # Limit to max_per_image detections *over all classes* if max_per_image > 0: image_scores = np.hstack([all_boxes[j][i][:, -1] for j in xrange(1, imdb.num_classes)]) if len(image_scores) > max_per_image: image_thresh = np.sort(image_scores)[-max_per_image] for j in xrange(1, imdb.num_classes): keep = np.where(all_boxes[j][i][:, -1] >= image_thresh)[0] all_boxes[j][i] = all_boxes[j][i][keep, :] print 'im_detection: {:d}/{:d} {:.3f}s {:.3f}s' \ .format(i + 1, num_images, _t['im_detect'].average_time, _t['misc'].average_time) _t['im_seg'].tic() out_mask = np.zeros((im.shape[0], im.shape[1])) for j in xrange(1, imdb.num_classes): ins_index = 1 boxes_this_im = all_boxes[j][i][:, :-1] seg = im_seg(net_mask, im, feat, boxes_this_im) # print(seg.shape) for ii in xrange(seg.shape[0]): seg_now = seg[ii][0] # seg_now = np.transpose(seg_now) box_now = boxes_this_im[ii] box_now = box_now.astype(int) # im_now=im[box_now[1]: box_now[3], box_now[0]:box_now[2]] # cv2.imshow("test", im_now) # cv2.waitKey() seg_org_size = cv2.resize(seg_now, (box_now[2] - box_now[0], box_now[3] - box_now[1]), interpolation=cv2.INTER_NEAREST) # print((seg_org_size*99999).shape) # cv2.imshow("seg", seg_org_size*99999) # cv2.waitKey() seg_org_size = seg_org_size*ins_index out_mask[box_now[1]: box_now[3], box_now[0]:box_now[2]] = seg_org_size ins_index += 1 _t['im_seg'].toc() mask_save_path = os.path.join(save_path, os.path.basename(imdb.image_path_at(i)).replace(".jpg", ".png")) cv2.imwrite(mask_save_path, out_mask*100) print 'im_seg: {:d}/{:d} {:.3f}s' \ .format(i + 1, num_images, _t['im_seg'].average_time) det_file = os.path.join(output_dir, 'detections.pkl') with open(det_file, 'wb') as f: cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL) print 'Evaluating detections' imdb.evaluate_detections(all_boxes, output_dir) def test_net_mask_reload(net_proto, net_mask_proto, weights, imdb, max_per_image=400, thresh=-np.inf, vis=False, save_path="./output/"): """Test a Fast R-CNN network on an image database.""" num_images = len(imdb.image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score) caffe.set_mode_gpu() caffe.set_device(cfg.GPU_ID) all_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(imdb.num_classes)] net = caffe.Net(net_proto, weights, caffe.TEST) net.name = os.path.splitext(os.path.basename(weights))[0] output_dir = get_output_dir(imdb, net) if not os.path.exists(save_path): os.makedirs(save_path) # timers _t = {'im_detect' : Timer(), 'im_seg' : Timer(),'misc' : Timer()} if not cfg.TEST.HAS_RPN: roidb = imdb.roidb del net for i in xrange(num_images): # filter out any ground truth boxes if cfg.TEST.HAS_RPN: box_proposals = None else: # The roidb may contain ground-truth rois (for example, if the roidb # comes from the training or val split). We only want to evaluate # detection on the *non*-ground-truth rois. We select those the rois # that have the gt_classes field set to 0, which means there's no # ground truth. box_proposals = roidb[i]['boxes'][roidb[i]['gt_classes'] == 0] net = caffe.Net(net_proto, weights, caffe.TEST) net.name = os.path.splitext(os.path.basename(weights))[0] im = cv2.imread(imdb.image_path_at(i)) print(im.shape) _t['im_detect'].tic() scores, boxes, feat = im_det(net, im, box_proposals) _t['im_detect'].toc() _t['misc'].tic() # skip j = 0, because it's the background class for j in xrange(1, imdb.num_classes): inds = np.where(scores[:, j] > thresh)[0] cls_scores = scores[inds, j] if cfg.TEST.AGNOSTIC: cls_boxes = boxes[inds, 4:8] else: cls_boxes = boxes[inds, j*4:(j+1)*4] cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis])) \ .astype(np.float32, copy=False) keep = nms(cls_dets, cfg.TEST.NMS) cls_dets = cls_dets[keep, :] if vis: vis_detections(im, imdb.classes[j], cls_dets) all_boxes[j][i] = cls_dets # Limit to max_per_image detections *over all classes* if max_per_image > 0: image_scores = np.hstack([all_boxes[j][i][:, -1] for j in xrange(1, imdb.num_classes)]) if len(image_scores) > max_per_image: image_thresh = np.sort(image_scores)[-max_per_image] for j in xrange(1, imdb.num_classes): keep = np.where(all_boxes[j][i][:, -1] >= image_thresh)[0] all_boxes[j][i] = all_boxes[j][i][keep, :] print 'im_detection: {:d}/{:d} {:.3f}s {:.3f}s' \ .format(i + 1, num_images, _t['im_detect'].average_time, _t['misc'].average_time) del net net_mask = caffe.Net(net_mask_proto, weights, caffe.TEST) net_mask.name = os.path.splitext(os.path.basename(weights))[0] _t['im_seg'].tic() out_mask = np.zeros((im.shape[0], im.shape[1])) for j in xrange(1, imdb.num_classes): ins_index = 1 boxes_this_im = all_boxes[j][i][:, :-1] seg = im_seg(net_mask, im, feat, boxes_this_im) # print(seg.shape) for ii in xrange(seg.shape[0]): seg_now = seg[ii][0] # seg_now = np.transpose(seg_now) box_now = boxes_this_im[ii] box_now = box_now.astype(int) if box_now[2] == box_now[0] or box_now[3] == box_now[1]: continue # im_now=im[box_now[1]: box_now[3], box_now[0]:box_now[2]] # cv2.imshow("test", im_now) # cv2.waitKey() seg_org_size = cv2.resize(seg_now, (box_now[2] - box_now[0], box_now[3] - box_now[1]), interpolation=cv2.INTER_NEAREST) # print((seg_org_size*99999).shape) # cv2.imshow("seg", seg_org_size*99999) # cv2.waitKey() seg_org_size = seg_org_size*ins_index out_mask[box_now[1]: box_now[3], box_now[0]:box_now[2]] = seg_org_size ins_index += 1 _t['im_seg'].toc() mask_save_path = os.path.join(save_path, os.path.basename(imdb.image_path_at(i)).replace(".jpg", ".png")) cv2.imwrite(mask_save_path, out_mask*10) print 'im_seg: {:d}/{:d} {:.3f}s' \ .format(i + 1, num_images, _t['im_seg'].average_time) del net_mask det_file = os.path.join(output_dir, 'detections.pkl') with open(det_file, 'wb') as f: cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL) print 'Evaluating detections' imdb.evaluate_detections(all_boxes, output_dir)
38.972868
136
0.593138
4,325
30,165
3.956763
0.091561
0.020102
0.011687
0.015193
0.801496
0.781277
0.776953
0.773622
0.77035
0.764507
0
0.016894
0.277872
30,165
774
137
38.972868
0.768719
0.151301
0
0.706667
0
0
0.05485
0
0
0
0
0.001292
0.006667
0
null
null
0
0.028889
null
null
0.028889
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
8
648ab8829e3046513cd358f92d5bee3480c20f69
16,638
py
Python
tests/test_mdtr.py
Devyani-Divs/mirrormanager2
c56bfdb363608c5ea701ce8f089ab1b09abc4de9
[ "MIT" ]
1
2015-11-08T08:56:33.000Z
2015-11-08T08:56:33.000Z
tests/test_mdtr.py
Devyani-Divs/mirrormanager2
c56bfdb363608c5ea701ce8f089ab1b09abc4de9
[ "MIT" ]
null
null
null
tests/test_mdtr.py
Devyani-Divs/mirrormanager2
c56bfdb363608c5ea701ce8f089ab1b09abc4de9
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- ''' mirrormanager2 tests for the `Move Devel To Release` (MDTL) script. ''' __requires__ = ['SQLAlchemy >= 0.7'] import pkg_resources import unittest import subprocess import sys import os sys.path.insert(0, os.path.join(os.path.dirname( os.path.abspath(__file__)), '..')) import mirrormanager2.lib import mirrormanager2.lib.model as model import tests FOLDER = os.path.dirname(os.path.abspath(__file__)) CONFIG = """ DB_URL = '%(db_path)s' # Specify whether the crawler should send a report by email CRAWLER_SEND_EMAIL = False """ % {'db_path': tests.DB_PATH} class MDTLTest(tests.Modeltests): """ MDTL tests. """ def setUp(self): """ Set up the environnment, ran before every test. """ super(MDTLTest, self).setUp() self.configfile = os.path.join( FOLDER, 'mirrormanager2_tests_mdtr.cfg') with open(self.configfile, 'w') as stream: stream.write(CONFIG) self.script = os.path.join( FOLDER, '..', 'utility', 'mm2_move-devel-to-release') self.command = ('%s -c %s --version=20 '\ '--category=' % (self.script, self.configfile)).split() self.command[-1] += 'Fedora Linux' self.assertTrue(os.path.exists(self.configfile)) def test_mdtr_no_data(self): """ Test the mdtr script without the appropriate data in the database. """ command = self.command[:] process = subprocess.Popen( args=command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(stderr, '') self.assertEqual( stdout, "Category 'Fedora Linux' not found, exiting\n" "Available categories:\n") # Fill the DB a little bit tests.create_base_items(self.session) tests.create_directory(self.session) tests.create_category(self.session) tests.create_categorydirectory(self.session) process = subprocess.Popen( args=command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(stdout, 'Version 20 not found for product Fedora\n') self.assertEqual(stderr, '') # One step further tests.create_version(self.session) process = subprocess.Popen( args=command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(stdout, 'directory pub/fedora/linux/releases/20/Fedora/i386/os does not ' 'exist on disk, skipping creation of a repository there\n' 'directory pub/fedora-secondary/releases/20/Fedora/ppc/os does ' 'not exist on disk, skipping creation of a repository there\n' 'directory pub/fedora/linux/releases/20/Fedora/x86_64/os does ' 'not exist on disk, skipping creation of a repository there\n') self.assertEqual(stderr, '') process = subprocess.Popen( args=command[:] + ['--test'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(stdout, 'directory pub/fedora/linux/releases/20/Fedora/i386/os exists on' ' disk, but not in the database yet, skipping creation of a ' 'repository there until after the next UMDL run.\n' 'directory pub/fedora-secondary/releases/20/Fedora/ppc/os exists ' 'on disk, but not in the database yet, skipping creation of a ' 'repository there until after the next UMDL run.\n' 'directory pub/fedora/linux/releases/20/Fedora/x86_64/os exists ' 'on disk, but not in the database yet, skipping creation of a ' 'repository there until after the next UMDL run.\n') self.assertEqual(stderr, '') def test_mdtr(self): """ Test the mdtr script. """ command = self.command[:] # Fill the DB a little bit tests.create_base_items(self.session) tests.create_directory(self.session) tests.create_category(self.session) tests.create_categorydirectory(self.session) tests.create_version(self.session) item = model.Directory( name='pub/fedora/linux/releases/20/Fedora/x86_64/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora/linux/releases/20/Fedora/i386/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora-secondary/releases/20/Fedora/ppc/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora-secondary/releases/20/Fedora/sources/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora/linux/development/21/x86_64/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora/linux/releases/21/Fedora/x86_64/os', readable=True, ) self.session.add(item) item = model.Directory( name='pub/fedora/linux/releases/21/Everything/x86_64/os', readable=True, ) self.session.add(item) item = model.Repository( name='pub/fedora/linux/development/21/x86_64/os', prefix='fedora-21', version_id=3, arch_id=3, directory_id=14, category_id=1, ) self.session.add(item) item = model.Repository( name='pub/fedora/linux/releases/21/Everything/x86_64/os', prefix=None, version_id=3, arch_id=3, directory_id=16, category_id=1, ) self.session.add(item) item = model.Category( name='Fedora Secondary Arches', product_id=2, canonicalhost='http://download.fedora.redhat.com', topdir_id=1, publiclist=True ) self.session.add(item) self.session.commit() # Check before running the script results = mirrormanager2.lib.get_repositories(self.session) self.assertEqual(len(results), 2) results = mirrormanager2.lib.get_directories(self.session) # create_directory creates 9 directories # we create 7 more here, 9+7=16 self.assertEqual(len(results), 16) self.assertEqual( results[9].name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') self.assertEqual( results[10].name, 'pub/fedora/linux/releases/20/Fedora/i386/os') self.assertEqual( results[11].name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') self.assertEqual( results[12].name, 'pub/fedora-secondary/releases/20/Fedora/sources/os') self.assertEqual( results[13].name, 'pub/fedora/linux/development/21/x86_64/os') self.assertEqual( results[14].name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os') self.assertEqual( results[15].name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') # Run the script process = subprocess.Popen( args=command[:] + ['--test'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual( stdout, 'updating fedora-install-20 repo for arch i386\n' 'updating fedora-install-20 repo for arch ppc\n' 'updating fedora-install-20 repo for arch x86_64\n' ) self.assertEqual(stderr, '') # Check after running the script results = mirrormanager2.lib.get_repositories(self.session) self.assertEqual(len(results), 5) res = results[0] self.assertEqual(res.prefix, 'fedora-21') self.assertEqual( res.name, 'pub/fedora/linux/development/21/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '21') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/development/21/x86_64/os') res = results[1] self.assertEqual(res.prefix, None) self.assertEqual( res.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '21') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') res = results[2] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora/linux/releases/20/Fedora/i386/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'i386') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/20/Fedora/i386/os') res = results[3] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') self.assertEqual(res.category.name, 'Fedora Secondary Arches') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'ppc') self.assertEqual( res.directory.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') res = results[4] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') results = mirrormanager2.lib.get_directories(self.session) # create_directory creates 9 directories # we create 7 more here, 9+7=16 self.assertEqual(len(results), 16) self.assertEqual( results[9].name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') self.assertEqual( results[10].name, 'pub/fedora/linux/releases/20/Fedora/i386/os') self.assertEqual( results[11].name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') self.assertEqual( results[12].name, 'pub/fedora-secondary/releases/20/Fedora/sources/os') self.assertEqual( results[13].name, 'pub/fedora/linux/development/21/x86_64/os') self.assertEqual( results[14].name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os') self.assertEqual( results[15].name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') # Update F21 command = ('%s -c %s --version=21 '\ '--category=' % (self.script, self.configfile)).split() command[-1] += 'Fedora Linux' process = subprocess.Popen( args=command[:] + ['--test'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() print stdout self.assertEqual( stdout, 'pub/fedora/linux/development/21/x86_64/os => ' 'pub/fedora/linux/releases/21/Everything/x86_64/os\n' 'directory pub/fedora/linux/releases/21/Fedora/i386/os exists ' 'on disk, but not in the database yet, skipping creation of a ' 'repository there until after the next UMDL run.\n' 'directory pub/fedora-secondary/releases/21/Fedora/ppc/os exists ' 'on disk, but not in the database yet, skipping creation of a ' 'repository there until after the next UMDL run.\n' 'updating fedora-install-21 repo for arch x86_64\n' ) self.assertEqual(stderr, '') # Check after running the script results = mirrormanager2.lib.get_repositories(self.session) self.assertEqual(len(results), 6) res = results[0] self.assertEqual(res.prefix, 'fedora-21') self.assertEqual( res.name, 'pub/fedora/linux/development/21/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '21') self.assertEqual(res.arch, None) self.assertEqual( res.directory.name, 'pub/fedora/linux/development/21/x86_64/os') res = results[1] self.assertEqual(res.prefix, 'fedora-21') self.assertEqual( res.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '21') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') res = results[2] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora/linux/releases/20/Fedora/i386/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'i386') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/20/Fedora/i386/os') res = results[3] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') self.assertEqual(res.category.name, 'Fedora Secondary Arches') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'ppc') self.assertEqual( res.directory.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') res = results[4] self.assertEqual(res.prefix, 'fedora-install-20') self.assertEqual( res.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '20') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') res = results[5] self.assertEqual(res.prefix, 'fedora-install-21') self.assertEqual( res.name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os') self.assertEqual(res.category.name, 'Fedora Linux') self.assertEqual(res.version.name, '21') self.assertEqual(res.arch.name, 'x86_64') self.assertEqual( res.directory.name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os') results = mirrormanager2.lib.get_directories(self.session) # create_directory creates 9 directories # we create 7 more here, 9+7=16 self.assertEqual(len(results), 16) self.assertEqual( results[9].name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os') self.assertEqual( results[10].name, 'pub/fedora/linux/releases/20/Fedora/i386/os') self.assertEqual( results[11].name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os') self.assertEqual( results[12].name, 'pub/fedora-secondary/releases/20/Fedora/sources/os') self.assertEqual( results[13].name, 'pub/fedora/linux/development/21/x86_64/os') self.assertEqual( results[14].name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os') self.assertEqual( results[15].name, 'pub/fedora/linux/releases/21/Everything/x86_64/os') if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(MDTLTest) unittest.TextTestRunner(verbosity=10).run(SUITE)
36.327511
78
0.602837
1,955
16,638
5.07468
0.10179
0.158754
0.119746
0.072573
0.866143
0.847193
0.832577
0.823103
0.808084
0.796291
0
0.042233
0.274192
16,638
457
79
36.407002
0.779314
0.024943
0
0.741848
0
0
0.296756
0.17912
0
0
0
0
0.288043
0
null
null
0
0.021739
null
null
0.002717
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
8
648f0edd698e37321d0c9ce88a74e10dbdcf7d99
35,444
py
Python
pyslam/feature_tracker_configs.py
dysdsyd/VO_benchmark
a7602edab934419c1ec73618ee655e18026f834f
[ "Apache-2.0" ]
2
2021-09-11T09:13:31.000Z
2021-11-03T01:39:56.000Z
pyslam/feature_tracker_configs.py
dysdsyd/VO_benchmark
a7602edab934419c1ec73618ee655e18026f834f
[ "Apache-2.0" ]
null
null
null
pyslam/feature_tracker_configs.py
dysdsyd/VO_benchmark
a7602edab934419c1ec73618ee655e18026f834f
[ "Apache-2.0" ]
null
null
null
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * PYSLAM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PYSLAM. If not, see <http://www.gnu.org/licenses/>. """ from feature_tracker import feature_tracker_factory, FeatureTrackerTypes from feature_manager import feature_manager_factory from feature_types import FeatureDetectorTypes, FeatureDescriptorTypes, FeatureInfo from feature_matcher import feature_matcher_factory, FeatureMatcherTypes from parameters import Parameters # some default parameters kNumFeatures=Parameters.kNumFeatures kRatioTest=Parameters.kFeatureMatchRatioTest kTrackerType = FeatureTrackerTypes.DES_BF # default descriptor-based, brute force matching with knn #kTrackerType = FeatureTrackerTypes.DES_FLANN # default descriptor-based, FLANN-based matching """ A collection of ready-to-used feature tracker configurations """ class FeatureTrackerConfigs(object): # Test/Template configuration: you can use this to quickly test # - your custom parameters and # - favourite descriptor and detector (check the file feature_types.py) TEST = dict(num_features=kNumFeatures, num_levels = 8, # N.B: some detectors/descriptors do not allow to set num_levels or they set it on their own scale_factor = 1.2, # N.B: some detectors/descriptors do not allow to set scale_factor or they set it on their own detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ###################################################### #################### TEST CONFIG COMBINATION ######### ###################################################### # Format: T[XX]_[YY]_[ZZ]; # XX is test ID number # YY is detector name # ZZ is descriptor name # there are 42 combinations + some deep learning test_configs = { 'T01_SHI_NONE':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T02_SHI_SIFT':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T03_SHI_SURF':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T04_SHI_ORB2':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T05_SHI_BRISK':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T06_SHI_TFEAT':dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## FAST detector + 6 descriptors 'T07_FAST_NONE':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T08_FAST_SIFT':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T09_FAST_SURF':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T10_FAST_ORB2':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T11_FAST_BRISK':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T12_FAST_TFEAT':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## SIFT detector + 6 descriptors 'T13_SIFT_NONE':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'TXX_SIFT_ORB2':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T14_SIFT_SIFT':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T15_SIFT_SURF':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T16_SIFT_ORB2':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T17_SIFT_BRISK':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T18_SIFT_TFEAT':dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## SURF detector + 6 descriptors 'T19_SURF_NONE':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T20_SURF_SIFT':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T21_SURF_SURF':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T22_SURF_ORB2':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T23_SURF_BRISK':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T24_SURF_TFEAT':dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## ORB2 detector + 6 descriptors 'T25_ORB2_NONE':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T26_ORB2_SIFT':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T27_ORB2_SURF':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T28_ORB2_ORB2':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T29_ORB2_BRISK':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T30_ORB2_TFEAT':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## BRISK detector + 6 descriptors 'T31_BRISK_NONE':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T32_BRISK_SIFT':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T33_BRISK_SURF':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T34_BRISK_ORB2':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T35_BRISK_BRISK':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T36_BRISK_TFEAT':dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done ## KEYNET detector + 6 descriptors 'T37_KEYNET_NONE':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK), # done 'T38_KEYNET_SIFT':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T39_KEYNET_SURF':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T40_KEYNET_ORB2':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T41_KEYNET_BRISK':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done 'T42_KEYNET_TFEAT':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # done # Deep learning features with 1-1 map (cannot combine with others) # T50 - T53 has some template, and we can use as is. 'T50_SUPERPOINT':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.SUPERPOINT, descriptor_type = FeatureDescriptorTypes.SUPERPOINT, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T51_CONTEXTDESC':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.CONTEXTDESC, descriptor_type = FeatureDescriptorTypes.CONTEXTDESC, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T52_KEYNET':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.KEYNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T53_DISK':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.DISK, descriptor_type = FeatureDescriptorTypes.DISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType), ## New DL features 'T54_R2D2_R2D2':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.R2D2, descriptor_type = FeatureDescriptorTypes.R2D2, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T55_LFNET_LFNET':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.LFNET, descriptor_type = FeatureDescriptorTypes.LFNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T56_ORB2_VGG':dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.VGG, match_ratio_test = kRatioTest, tracker_type = kTrackerType), # orb and DL feats 'T57_ORB2_HARDNET': dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.HARDNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T58_ORB2_SOSNET': dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.SOSNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T59_ORB2_L2NET': dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.L2NET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), 'T60_D2NET_D2NET':dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.D2NET, descriptor_type = FeatureDescriptorTypes.D2NET, match_ratio_test = kRatioTest, tracker_type = kTrackerType), } # ===================================== # LK trackers (these can only be used with VisualOdometry() ... at the present time) LK_SHI_TOMASI = dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK) LK_FAST = dict(num_features=kNumFeatures, num_levels = 3, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.NONE, tracker_type = FeatureTrackerTypes.LK) # ===================================== # Descriptor-based 'trackers' SHI_TOMASI_ORB = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always) num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.ORB, match_ratio_test = kRatioTest, tracker_type = kTrackerType) SHI_TOMASI_FREAK = dict(num_features=kNumFeatures, num_levels=8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.SHI_TOMASI, descriptor_type = FeatureDescriptorTypes.FREAK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) FAST_ORB = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always) num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.ORB, match_ratio_test = kRatioTest, tracker_type = kTrackerType) FAST_FREAK = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.FAST, descriptor_type = FeatureDescriptorTypes.FREAK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) BRISK = dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) BRISK_TFEAT = dict(num_features=kNumFeatures, num_levels = 4, scale_factor = 1.2, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.TFEAT, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB, descriptor_type = FeatureDescriptorTypes.ORB, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB2 = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.ORB2, match_ratio_test = kRatioTest, tracker_type = kTrackerType) BRISK = dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.BRISK, descriptor_type = FeatureDescriptorTypes.BRISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) KAZE = dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.KAZE, descriptor_type = FeatureDescriptorTypes.KAZE, match_ratio_test = kRatioTest, tracker_type = kTrackerType) AKAZE = dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.AKAZE, descriptor_type = FeatureDescriptorTypes.AKAZE, match_ratio_test = kRatioTest, tracker_type = kTrackerType) SIFT = dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.SIFT, descriptor_type = FeatureDescriptorTypes.SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ROOT_SIFT = dict(num_features=kNumFeatures, detector_type = FeatureDetectorTypes.ROOT_SIFT, descriptor_type = FeatureDescriptorTypes.ROOT_SIFT, match_ratio_test = kRatioTest, tracker_type = kTrackerType) # NOTE: SURF is a patented algorithm and not included in the new opencv versions # If you want to test it, you can install and old version of opencv that supports it: run # $ pip3 uninstall opencv-contrib-python # $ pip3 install opencv-contrib-python==3.4.2.16 SURF = dict(num_features=kNumFeatures, num_levels = 8, detector_type = FeatureDetectorTypes.SURF, descriptor_type = FeatureDescriptorTypes.SURF, match_ratio_test = kRatioTest, tracker_type = kTrackerType) SUPERPOINT = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always) num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.SUPERPOINT, descriptor_type = FeatureDescriptorTypes.SUPERPOINT, match_ratio_test = kRatioTest, tracker_type = kTrackerType) CONTEXTDESC = dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.CONTEXTDESC, descriptor_type = FeatureDescriptorTypes.CONTEXTDESC, match_ratio_test = kRatioTest, tracker_type = kTrackerType) KEYNET = dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.KEYNET, descriptor_type = FeatureDescriptorTypes.KEYNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType) DISK = dict(num_features=kNumFeatures, num_levels = 1, scale_factor = 1.2, detector_type = FeatureDetectorTypes.DISK, descriptor_type = FeatureDescriptorTypes.DISK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) # ===================================== # Descriptor-based 'trackers' with ORB2 ORB2_FREAK = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.FREAK, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB2_BEBLID = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.BEBLID, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB2_HARDNET = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.HARDNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB2_SOSNET = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.SOSNET, match_ratio_test = kRatioTest, tracker_type = kTrackerType) ORB2_L2NET = dict(num_features=kNumFeatures, num_levels = 8, scale_factor = 1.2, detector_type = FeatureDetectorTypes.ORB2, descriptor_type = FeatureDescriptorTypes.L2NET, match_ratio_test = kRatioTest, tracker_type = kTrackerType)
52.04699
159
0.49289
2,620
35,444
6.387405
0.10916
0.033463
0.071706
0.129071
0.840215
0.836391
0.833045
0.810218
0.795698
0.783269
0
0.019485
0.448313
35,444
680
160
52.123529
0.836351
0.076402
0
0.802281
0
0
0.022568
0
0
0
0
0
0
1
0
false
0
0.009506
0
0.062738
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
64b16ebfd26819bd4c8d9aa5796193c67ffe62b2
29,216
py
Python
includes/imagedata.py
take-a-CHANCE/weatherPi
7a67204faa65d7921239fe8b6b3cbd6fc25cc49a
[ "MIT" ]
null
null
null
includes/imagedata.py
take-a-CHANCE/weatherPi
7a67204faa65d7921239fe8b6b3cbd6fc25cc49a
[ "MIT" ]
null
null
null
includes/imagedata.py
take-a-CHANCE/weatherPi
7a67204faa65d7921239fe8b6b3cbd6fc25cc49a
[ "MIT" ]
null
null
null
## # @filename : imagedata.py # @brief : data file for epd demo # # Copyright (C) Waveshare July 26 2017 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # IMAGE_BLACK = [ # 0X00,0X01,0X68,0X00,0XD4,0X00, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XBF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XCF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF, 0XC3,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC7,0XFF,0XFF,0XC0,0X3F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XE0,0X0F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XF0,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XE7,0XFF,0XFF,0XF8,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF, 0XFF,0XFC,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFE,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0X00,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0X80,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XC0,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7, 0XFF,0XFF,0XFF,0XC0,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF, 0XE0,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XE0,0X7F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XE0,0X7F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XF0,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XE7,0XFF,0XFF,0XFF,0XF0,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF, 0XFF,0XF0,0X7F,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XF0,0X7F, 0XBF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XF0,0X7E,0X7F,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF,0XF0,0X7E,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XE7,0XFF,0XFF,0XFF,0XF0,0X7C,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF, 0XFF,0XFF,0XF0,0X7D,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XFC,0X03,0XE0, 0XFD,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XF8,0X00,0XE0,0X79,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XF0,0X00,0X60,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XE7,0XFF,0XE0,0X00,0X30,0XF8,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7, 0XFF,0XC0,0X60,0X11,0X80,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0X00,0X30, 0X19,0X00,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFE,0X40,0X20,0X08,0X00,0X00, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XC1,0XC0,0X00,0X08,0X00,0X7F,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XE7,0X80,0XC0,0X20,0X08,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XE7,0X00,0X4C,0X20,0X08,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE6,0X10,0X04, 0X20,0X00,0X1D,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE6,0X10,0X04,0X20,0X40,0X7C, 0XFF,0XF9,0XFF,0XFF,0XFF,0XFF,0XFF,0XE4,0X10,0X00,0X00,0X80,0XFC,0XFF,0XE0,0X7F, 0XFF,0XFF,0XFF,0XFF,0XE4,0X0C,0X00,0X03,0X0F,0XFC,0X7F,0XE4,0X3F,0XFF,0XFF,0XFF, 0XFF,0XE4,0X0E,0X00,0XC0,0X1F,0XFC,0X7F,0XC0,0X1F,0XFF,0XFF,0XFF,0XFF,0XE4,0X0B, 0X83,0XE0,0X0F,0XFC,0X7F,0XC2,0X1F,0XFF,0XFF,0XFF,0XFF,0XE6,0X00,0X07,0XF0,0X0F, 0XFE,0X7F,0XC1,0X0F,0XFF,0XFF,0XFF,0XFF,0XE6,0X00,0X07,0XF0,0X07,0XFE,0X7F,0XC0, 0X8F,0XFF,0XFF,0XFF,0XFF,0XE7,0X00,0X07,0XF0,0X03,0XFE,0X7F,0XE0,0X7F,0XFF,0XFF, 0XFF,0XFF,0XE7,0X80,0X03,0XF3,0X01,0XFE,0X7F,0XE0,0X1F,0XFF,0XFF,0XFF,0XFF,0XE7, 0XC0,0X03,0XE3,0X80,0XFE,0X7F,0XF0,0X1F,0XFF,0XFF,0XFF,0XFF,0XE7,0XF8,0X00,0XC0, 0XE0,0XFC,0X7F,0XF0,0X87,0XFF,0XFF,0XFF,0XFF,0XE7,0XF7,0X00,0X00,0X3C,0XFC,0X7F, 0XF0,0X83,0XFF,0XFF,0XFF,0XFF,0XE7,0XF9,0X80,0X00,0X18,0XFC,0XFF,0XF0,0X81,0XFF, 0XFF,0XFF,0XFF,0XE7,0X9D,0X80,0X04,0X00,0XFC,0XFF,0XF1,0XC1,0XFF,0XFF,0XFF,0XFF, 0XE6,0X35,0X01,0X04,0X00,0XFD,0XFF,0XF3,0X71,0XFF,0XFF,0XFF,0XFF,0XE6,0X62,0X02, 0X00,0X00,0XFD,0XFF,0XE2,0X01,0XFF,0XFF,0XFF,0XFF,0XE4,0XC2,0X02,0X00,0X00,0XFB, 0XFF,0XE2,0X01,0XFF,0XFF,0XFF,0XFF,0XE5,0X82,0X02,0X00,0X01,0XF3,0XFF,0XE0,0X01, 0XFF,0XFF,0XFF,0XFF,0XE3,0X01,0X0E,0X00,0X03,0XF3,0XFF,0XE4,0X01,0XFF,0XFF,0XFF, 0XFF,0XE6,0X01,0X83,0X00,0X7F,0XE7,0XFF,0XC0,0X00,0XFF,0XFF,0XFF,0XFF,0XE4,0X01, 0X81,0X00,0XFF,0XCF,0XFF,0XE0,0X00,0X3F,0XFF,0XFF,0XFF,0XE0,0X01,0X80,0X00,0XFF, 0X8F,0XFF,0XE0,0X00,0X1F,0XFF,0XFF,0XFF,0XE0,0X03,0XC0,0X01,0XFF,0X9F,0XFF,0XE0, 0X01,0X1F,0XFF,0XFF,0XFF,0XE0,0X0F,0XF8,0X01,0XFF,0XDF,0XFF,0XFC,0X16,0X1F,0XFF, 0XFF,0XFF,0XE0,0X1F,0XF0,0XC7,0XF8,0X3F,0XFF,0XF6,0X1F,0X1F,0XFF,0XFF,0XFF,0XE0, 0X3F,0XC0,0X6F,0XF0,0X1F,0XFF,0XE2,0X01,0X1F,0XFF,0XFF,0XFF,0XE0,0X7F,0XC0,0X3F, 0XC0,0X0F,0XFF,0XCC,0X00,0X9F,0XFF,0XFF,0XFF,0XE0,0XFF,0XC0,0X1F,0XC0,0X0F,0XFF, 0XDE,0X00,0X19,0XFF,0XFF,0XFF,0XE0,0XFF,0X80,0X0F,0X80,0X0F,0XFF,0X9F,0X00,0X00, 0XFF,0XFF,0XFF,0XE1,0XFF,0X80,0X40,0X00,0X07,0XFF,0X9F,0XFE,0X00,0XFF,0XFF,0XFF, 0XF3,0XFF,0X80,0XC0,0X00,0X07,0XFF,0XBF,0XFF,0X00,0X7F,0XFF,0XFF,0XE7,0XFF,0XC0, 0X80,0X00,0X07,0XFF,0XBF,0XFF,0X90,0X7F,0XFF,0XFF,0XE7,0XFF,0XC7,0X80,0X00,0X0F, 0XFF,0XBF,0XFF,0XD8,0X7F,0XFF,0XFF,0XE7,0XFF,0XE0,0XC0,0X00,0X3F,0XFF,0X3F,0XFF, 0XE0,0X7F,0XFF,0XFF,0XE7,0XFF,0XE0,0XC0,0X00,0X1F,0XFF,0X3F,0XFF,0XF0,0XFF,0XFF, 0XFF,0XE7,0XFF,0XF0,0X20,0X80,0X07,0XFF,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF, 0XE0,0X30,0X00,0X03,0XFF,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFF,0XC0,0X30,0X40, 0X03,0XFF,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XFC,0X40,0X10,0X60,0X03,0XFF,0X7F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XE7,0XE0,0XC0,0X18,0X3C,0X07,0XFE,0X7F,0XFF,0XFF,0XFF, 0XFF,0XFF,0XE7,0X87,0XC0,0X08,0X18,0X0F,0XFC,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7, 0X0F,0XE0,0X08,0X10,0X1F,0XFC,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF6,0X7F,0XFE,0X0C, 0X10,0X43,0XF9,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0XFF,0XF1,0X04,0X10,0X81,0XF3, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF1,0XFF,0XE1,0X04,0X11,0X81,0XE3,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XF3,0XFF,0XC0,0X06,0X11,0X80,0X4F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XF3,0XFF,0XC0,0X02,0X10,0X00,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0XC0, 0X22,0X10,0X08,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0XC0,0X3A,0X30,0X0C, 0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0XC2,0X18,0X00,0X0C,0X7F,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0XC3,0X10,0X00,0X1C,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XF7,0XFF,0XC1,0X80,0X00,0X60,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF, 0X80,0XC0,0X00,0XC0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0X80,0XC0,0X01, 0X80,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XF0,0X00,0X30,0X00,0X00,0X1F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0X03,0XE0,0X00,0XE0,0X00,0X1F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XF6,0X0F,0XF0,0X01,0XF0,0X02,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0, 0XFF,0XF8,0X03,0XF8,0X3C,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF1,0XE0,0X04,0X07, 0XF8,0X00,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF3,0X80,0X02,0X07,0XF8,0X00,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF6,0X0F,0XFE,0X07,0XF8,0X01,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XF0,0X7F,0XFC,0X03,0XF8,0X03,0XBF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XF1,0XE0,0X10,0X21,0XF0,0X03,0X27,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF3,0X07,0XC0, 0XC0,0X60,0X81,0X91,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X3F,0XC1,0X00,0X00,0XC1, 0XD8,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X7F,0X87,0X04,0X00,0X60,0X4C,0X3F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0X86,0X0C,0X00,0X20,0X4F,0X3F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XF7,0XFF,0X80,0X18,0X08,0X10,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF, 0XC0,0X18,0X08,0X08,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XFF,0XC0,0X10,0X4C, 0X0F,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0X00,0X40,0X00,0X44,0X0C,0X3F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X00,0X0C,0X46,0X0C,0X3F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XF0,0X00,0X30,0X1C,0XC6,0X0C,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF1, 0XFF,0XF8,0XF8,0XC6,0X0C,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X1C,0X00, 0XC6,0X0C,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X0C,0X00,0XC3,0X00,0X3F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF3,0X80,0X18,0X00,0XC3,0X00,0X3F,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XF7,0XFF,0X70,0X00,0XC1,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XF7,0XFF,0XE0,0X00,0XC3,0X80,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XC0, 0X00,0XC7,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF1,0XFF,0X80,0X00,0XC6,0X07, 0X9F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X7F,0XC0,0X08,0XC4,0X03,0X0F,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XF0,0X0F,0XC0,0X18,0XC0,0X03,0X47,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XF3,0X83,0X80,0X20,0XC0,0X02,0X39,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0XE0, 0XC0,0X00,0XC0,0X02,0X0C,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X1C,0X40,0X43,0X70, 0XFC,0X03,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X0F,0X20,0XC2,0X31,0XEC,0X03,0X8F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X03,0X9F,0XC4,0X03,0XFF,0X00,0XC7,0XFF,0XFF,0XFF, 0XFF,0XFF,0XF0,0X00,0X6F,0XE0,0X07,0X3F,0X80,0X63,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7, 0X00,0X31,0XE0,0X04,0XFF,0XC0,0X31,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XE0,0X18,0XF0, 0X01,0XFF,0XF0,0X1C,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XF8,0X0E,0X30,0X0B,0XFF,0XF0, 0X0C,0X7F,0XFF,0XFF,0XFF,0XFF,0XF7,0XFC,0X07,0X18,0X1F,0XFF,0XFC,0X0F,0X3F,0XFF, 0XFF,0XFF,0XFF,0XF3,0XFE,0X07,0X1C,0X3F,0XFF,0XFE,0X07,0X9F,0XFF,0XFF,0XFF,0XFF, 0XF3,0XFF,0X83,0XCF,0XFF,0XFF,0XFF,0X03,0X8F,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XC3, 0XE7,0XFF,0XFF,0XFF,0X83,0XE7,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XC1,0XF7,0XFF,0XFF, 0XFF,0X81,0XE3,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XE1,0XF3,0XFF,0XFF,0XFF,0XC1,0XF1, 0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XE0,0XFB,0XFF,0XFF,0XFF,0XE0,0XF9,0XFF,0XFF,0XFF, 0XFF,0XF3,0XFF,0XF0,0XF9,0XFF,0XFF,0XFF,0XF0,0XFC,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF, 0XF8,0XFD,0XFF,0XFF,0XFF,0XF8,0XFE,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XF8,0X7C,0XFF, 0XFF,0XFF,0XFC,0X7F,0X7F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFC,0X7C,0X7F,0XFF,0XFF,0XFE, 0X7F,0X3F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFC,0X3E,0X7F,0XFF,0XFF,0XFF,0X7F,0XBF,0XFF, 0XFF,0XFF,0XF3,0XFF,0XFE,0X3E,0X3F,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XF3, 0XFF,0XFE,0X3F,0X3F,0XFF,0XFF,0XFF,0XFF,0XCF,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X3F, 0X3F,0XF0,0XFF,0XFF,0XFF,0XEF,0XFF,0XFF,0XFF,0XF3,0XFF,0XFE,0X3F,0XBF,0XF0,0X03, 0XFF,0XFF,0XC7,0XFF,0XFF,0XFF,0XF3,0XFF,0XFE,0X3F,0XBF,0XE0,0X01,0XFF,0XFF,0XE7, 0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X3F,0X9F,0XE0,0X00,0XFF,0XFF,0XE7,0XFF,0XFF,0XFF, 0XF3,0XFF,0XFF,0X3F,0XDF,0XF0,0X00,0X7F,0XFF,0XF3,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF, 0X3F,0XDF,0XFB,0X00,0X7F,0XFF,0XF3,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X3F,0XDF,0XF0, 0X00,0X7F,0XFF,0XFB,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X7F,0XDF,0XC0,0X10,0X3F,0XFF, 0XFB,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XC0,0X10,0X3F,0XFF,0XFB,0XFF,0XFF, 0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XC0,0X10,0X1F,0XFF,0XFB,0XFF,0XFF,0XFF,0XF3,0XFF, 0XFF,0XFF,0XDF,0XC1,0XF8,0X1F,0XFF,0XFB,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF, 0XC0,0X0C,0X0F,0XFF,0XFB,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XE0,0X06,0X03, 0XFF,0XF3,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XE0,0X03,0X00,0X1F,0XF3,0XFF, 0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XF8,0X01,0XC0,0X03,0XE7,0XFF,0XFF,0XFF,0XF3, 0XFF,0XFF,0XFF,0XDF,0XFC,0X00,0X7F,0X01,0XE7,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF, 0XDF,0XFC,0X00,0X3F,0XC0,0XC7,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XFC,0X00, 0X00,0X00,0XEF,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XFC,0X00,0X00,0X00,0XDF, 0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XFC,0X00,0X00,0X00,0XDF,0XFF,0XFF,0XFF, 0XF3,0XFF,0XFF,0XFF,0X9F,0XFE,0X00,0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF, 0XFF,0X1F,0XFF,0X80,0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFE,0X1F,0XFF, 0XE0,0X00,0X00,0X1F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFC,0X1F,0XFF,0XF0,0X00,0X00, 0X1F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFF,0X9F,0XFF,0XF0,0X00,0X18,0X1F,0XFF,0XFF, 0XFF,0XF3,0XFF,0XFF,0XFF,0XDF,0XFF,0XF0,0X00,0X30,0X1F,0XFF,0XFF,0XFF,0XF3,0XFF, 0XFF,0XFF,0XDF,0XFF,0XF1,0X83,0XC0,0X3F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0XFE,0XCF, 0XFF,0XE0,0XFF,0X01,0X3F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X84,0XCF,0XFF,0X00,0X70, 0X01,0X1F,0XFF,0XFF,0XFF,0XF3,0XFF,0XFF,0X06,0X67,0XFE,0X00,0X40,0X02,0X3F,0XFF, 0XFF,0XFF,0XF3,0XFF,0XFE,0X07,0XE7,0XFE,0X00,0X40,0X06,0X3F,0XFF,0XFF,0XFF,0XFB, 0XFF,0XFC,0X03,0XE1,0XFE,0X00,0X40,0X06,0X7F,0XFF,0XFF,0XFF,0XFB,0XFF,0XFC,0X04, 0X60,0XFF,0X00,0X40,0X0C,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0XFE,0X18,0X30,0X7F,0X80, 0X00,0X18,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0XE0,0X38,0X36,0X3F,0XC0,0X00,0X19,0XFF, 0XFF,0XFF,0XFF,0XFB,0XFF,0XC0,0X20,0X33,0X1F,0XF0,0X00,0X31,0XFF,0XFF,0XFF,0XFF, 0XFB,0XFF,0XC0,0XC8,0X11,0X8F,0XF8,0X00,0X63,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0X80, 0XC0,0X39,0X8F,0XFC,0X00,0X63,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0XF9,0X80,0X48,0XC7, 0XFC,0X00,0X43,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0XBF,0X06,0XC4,0X07,0XFC,0X00,0XC3, 0XFF,0XFF,0XFF,0XFF,0XFB,0XFE,0X03,0X07,0X86,0X07,0XFC,0X0C,0X83,0XFF,0XFF,0XFF, 0XFF,0XFB,0XFE,0X01,0X07,0X86,0X07,0XFC,0X1E,0X83,0XFF,0XFF,0XFF,0XFF,0XFB,0XFC, 0X05,0X07,0X93,0X07,0XFC,0X1D,0X81,0XFF,0XFF,0XFF,0XFF,0XFB,0XFC,0X08,0X0F,0XB1, 0X03,0XFE,0X23,0XE1,0XFF,0XFF,0XFF,0XFF,0XFB,0XFF,0XF8,0XFF,0X99,0X23,0XFF,0XE7, 0X30,0XFF,0XFF,0XFF,0XFF,0XFB,0XFE,0X00,0XFF,0XC0,0X91,0XFF,0X80,0X10,0X7F,0XFF, 0XFF,0XFF,0XFB,0XFC,0X00,0XFF,0XE0,0X98,0XFF,0X00,0X00,0X7F,0XFF,0XFF,0XFF,0XFF, 0XFC,0X00,0XFF,0XE0,0X8C,0X7F,0X00,0X00,0X7F,0XFF,0XFF,0XFF,0XFF,0XFC,0X21,0XFF, 0XF8,0X80,0X7F,0X00,0X00,0X7F,0XFF,0XFF,0XFF,0XFF,0XFC,0X71,0XFF,0XFC,0X80,0X7F, 0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X40,0X3F,0X80,0X00,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X3F,0X80,0X01,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X3F,0XE0,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XC0,0X7F,0XFC,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0, 0X3F,0XFC,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X3F,0XFC,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X03,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X9F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF, ] IMAGE_RED = [ # 0X00,0X01,0X68,0X00,0XD4,0X00, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X7F, 0XFE,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X3F,0XFC,0X3F,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X1F,0XF0,0X3F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X0F,0XC0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0X80,0X47,0X80,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X80, 0X02,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X83,0X86,0X78,0X3F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X82,0X0C,0XE0,0X0F,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X0C,0X80,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0X80,0X05,0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XC6,0X04,0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X04,0X00, 0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X04,0X60,0X01,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X06,0X60,0X01,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFC,0X0E,0X00,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XE2,0X20,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00, 0X10,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X80,0X00,0X07,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X80,0X18,0X07,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X80,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XF0,0XC0,0X80,0X3C,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0, 0XC0,0X7F,0XF0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X60,0X40,0X00, 0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X38,0X20,0X00,0X0F,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X1C,0X18,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFC,0X03,0X0C,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0X06,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0XC9,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0XCF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X47,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XE0,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0, 0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X07,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF9,0XCF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XEF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X3F,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFE,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X00, 0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X00,0X07,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X4E,0X07,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X01,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFE,0X01,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE, 0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X00,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X03,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X1C,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFE,0X68,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XF0,0XC4,0X00,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF1,0X06,0X00, 0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE1,0X03,0X00,0X3F,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE2,0X01,0X80,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XC1,0XC0,0X80,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XC0,0X70,0XC0,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X38, 0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X0C,0X01,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X1F,0XFF,0X8F,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X70,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0X81,0X00,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC1, 0X00,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X0F,0XC0,0X7F, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X0F,0XC0,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFA,0X07,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFE,0X07,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X08,0X03, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X03,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XF8,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC, 0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF, ]
76.682415
80
0.787616
5,706
29,216
4.032422
0.039257
1.219349
1.647529
1.972793
0.824895
0.794472
0.751184
0.720414
0.669477
0.629841
0
0.26081
0.020845
29,216
380
81
76.884211
0.543503
0.0408
0
0.334286
0
0
0
0
0
0
0.787625
0
0
1
0
false
0
0
0
0
0
0
0
0
null
1
1
1
1
1
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
10
b380fa68848ab015f5370372d4fb624320582746
516
py
Python
py/examples/d_2d/image.py
heyfaraday/rustcmb
307e65c496db066c1e8a63d68b6feb585349de18
[ "MIT" ]
4
2019-10-23T16:05:31.000Z
2022-02-19T22:57:58.000Z
py/examples/d_2d/image.py
heyfaraday/rustcmb
307e65c496db066c1e8a63d68b6feb585349de18
[ "MIT" ]
3
2017-10-18T20:49:50.000Z
2018-02-25T21:39:51.000Z
py/examples/d_2d/image.py
heyfaraday/rustcmb
307e65c496db066c1e8a63d68b6feb585349de18
[ "MIT" ]
2
2019-10-23T16:05:34.000Z
2022-02-13T04:27:24.000Z
from numpy import * from pylab import * size = 8 plt.figure(figsize=(8, 8)) x, y, z = genfromtxt("../../../../data/out/rust-examples/d_2d/field.dat").T x = x.reshape(size + 1, size + 1) y = y.reshape(size + 1, size + 1) z = z.reshape(size + 1, size + 1) pcolor(x, y, z) show() plt.figure(figsize=(8, 8)) x, y, z = genfromtxt("../../../../data/out/rust-examples/d_2d/field_laplace.dat").T x = x.reshape(size + 1, size + 1) y = y.reshape(size + 1, size + 1) z = z.reshape(size + 1, size + 1) pcolor(x, y, z) show()
24.571429
83
0.598837
97
516
3.154639
0.278351
0.196078
0.235294
0.313725
0.862745
0.862745
0.862745
0.862745
0.862745
0.862745
0
0.043981
0.162791
516
20
84
25.8
0.664352
0
0
0.705882
0
0
0.205426
0.205426
0
0
0
0
0
1
0
false
0
0.117647
0
0.117647
0
0
0
0
null
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
9
b39562a2a1514a9a322ae5f74b1697ac87fb0d3f
6,857
py
Python
asap/priors.py
dr-guangtou/asap
4b796b9708ee1a1d854d4ddf6d5c6e811941f55e
[ "Unlicense" ]
2
2018-11-06T06:50:35.000Z
2018-11-06T14:24:05.000Z
asap/priors.py
dr-guangtou/asap
4b796b9708ee1a1d854d4ddf6d5c6e811941f55e
[ "Unlicense" ]
1
2018-11-02T17:55:32.000Z
2018-11-02T17:55:32.000Z
asap/priors.py
dr-guangtou/asap
4b796b9708ee1a1d854d4ddf6d5c6e811941f55e
[ "Unlicense" ]
null
null
null
"""Module contains different types of priors.""" from __future__ import print_function, division, unicode_literals import numpy as np from scipy.stats import t from scipy.stats import uniform __all__ = ['StudentT', 'TopHat'] class TopHat(object): """TopHat prior object. Based on the `prior` from `prospector`: https://github.com/bd-j/prospector/blob/master/prospect/models/priors.py """ def __init__(self, low=0.0, upp=1.0): """Constructor. Parameters ---------- low : float Lower limit of the flat distribution. upp : float Upper limit of the flat distribution. """ self.distr = uniform self._low = low self._upp = upp def get_mean(self): """Get the mean value of the distribution. Can be used as initial values.""" return self.distr.mean(loc=self.loc, scale=self.scale) def lnp(self, x): """Compute the value of the probability desnity function at x and return the ln of that. Parameters ---------- x : float or numpy array Parameter values. Return ------ lnp : float or numpy array The natural log of the prior probability at x """ return self.distr.logpdf(x, loc=self.loc, scale=self.scale) def unit_transform(self, x): """Go from a value of the CDF (between 0 and 1) to the corresponding parameter value. Parameters ---------- x : float or numpy array. Values of the CDF (between 0 and 1). Return ------ The parameter value corresponding to the value of the CDF given by `unit_arr`. """ return self.distr.ppf(x, loc=self.loc, scale=self.scale) def inverse_unit_transform(self, x): """Go from the parameter value to the unit coordinate using the cdf. Parameters ---------- x : float or numpy array. Values of the CDF (between 0 and 1). Return ------ The corresponding value in unit coordinate. """ return self.distr.cdf(x, loc=self.loc, scale=self.scale) def sample(self, nsample): """Sample the distribution. Parameter --------- nsample : int Number of samples to return. Return ------ sample : arr `nsample` values that follow the distribution. """ return self.distr.rvs(loc=self.loc, scale=self.scale, size=nsample) @property def low(self): """Lower limit of the distribution.""" return self._low @property def upp(self): """Upper limit of the distribution.""" return self._upp @property def scale(self): """The `scale` parameter of the distribution.""" return self._upp - self._low @property def loc(self): """The `loc` parameter of the distribution.""" return self._low @property def range(self): """The range of the distribution.""" return (self._low, self._upp) class StudentT(object): """Student-t prior object. Based on the `prior` from `prospector`: https://github.com/bd-j/prospector/blob/master/prospect/models/priors.py """ def __init__(self, loc=0.0, scale=1.0, df=1): """Constructor. Parameters ---------- loc : float, optional Mean of the distribution. Default: 0.0 scale : float, optional Scale of the flat distribution. Default: 1.0 df : int, optional Degree of freedom. Default: 1 """ self.distr = t self._loc = loc self._scale = scale self._df = df def get_mean(self): """Get the mean value of the distribution. Can be used as initial values.""" return self.distr.mean(loc=self.loc, scale=self.scale, df=self.df) def lnp(self, x): """Compute the value of the probability desnity function at x and return the ln of that. Parameters ---------- x : float or numpy array Parameter values. Return ------ lnp : float or numpy array The natural log of the prior probability at x """ return self.distr.logpdf(x, loc=self.loc, scale=self.scale, df=self.df) def unit_transform(self, x): """Go from a value of the CDF (between 0 and 1) to the corresponding parameter value. Parameters ---------- x : float or numpy array. Values of the CDF (between 0 and 1). Return ------ The parameter value corresponding to the value of the CDF given by `unit_arr`. """ return self.distr.ppf(x, loc=self.loc, scale=self.scale, df=self.df) def inverse_unit_transform(self, x): """Go from the parameter value to the unit coordinate using the cdf. Parameters ---------- x : float or numpy array. Values of the CDF (between 0 and 1). Return ------ The corresponding value in unit coordinate. """ return self.distr.cdf(x, loc=self.loc, scale=self.scale, df=self.df) def sample(self, nsample, limit=True): """Sample the distribution. Parameter --------- nsample : int Number of samples to return. limit : bool, optional Whether to limit the random variables within the range. Return ------ sample : arr `nsample` values that follow the distribution. """ if not limit: return self.distr.rvs( loc=self.loc, scale=self.scale, df=self.df, size=nsample) else: sample = [] while len(sample) < nsample: rv = self.distr.rvs(df=self.df, loc=self.loc, scale=self.scale) if self.low < rv <= self.upp: sample.append(rv) return np.asarray(sample) @property def scale(self): """The `scale` parameter of the distribution.""" return self._scale @property def loc(self): """The `loc` parameter of the distribution.""" return self._loc @property def df(self): """The `df` parameter of the distribution.""" return self._df @property def low(self): """Lower limit of the distribution.""" return self.loc - 4.0 * self.scale @property def upp(self): """Upper limit of the distribution.""" return self.loc + 4.0 * self.scale @property def range(self): """The range of the distribution.""" return (self.low, self.upp)
26.577519
90
0.55622
841
6,857
4.483948
0.154578
0.038451
0.063113
0.079554
0.786794
0.773005
0.754707
0.754707
0.75232
0.72209
0
0.006556
0.332653
6,857
257
91
26.680934
0.817526
0.457489
0
0.397436
0
0
0.004956
0
0
0
0
0
0
1
0.294872
false
0
0.051282
0
0.653846
0.012821
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
1
0
0
0
0
1
0
0
7
b3a598ef8589cd400df46afe77c831146cd07e60
9,192
py
Python
jhdf/src/test/resources/scripts/chunked_v4_datasets.py
raedma/jhdf
4a8aebc6ff925592bfc541da2d7b7078aac17d37
[ "MIT" ]
null
null
null
jhdf/src/test/resources/scripts/chunked_v4_datasets.py
raedma/jhdf
4a8aebc6ff925592bfc541da2d7b7078aac17d37
[ "MIT" ]
null
null
null
jhdf/src/test/resources/scripts/chunked_v4_datasets.py
raedma/jhdf
4a8aebc6ff925592bfc541da2d7b7078aac17d37
[ "MIT" ]
null
null
null
# ------------------------------------------------------------------------------- # This file is part of jHDF. A pure Java library for accessing HDF5 files. # # http://jhdf.io # # Copyright (c) 2022 James Mudd # # MIT License see 'LICENSE' file # ------------------------------------------------------------------------------- import h5py import numpy as np def write_chunked_datasets(f): data = np.arange(15).reshape(5, 3) string_data = data.astype(bytes) large_data = np.arange(10000).reshape(200, 5, 10) string_dtype = h5py.special_dtype(vlen=bytes) # Single chunk index - The current, maximum, and chunk dimension sizes are all the same. Index type 1 single_chunk_group = f.create_group("single_chunk") single_chunk_group.create_dataset("int8", data=data, dtype='i1', chunks=(5, 3)) single_chunk_group.create_dataset("int16", data=data, dtype='i2', chunks=(5, 3)) single_chunk_group.create_dataset("int32", data=data, dtype='i4', chunks=(5, 3)) single_chunk_group.create_dataset('float32', data=data, dtype='f4', chunks=(5, 3)) single_chunk_group.create_dataset('float64', data=data, dtype='f8', chunks=(5, 3)) single_chunk_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(5, 3)) filtered_single_chunk_group = f.create_group("filtered_single_chunk") filtered_single_chunk_group.create_dataset("int8", data=data, dtype='i1', chunks=(5, 3), compression="gzip") filtered_single_chunk_group.create_dataset("int16", data=data, dtype='i2', chunks=(5, 3), compression="gzip") filtered_single_chunk_group.create_dataset("int32", data=data, dtype='i4', chunks=(5, 3), compression="gzip") filtered_single_chunk_group.create_dataset('float32', data=data, dtype='f4', chunks=(5, 3), compression="gzip") filtered_single_chunk_group.create_dataset('float64', data=data, dtype='f8', chunks=(5, 3), compression="gzip") filtered_single_chunk_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(5, 3)) # Implicit Index - fixed maximum dimension sizes, no filter applied to the dataset, # the timing for the space allocation of the dataset chunks is H5P_ALLOC_TIME_EARLY # TODO... # Fixed Array Index - Fixed maximum dimension sizes. Index type 3 fixed_array_index_group = f.create_group("fixed_array") fixed_array_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3)) fixed_array_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3)) fixed_array_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3)) fixed_array_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3)) fixed_array_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3)) fixed_array_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3)) filtered_fixed_array_index_group = f.create_group("filtered_fixed_array") filtered_fixed_array_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3), compression="gzip") filtered_fixed_array_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3), compression="gzip") filtered_fixed_array_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3), compression="gzip") filtered_fixed_array_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3), compression="gzip") filtered_fixed_array_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3), compression="gzip") filtered_fixed_array_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3), compression="gzip") # Extensible Array Index - Only one dimension of unlimited extent. Index type 4 extensible_array_index_group = f.create_group("extensible_array") extensible_array_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3), maxshape=(None, 3)) # The idea is to choose a chunk size that results in no extensible_array_index_group.create_dataset("int8_alt_chunks", data=data, dtype='i1', chunks=(4, 3), maxshape=(None, 3)) extensible_array_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3), maxshape=(None, 3)) extensible_array_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3), maxshape=(None, 3)) extensible_array_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3), maxshape=(None, 3)) extensible_array_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3), maxshape=(None, 3)) extensible_array_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3), maxshape=(None, 3)) # large data to use secondary blocks smallest chunk size extensible_array_index_group.create_dataset("large_int16", data=large_data, dtype='i2', chunks=(1, 1, 1), maxshape=(None, 5, 10)) extensible_array_index_group = f.create_group("filtered_extensible_array") extensible_array_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3), maxshape=(None, 3), compression="gzip") extensible_array_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3), maxshape=(None, 3), compression="gzip") extensible_array_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3), maxshape=(None, 3), compression="gzip") extensible_array_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3), maxshape=(None, 3), compression="gzip") extensible_array_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3), maxshape=(None, 3), compression="gzip") extensible_array_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3), maxshape=(None, 3), compression="gzip") # large data to use secondary blocks smallest chunk size extensible_array_index_group.create_dataset("large_int16", data=large_data, dtype='i2', chunks=(1, 1, 1), maxshape=(None, 5, 10), compression="gzip") # B Tree V2 Index - More than one dimension of unlimited extent. Index type 5 btree_v2_index_group = f.create_group("btree_v2") btree_v2_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3), maxshape=(None, None)) btree_v2_index_group.create_dataset("large_int16", data=large_data, dtype='i2', chunks=(1, 1, 1), maxshape=(None, None, None)) btree_v2_index_group = f.create_group("filtered_btree_v2") btree_v2_index_group.create_dataset("int8", data=data, dtype='i1', chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset("int16", data=data, dtype='i2', chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset("int32", data=data, dtype='i4', chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset('float32', data=data, dtype='f4', chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset('float64', data=data, dtype='f8', chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset('string', data=string_data, dtype=string_dtype, chunks=(2, 3), maxshape=(None, None), compression="gzip") btree_v2_index_group.create_dataset("large_int16", data=large_data, dtype='i2', chunks=(1, 1, 1), maxshape=(None, None, None), compression="gzip") f.flush() f.close() if __name__ == '__main__': print('Making chunked v4 dataset test files...') f = h5py.File('chunked_v4_datasets.hdf5', 'w', libver='latest') write_chunked_datasets(f) print('created chunked_v4_datasets.hdf5')
70.167939
120
0.649913
1,200
9,192
4.724167
0.1125
0.10284
0.168284
0.166343
0.859234
0.841595
0.82272
0.763098
0.760452
0.760452
0
0.04161
0.197346
9,192
130
121
70.707692
0.726755
0.104656
0
0.221053
0
0
0.092692
0.011449
0
0
0
0.007692
0
1
0.010526
false
0
0.021053
0
0.031579
0.021053
0
0
0
null
0
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
3775c0c219ee451dbeabe565b3e48ec12b1c6ae0
27,258
py
Python
tests/unit/test_str_numeric_op.py
ogarraux/jsnapy
801babf77cc2cb05a9a4843e1740d0d6eff8939d
[ "Apache-2.0" ]
null
null
null
tests/unit/test_str_numeric_op.py
ogarraux/jsnapy
801babf77cc2cb05a9a4843e1740d0d6eff8939d
[ "Apache-2.0" ]
1
2018-03-19T08:52:21.000Z
2018-03-19T08:52:21.000Z
tests/unit/test_str_numeric_op.py
ogarraux/jsnapy
801babf77cc2cb05a9a4843e1740d0d6eff8939d
[ "Apache-2.0" ]
null
null
null
import unittest import yaml from jnpr.jsnapy.check import Comparator from mock import patch import os from nose.plugins.attrib import attr @attr('unit') class TestStrNumericOperators(unittest.TestCase): def setUp(self): self.diff = False self.hostname = "1.1.1.1" self.db = dict() self.db['store_in_sqlite'] = False self.db['check_from_sqlite'] = False self.db['db_name'] = "" self.snap_del = False self.action = None @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_equal_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-equal-fail.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-equal-fail_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-fail.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-fail_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_success(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-success.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_ignore_null_1(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-ignore-null_1.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_ignore_null_2(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-ignore-null_2.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_ignore_null_3(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-ignore-null_3.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre") self.assertEqual(oper.no_passed, 0) #comparison between None values. All values are None. self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_ignore_null_4(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-ignore-null_4.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_all_same_ignore_null_pass(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_all-same-ignore-null_pass.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_all-same-success_pre_ignore_null") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 2) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_success(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal-item.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal-item_pre") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_fail_ignore_null_1(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_1.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_fail_ignore_null_2(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_2.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_fail_ignore_null_3(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_3.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_fail_ignore_null_4(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_4.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_success_ignore_null_1(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_5.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre_special") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_is_equal_success_ignore_null_2(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_is-equal_ignore-null_6.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre_special") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_pre") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_fail_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_ignore_null_1(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal_ignore-null_1.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_ignore_null_2(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal_ignore-null_2.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_ignore_null_3(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal_ignore-null_3.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_ignore_null_4(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal_ignore-null_4.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-equal_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_equal_ignore_null_5(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-equal_ignore-null_5.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_is-equal_pre_special") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_exists_pass(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-exists.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-exists_pre") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_exists_ignore_null_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-exists_ignore-null_fail.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-exists_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_exists_ignore_null_skip(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-exists_ignore-null.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) # print main_file oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-exists_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_not_exists_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_not-exists_fail.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_not-exists_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_exists(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_exists.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_exists_pre") self.assertEqual(oper.no_passed, 1) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_exists_ignore_null_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_exists_ignore-null_fail.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_exists_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_exists_ignore_null_skip(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_exists_ignore-null_skip.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_exists_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 0) @patch('logging.Logger.debug') @patch('logging.Logger.info') @patch('jnpr.jsnapy.check.get_path') def test_exists_fail(self, mock_path, mock_debug, mock_info): self.chk = False comp = Comparator() conf_file = os.path.join(os.path.dirname(__file__), 'configs', 'main_exists.yml') mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs') config_file = open(conf_file, 'r') main_file = yaml.load(config_file) oper = comp.generate_test_files( main_file, self.hostname, self.chk, self.diff, self.db, self.snap_del, "snap_exists_fail_pre") self.assertEqual(oper.no_passed, 0) self.assertEqual(oper.no_failed, 1) if __name__ == "__main__": suite = unittest.TestLoader().loadTestsFromTestCase( TestStrNumericOperators) unittest.TextTestRunner(verbosity=2).run(suite)
38.230014
100
0.589588
3,399
27,258
4.416593
0.028832
0.04956
0.074341
0.04956
0.965561
0.965228
0.965228
0.965228
0.965228
0.965228
0
0.005023
0.291584
27,258
712
101
38.283708
0.772398
0.002605
0
0.872024
0
0
0.148759
0.069671
0
0
0
0
0.092262
1
0.047619
false
0.050595
0.008929
0
0.058036
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
8
379db272c1836e0c79b3ecbe84e55d961495b13b
742
py
Python
src/bgapi/dfu/rsp.py
GetAmbush/python-bgapi
985e5849275eb5e7cf794c30ef87e16ffa91fa63
[ "MIT" ]
5
2018-05-11T14:59:50.000Z
2021-04-29T07:51:43.000Z
src/bgapi/dfu/rsp.py
GetAmbush/python-bgapi
985e5849275eb5e7cf794c30ef87e16ffa91fa63
[ "MIT" ]
null
null
null
src/bgapi/dfu/rsp.py
GetAmbush/python-bgapi
985e5849275eb5e7cf794c30ef87e16ffa91fa63
[ "MIT" ]
2
2018-10-05T16:51:08.000Z
2020-08-10T18:24:16.000Z
from struct import (unpack_from, calcsize) def flash_set_address(data: bytes, offset: int = 0): FORMAT = '<H' result, = unpack_from(FORMAT, data, offset=offset) offset += calcsize(FORMAT) payload = { 'result': result, } return payload, offset def flash_upload(data: bytes, offset: int = 0): FORMAT = '<H' result, = unpack_from(FORMAT, data, offset=offset) offset += calcsize(FORMAT) payload = { 'result': result, } return payload, offset def flash_upload_finish(data: bytes, offset: int = 0): FORMAT = '<H' result, = unpack_from(FORMAT, data, offset=offset) offset += calcsize(FORMAT) payload = { 'result': result, } return payload, offset
23.1875
54
0.621294
86
742
5.255814
0.244186
0.159292
0.099558
0.119469
0.871681
0.871681
0.871681
0.871681
0.871681
0.871681
0
0.005415
0.253369
742
31
55
23.935484
0.810469
0
0
0.72
0
0
0.032345
0
0
0
0
0
0
1
0.12
false
0
0.04
0
0.28
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
37ccd02ddc2f2e185efbdfd574521b4cf864289e
3,939
py
Python
test_bing.py
mingming1205/open_automation_quiz
bea6c4b775a61a71c118f82f963bf12f97f2406c
[ "MIT" ]
null
null
null
test_bing.py
mingming1205/open_automation_quiz
bea6c4b775a61a71c118f82f963bf12f97f2406c
[ "MIT" ]
null
null
null
test_bing.py
mingming1205/open_automation_quiz
bea6c4b775a61a71c118f82f963bf12f97f2406c
[ "MIT" ]
null
null
null
#! /usr/bin/env python #-*- coding:utf-8 -*- #created by zc on Sep9th,2020 import os import time import pytest from selenium import webdriver from selenium.webdriver.support.select import Select from selenium.webdriver import ActionChains from HTMLTestRunner import HTMLTestRunner def test_searchbing(driver): searchtext = "Bing" driver.find_element_by_name('q').clear() driver.find_element_by_name('q').send_keys(searchtext) driver.find_element_by_id('sb_form_go').click() driver.implicitly_wait(20) wide = driver.get_window_size()['width'] heighth = driver.get_window_size()['height'] print(wide, heighth) js = "window.scrollTo(1161,633);" driver.execute_script(js) time.sleep(3) driver.find_elements_by_xpath("//*[@aria-label='第 2 页']").click() driver.implicitly_wait(5) results = dr.find_elements_by_xpath("//*[@target='_blank']") links = dr.find_elements_by_class_name('b_attribution') for r,l in results,links: print(r.text,"-->",l.text) driver.refresh() time.sleep(3) def test_countbing(driver): searchtext = "Bing" driver.find_element_by_name('q').clear() driver.find_element_by_name('q').send_keys(searchtext) driver.find_element_by_id('sb_form_go').click() driver.implicitly_wait(20) wide = driver.get_window_size()['width'] heighth = driver.get_window_size()['height'] print(wide, heighth) js = "window.scrollTo(1161,633);" driver.execute_script(js) time.sleep(3) driver.find_elements_by_xpath("//*[@aria-label='第 2 页']").click() driver.implicitly_wait(5) try: domain = driver.find_elements_by_xpath("//div/cite/strong") list = domain.text domainset = set(list) for d in domainset: print("%d --> %d" %(d,list.count(d))) except Exception as e: print("not found.") driver.refresh() time.sleep(3) def test_searchsc(driver): searchtext = "Bing" driver.find_element_by_name('q').clear() driver.find_element_by_name('q').send_keys(searchtext) driver.find_element_by_id('sb_form_go').click() driver.implicitly_wait(20) wide = driver.get_window_size()['width'] heighth = driver.get_window_size()['height'] print(wide, heighth) js = "window.scrollTo(1161,633);" driver.execute_script(js) time.sleep(3) driver.find_elements_by_xpath("//*[@aria-label='第 2 页']").click() driver.implicitly_wait(5) results = dr.find_elements_by_xpath("//*[@target='_blank']") links = dr.find_elements_by_class_name('b_attribution') for r,l in results,links: print(r.text,"-->",l.text) driver.refresh() time.sleep(3) def test_countsc(driver): searchtext = "SC" driver.find_element_by_name('q').clear() driver.find_element_by_name('q').send_keys(searchtext) driver.find_element_by_id('sb_form_go').click() driver.implicitly_wait(20) wide = driver.get_window_size()['width'] heighth = driver.get_window_size()['height'] print(wide, heighth) js = "window.scrollTo(1161,633);" driver.execute_script(js) time.sleep(3) driver.find_elements_by_xpath("//*[@aria-label='第 2 页']").click() driver.implicitly_wait(5) try: domain = driver.find_elements_by_xpath("//div/cite/strong") list = domain.text domainset = set(list) for d in domainset: print("%d --> %d" %(d,list.count(d))) except Exception as e: print("not found.") driver.refresh() time.sleep(3) if __name__=="__main__": now = time.strftime("%Y%m%d%H%M", time.localtime(time.time())) filename = './testreport/' + now + 'testquizresult.html' pytest.main(["-s", "--html", filename])
31.015748
70
0.631886
516
3,939
4.583333
0.224806
0.07611
0.086258
0.096406
0.830867
0.830867
0.830867
0.827907
0.827907
0.827907
0
0.01885
0.218837
3,939
126
71
31.261905
0.749756
0.017517
0
0.838384
0
0
0.136364
0.039037
0
0
0
0
0
1
0.040404
false
0
0.070707
0
0.111111
0.10101
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
8075f4c1e5a8ec3c0940f7f15ca56f9febdf0251
36,821
py
Python
napalm_yang/models/openconfig/network_instances/network_instance/segment_routing/srlbs/srlb/state/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
64
2016-10-20T15:47:18.000Z
2021-11-11T11:57:32.000Z
napalm_yang/models/openconfig/network_instances/network_instance/segment_routing/srlbs/srlb/state/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
126
2016-10-05T10:36:14.000Z
2019-05-15T08:43:23.000Z
napalm_yang/models/openconfig/network_instances/network_instance/segment_routing/srlbs/srlb/state/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
63
2016-11-07T15:23:08.000Z
2021-09-22T14:41:16.000Z
# -*- coding: utf-8 -*- from operator import attrgetter from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType from pyangbind.lib.yangtypes import RestrictedClassType from pyangbind.lib.yangtypes import TypedListType from pyangbind.lib.yangtypes import YANGBool from pyangbind.lib.yangtypes import YANGListType from pyangbind.lib.yangtypes import YANGDynClass from pyangbind.lib.yangtypes import ReferenceType from pyangbind.lib.base import PybindBase from collections import OrderedDict from decimal import Decimal from bitarray import bitarray import six # PY3 support of some PY2 keywords (needs improved) if six.PY3: import builtins as __builtin__ long = int elif six.PY2: import __builtin__ class state(PybindBase): """ This class was auto-generated by the PythonClass plugin for PYANG from YANG module openconfig-network-instance - based on the path /network-instances/network-instance/segment-routing/srlbs/srlb/state. Each member element of the container is represented as a class variable - with a specific YANG type. YANG Description: Operational state parmeters relating to the SRLB. """ __slots__ = ( "_path_helper", "_extmethods", "__local_id", "__dataplane_type", "__mpls_label_block", "__ipv6_prefix", ) _yang_name = "state" _pybind_generated_by = "container" def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__local_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) self.__dataplane_type = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) self.__mpls_label_block = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) self.__ipv6_prefix = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) load = kwargs.pop("load", None) if args: if len(args) > 1: raise TypeError("cannot create a YANG container with >1 argument") all_attr = True for e in self._pyangbind_elements: if not hasattr(args[0], e): all_attr = False break if not all_attr: raise ValueError("Supplied object did not have the correct attributes") for e in self._pyangbind_elements: nobj = getattr(args[0], e) if nobj._changed() is False: continue setmethod = getattr(self, "_set_%s" % e) if load is None: setmethod(getattr(args[0], e)) else: setmethod(getattr(args[0], e), load=load) def _path(self): if hasattr(self, "_parent"): return self._parent._path() + [self._yang_name] else: return [ "network-instances", "network-instance", "segment-routing", "srlbs", "srlb", "state", ] def _get_local_id(self): """ Getter method for local_id, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/local_id (string) YANG Description: A unique local identifier used for the Segment Routing Local Block. The identifier is used when referencing the SRLB within other contexts. """ return self.__local_id def _set_local_id(self, v, load=False): """ Setter method for local_id, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/local_id (string) If this variable is read-only (config: false) in the source YANG file, then _set_local_id is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_local_id() directly. YANG Description: A unique local identifier used for the Segment Routing Local Block. The identifier is used when referencing the SRLB within other contexts. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """local_id must be of a type compatible with string""", "defined-type": "string", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='string', is_config=False)""", } ) self.__local_id = t if hasattr(self, "_set"): self._set() def _unset_local_id(self): self.__local_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) def _get_dataplane_type(self): """ Getter method for dataplane_type, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/dataplane_type (sr-dataplane-type) YANG Description: The dataplane that is to be used for the Segment Routing Local Block. When MPLS is specified, the local block corresponds to a block of MPLS labels; when IPv6 is specified it corresponds to an IPv6 prefix. """ return self.__dataplane_type def _set_dataplane_type(self, v, load=False): """ Setter method for dataplane_type, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/dataplane_type (sr-dataplane-type) If this variable is read-only (config: false) in the source YANG file, then _set_dataplane_type is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dataplane_type() directly. YANG Description: The dataplane that is to be used for the Segment Routing Local Block. When MPLS is specified, the local block corresponds to a block of MPLS labels; when IPv6 is specified it corresponds to an IPv6 prefix. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """dataplane_type must be of a type compatible with sr-dataplane-type""", "defined-type": "openconfig-network-instance:sr-dataplane-type", "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MPLS': {}, 'IPV6': {}},), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='sr-dataplane-type', is_config=False)""", } ) self.__dataplane_type = t if hasattr(self, "_set"): self._set() def _unset_dataplane_type(self): self.__dataplane_type = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) def _get_mpls_label_block(self): """ Getter method for mpls_label_block, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/mpls_label_block (leafref) YANG Description: A reference to the MPLS label block that is used to contain the SIDs of the SRLB. """ return self.__mpls_label_block def _set_mpls_label_block(self, v, load=False): """ Setter method for mpls_label_block, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/mpls_label_block (leafref) If this variable is read-only (config: false) in the source YANG file, then _set_mpls_label_block is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_mpls_label_block() directly. YANG Description: A reference to the MPLS label block that is used to contain the SIDs of the SRLB. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """mpls_label_block must be of a type compatible with leafref""", "defined-type": "leafref", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=False)""", } ) self.__mpls_label_block = t if hasattr(self, "_set"): self._set() def _unset_mpls_label_block(self): self.__mpls_label_block = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) def _get_ipv6_prefix(self): """ Getter method for ipv6_prefix, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/ipv6_prefix (inet:ipv6-prefix) YANG Description: The IPv6 prefix that is used for the SRLB. """ return self.__ipv6_prefix def _set_ipv6_prefix(self, v, load=False): """ Setter method for ipv6_prefix, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/ipv6_prefix (inet:ipv6-prefix) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_prefix is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_ipv6_prefix() directly. YANG Description: The IPv6 prefix that is used for the SRLB. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """ipv6_prefix must be of a type compatible with inet:ipv6-prefix""", "defined-type": "inet:ipv6-prefix", "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='inet:ipv6-prefix', is_config=False)""", } ) self.__ipv6_prefix = t if hasattr(self, "_set"): self._set() def _unset_ipv6_prefix(self): self.__ipv6_prefix = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) local_id = __builtin__.property(_get_local_id) dataplane_type = __builtin__.property(_get_dataplane_type) mpls_label_block = __builtin__.property(_get_mpls_label_block) ipv6_prefix = __builtin__.property(_get_ipv6_prefix) _pyangbind_elements = OrderedDict( [ ("local_id", local_id), ("dataplane_type", dataplane_type), ("mpls_label_block", mpls_label_block), ("ipv6_prefix", ipv6_prefix), ] ) class state(PybindBase): """ This class was auto-generated by the PythonClass plugin for PYANG from YANG module openconfig-network-instance-l2 - based on the path /network-instances/network-instance/segment-routing/srlbs/srlb/state. Each member element of the container is represented as a class variable - with a specific YANG type. YANG Description: Operational state parmeters relating to the SRLB. """ __slots__ = ( "_path_helper", "_extmethods", "__local_id", "__dataplane_type", "__mpls_label_block", "__ipv6_prefix", ) _yang_name = "state" _pybind_generated_by = "container" def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__local_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) self.__dataplane_type = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) self.__mpls_label_block = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) self.__ipv6_prefix = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) load = kwargs.pop("load", None) if args: if len(args) > 1: raise TypeError("cannot create a YANG container with >1 argument") all_attr = True for e in self._pyangbind_elements: if not hasattr(args[0], e): all_attr = False break if not all_attr: raise ValueError("Supplied object did not have the correct attributes") for e in self._pyangbind_elements: nobj = getattr(args[0], e) if nobj._changed() is False: continue setmethod = getattr(self, "_set_%s" % e) if load is None: setmethod(getattr(args[0], e)) else: setmethod(getattr(args[0], e), load=load) def _path(self): if hasattr(self, "_parent"): return self._parent._path() + [self._yang_name] else: return [ "network-instances", "network-instance", "segment-routing", "srlbs", "srlb", "state", ] def _get_local_id(self): """ Getter method for local_id, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/local_id (string) YANG Description: A unique local identifier used for the Segment Routing Local Block. The identifier is used when referencing the SRLB within other contexts. """ return self.__local_id def _set_local_id(self, v, load=False): """ Setter method for local_id, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/local_id (string) If this variable is read-only (config: false) in the source YANG file, then _set_local_id is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_local_id() directly. YANG Description: A unique local identifier used for the Segment Routing Local Block. The identifier is used when referencing the SRLB within other contexts. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """local_id must be of a type compatible with string""", "defined-type": "string", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='string', is_config=False)""", } ) self.__local_id = t if hasattr(self, "_set"): self._set() def _unset_local_id(self): self.__local_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="local-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="string", is_config=False, ) def _get_dataplane_type(self): """ Getter method for dataplane_type, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/dataplane_type (sr-dataplane-type) YANG Description: The dataplane that is to be used for the Segment Routing Local Block. When MPLS is specified, the local block corresponds to a block of MPLS labels; when IPv6 is specified it corresponds to an IPv6 prefix. """ return self.__dataplane_type def _set_dataplane_type(self, v, load=False): """ Setter method for dataplane_type, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/dataplane_type (sr-dataplane-type) If this variable is read-only (config: false) in the source YANG file, then _set_dataplane_type is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dataplane_type() directly. YANG Description: The dataplane that is to be used for the Segment Routing Local Block. When MPLS is specified, the local block corresponds to a block of MPLS labels; when IPv6 is specified it corresponds to an IPv6 prefix. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """dataplane_type must be of a type compatible with sr-dataplane-type""", "defined-type": "openconfig-network-instance:sr-dataplane-type", "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MPLS': {}, 'IPV6': {}},), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='sr-dataplane-type', is_config=False)""", } ) self.__dataplane_type = t if hasattr(self, "_set"): self._set() def _unset_dataplane_type(self): self.__dataplane_type = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_type="dict_key", restriction_arg={"MPLS": {}, "IPV6": {}}, ), is_leaf=True, yang_name="dataplane-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="sr-dataplane-type", is_config=False, ) def _get_mpls_label_block(self): """ Getter method for mpls_label_block, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/mpls_label_block (leafref) YANG Description: A reference to the MPLS label block that is used to contain the SIDs of the SRLB. """ return self.__mpls_label_block def _set_mpls_label_block(self, v, load=False): """ Setter method for mpls_label_block, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/mpls_label_block (leafref) If this variable is read-only (config: false) in the source YANG file, then _set_mpls_label_block is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_mpls_label_block() directly. YANG Description: A reference to the MPLS label block that is used to contain the SIDs of the SRLB. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """mpls_label_block must be of a type compatible with leafref""", "defined-type": "leafref", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=False)""", } ) self.__mpls_label_block = t if hasattr(self, "_set"): self._set() def _unset_mpls_label_block(self): self.__mpls_label_block = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="mpls-label-block", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=False, ) def _get_ipv6_prefix(self): """ Getter method for ipv6_prefix, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/ipv6_prefix (inet:ipv6-prefix) YANG Description: The IPv6 prefix that is used for the SRLB. """ return self.__ipv6_prefix def _set_ipv6_prefix(self, v, load=False): """ Setter method for ipv6_prefix, mapped from YANG variable /network_instances/network_instance/segment_routing/srlbs/srlb/state/ipv6_prefix (inet:ipv6-prefix) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_prefix is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_ipv6_prefix() directly. YANG Description: The IPv6 prefix that is used for the SRLB. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) except (TypeError, ValueError): raise ValueError( { "error-string": """ipv6_prefix must be of a type compatible with inet:ipv6-prefix""", "defined-type": "inet:ipv6-prefix", "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='inet:ipv6-prefix', is_config=False)""", } ) self.__ipv6_prefix = t if hasattr(self, "_set"): self._set() def _unset_ipv6_prefix(self): self.__ipv6_prefix = YANGDynClass( base=RestrictedClassType( base_type=six.text_type, restriction_dict={ "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))" }, ), is_leaf=True, yang_name="ipv6-prefix", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="inet:ipv6-prefix", is_config=False, ) local_id = __builtin__.property(_get_local_id) dataplane_type = __builtin__.property(_get_dataplane_type) mpls_label_block = __builtin__.property(_get_mpls_label_block) ipv6_prefix = __builtin__.property(_get_ipv6_prefix) _pyangbind_elements = OrderedDict( [ ("local_id", local_id), ("dataplane_type", dataplane_type), ("mpls_label_block", mpls_label_block), ("ipv6_prefix", ipv6_prefix), ] )
42.864959
651
0.58635
4,348
36,821
4.74471
0.049908
0.063984
0.044789
0.051091
0.981823
0.971304
0.971304
0.971304
0.971304
0.971304
0
0.023195
0.292795
36,821
858
652
42.914918
0.769048
0.206974
0
0.874233
0
0.021472
0.304141
0.14617
0
0
0
0
0
1
0.042945
false
0
0.023006
0
0.111963
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
80f5cff111335fec246dd423b12bdb4caee210c8
200
py
Python
Python cursoemvideo/ex005.py
heldermedeiros/Python-em-video
eff781642f262c22d9b99423e825b57d68ee5a3e
[ "MIT" ]
null
null
null
Python cursoemvideo/ex005.py
heldermedeiros/Python-em-video
eff781642f262c22d9b99423e825b57d68ee5a3e
[ "MIT" ]
null
null
null
Python cursoemvideo/ex005.py
heldermedeiros/Python-em-video
eff781642f262c22d9b99423e825b57d68ee5a3e
[ "MIT" ]
null
null
null
int("1") print(type(1)) soma=1+1 print(soma) print("5+2= ",5+2) print("5-2= ",5-2) print("5*2= ",5*2) print("5**2= ",5**2) print("5/2= ",5/2) print("5//2= ",5//2) print("5%2= ",5%2) print("5+2= ",5+2)
16.666667
20
0.505
50
200
2.02
0.14
0.316832
0.554455
0.633663
0.712871
0.712871
0.712871
0.712871
0.712871
0.712871
0
0.198895
0.095
200
12
21
16.666667
0.359116
0
0
0.166667
0
0
0.21393
0
0
0
0
0
0
1
0
false
0
0
0
0
0.833333
0
0
0
null
1
1
1
0
1
1
1
1
1
0
0
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
10
206ba526f89245d8255cc197e861d7b4b307b8ac
52,310
py
Python
napalm_yang/models/openconfig/network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
64
2016-10-20T15:47:18.000Z
2021-11-11T11:57:32.000Z
napalm_yang/models/openconfig/network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
126
2016-10-05T10:36:14.000Z
2019-05-15T08:43:23.000Z
napalm_yang/models/openconfig/network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/__init__.py
ckishimo/napalm-yang
8f2bd907bd3afcde3c2f8e985192de74748baf6c
[ "Apache-2.0" ]
63
2016-11-07T15:23:08.000Z
2021-09-22T14:41:16.000Z
# -*- coding: utf-8 -*- from operator import attrgetter from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType from pyangbind.lib.yangtypes import RestrictedClassType from pyangbind.lib.yangtypes import TypedListType from pyangbind.lib.yangtypes import YANGBool from pyangbind.lib.yangtypes import YANGListType from pyangbind.lib.yangtypes import YANGDynClass from pyangbind.lib.yangtypes import ReferenceType from pyangbind.lib.base import PybindBase from collections import OrderedDict from decimal import Decimal from bitarray import bitarray import six # PY3 support of some PY2 keywords (needs improved) if six.PY3: import builtins as __builtin__ long = int elif six.PY2: import __builtin__ from . import config from . import state from . import l2 from . import ip from . import transport from . import action class rule(PybindBase): """ This class was auto-generated by the PythonClass plugin for PYANG from YANG module openconfig-network-instance - based on the path /network-instances/network-instance/policy-forwarding/policies/policy/rules/rule. Each member element of the container is represented as a class variable - with a specific YANG type. YANG Description: A match rule for the policy. In the case that multiple criteria are specified within a single """ __slots__ = ( "_path_helper", "_extmethods", "__sequence_id", "__config", "__state", "__l2", "__ip", "__transport", "__action", ) _yang_name = "rule" _pybind_generated_by = "container" def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__sequence_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) self.__config = YANGDynClass( base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__state = YANGDynClass( base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__l2 = YANGDynClass( base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__ip = YANGDynClass( base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__transport = YANGDynClass( base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__action = YANGDynClass( base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) load = kwargs.pop("load", None) if args: if len(args) > 1: raise TypeError("cannot create a YANG container with >1 argument") all_attr = True for e in self._pyangbind_elements: if not hasattr(args[0], e): all_attr = False break if not all_attr: raise ValueError("Supplied object did not have the correct attributes") for e in self._pyangbind_elements: nobj = getattr(args[0], e) if nobj._changed() is False: continue setmethod = getattr(self, "_set_%s" % e) if load is None: setmethod(getattr(args[0], e)) else: setmethod(getattr(args[0], e), load=load) def _path(self): if hasattr(self, "_parent"): return self._parent._path() + [self._yang_name] else: return [ "network-instances", "network-instance", "policy-forwarding", "policies", "policy", "rules", "rule", ] def _get_sequence_id(self): """ Getter method for sequence_id, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/sequence_id (leafref) YANG Description: A unique sequence identifier for the match rule. """ return self.__sequence_id def _set_sequence_id(self, v, load=False): """ Setter method for sequence_id, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/sequence_id (leafref) If this variable is read-only (config: false) in the source YANG file, then _set_sequence_id is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_sequence_id() directly. YANG Description: A unique sequence identifier for the match rule. """ parent = getattr(self, "_parent", None) if parent is not None and load is False: raise AttributeError( "Cannot set keys directly when" + " within an instantiated list" ) if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """sequence_id must be of a type compatible with leafref""", "defined-type": "leafref", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=True)""", } ) self.__sequence_id = t if hasattr(self, "_set"): self._set() def _unset_sequence_id(self): self.__sequence_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) def _get_config(self): """ Getter method for config, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/config (container) YANG Description: Configuration parameters relating to the match rule. """ return self.__config def _set_config(self, v, load=False): """ Setter method for config, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/config (container) If this variable is read-only (config: false) in the source YANG file, then _set_config is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_config() directly. YANG Description: Configuration parameters relating to the match rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """config must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__config = t if hasattr(self, "_set"): self._set() def _unset_config(self): self.__config = YANGDynClass( base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_state(self): """ Getter method for state, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/state (container) YANG Description: Operational state parameters relating to the match rule. """ return self.__state def _set_state(self, v, load=False): """ Setter method for state, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/state (container) If this variable is read-only (config: false) in the source YANG file, then _set_state is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_state() directly. YANG Description: Operational state parameters relating to the match rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """state must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__state = t if hasattr(self, "_set"): self._set() def _unset_state(self): self.__state = YANGDynClass( base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_l2(self): """ Getter method for l2, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/l2 (container) YANG Description: Ethernet header fields """ return self.__l2 def _set_l2(self, v, load=False): """ Setter method for l2, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/l2 (container) If this variable is read-only (config: false) in the source YANG file, then _set_l2 is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_l2() directly. YANG Description: Ethernet header fields """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """l2 must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=l2.l2, is_container='container', yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__l2 = t if hasattr(self, "_set"): self._set() def _unset_l2(self): self.__l2 = YANGDynClass( base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_ip(self): """ Getter method for ip, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/ip (container) YANG Description: Top level container """ return self.__ip def _set_ip(self, v, load=False): """ Setter method for ip, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/ip (container) If this variable is read-only (config: false) in the source YANG file, then _set_ip is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_ip() directly. YANG Description: Top level container """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """ip must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=ip.ip, is_container='container', yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__ip = t if hasattr(self, "_set"): self._set() def _unset_ip(self): self.__ip = YANGDynClass( base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_transport(self): """ Getter method for transport, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/transport (container) YANG Description: Transport fields container """ return self.__transport def _set_transport(self, v, load=False): """ Setter method for transport, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/transport (container) If this variable is read-only (config: false) in the source YANG file, then _set_transport is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_transport() directly. YANG Description: Transport fields container """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """transport must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=transport.transport, is_container='container', yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__transport = t if hasattr(self, "_set"): self._set() def _unset_transport(self): self.__transport = YANGDynClass( base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_action(self): """ Getter method for action, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/action (container) YANG Description: The forwarding policy action to be applied for packets matching the rule. """ return self.__action def _set_action(self, v, load=False): """ Setter method for action, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/action (container) If this variable is read-only (config: false) in the source YANG file, then _set_action is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_action() directly. YANG Description: The forwarding policy action to be applied for packets matching the rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """action must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=action.action, is_container='container', yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__action = t if hasattr(self, "_set"): self._set() def _unset_action(self): self.__action = YANGDynClass( base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) sequence_id = __builtin__.property(_get_sequence_id, _set_sequence_id) config = __builtin__.property(_get_config, _set_config) state = __builtin__.property(_get_state, _set_state) l2 = __builtin__.property(_get_l2, _set_l2) ip = __builtin__.property(_get_ip, _set_ip) transport = __builtin__.property(_get_transport, _set_transport) action = __builtin__.property(_get_action, _set_action) _pyangbind_elements = OrderedDict( [ ("sequence_id", sequence_id), ("config", config), ("state", state), ("l2", l2), ("ip", ip), ("transport", transport), ("action", action), ] ) from . import config from . import state from . import l2 from . import ip from . import transport from . import action class rule(PybindBase): """ This class was auto-generated by the PythonClass plugin for PYANG from YANG module openconfig-network-instance-l2 - based on the path /network-instances/network-instance/policy-forwarding/policies/policy/rules/rule. Each member element of the container is represented as a class variable - with a specific YANG type. YANG Description: A match rule for the policy. In the case that multiple criteria are specified within a single """ __slots__ = ( "_path_helper", "_extmethods", "__sequence_id", "__config", "__state", "__l2", "__ip", "__transport", "__action", ) _yang_name = "rule" _pybind_generated_by = "container" def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__sequence_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) self.__config = YANGDynClass( base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__state = YANGDynClass( base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__l2 = YANGDynClass( base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__ip = YANGDynClass( base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__transport = YANGDynClass( base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) self.__action = YANGDynClass( base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) load = kwargs.pop("load", None) if args: if len(args) > 1: raise TypeError("cannot create a YANG container with >1 argument") all_attr = True for e in self._pyangbind_elements: if not hasattr(args[0], e): all_attr = False break if not all_attr: raise ValueError("Supplied object did not have the correct attributes") for e in self._pyangbind_elements: nobj = getattr(args[0], e) if nobj._changed() is False: continue setmethod = getattr(self, "_set_%s" % e) if load is None: setmethod(getattr(args[0], e)) else: setmethod(getattr(args[0], e), load=load) def _path(self): if hasattr(self, "_parent"): return self._parent._path() + [self._yang_name] else: return [ "network-instances", "network-instance", "policy-forwarding", "policies", "policy", "rules", "rule", ] def _get_sequence_id(self): """ Getter method for sequence_id, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/sequence_id (leafref) YANG Description: A unique sequence identifier for the match rule. """ return self.__sequence_id def _set_sequence_id(self, v, load=False): """ Setter method for sequence_id, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/sequence_id (leafref) If this variable is read-only (config: false) in the source YANG file, then _set_sequence_id is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_sequence_id() directly. YANG Description: A unique sequence identifier for the match rule. """ parent = getattr(self, "_parent", None) if parent is not None and load is False: raise AttributeError( "Cannot set keys directly when" + " within an instantiated list" ) if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """sequence_id must be of a type compatible with leafref""", "defined-type": "leafref", "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=True)""", } ) self.__sequence_id = t if hasattr(self, "_set"): self._set() def _unset_sequence_id(self): self.__sequence_id = YANGDynClass( base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="leafref", is_config=True, ) def _get_config(self): """ Getter method for config, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/config (container) YANG Description: Configuration parameters relating to the match rule. """ return self.__config def _set_config(self, v, load=False): """ Setter method for config, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/config (container) If this variable is read-only (config: false) in the source YANG file, then _set_config is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_config() directly. YANG Description: Configuration parameters relating to the match rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """config must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__config = t if hasattr(self, "_set"): self._set() def _unset_config(self): self.__config = YANGDynClass( base=config.config, is_container="container", yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_state(self): """ Getter method for state, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/state (container) YANG Description: Operational state parameters relating to the match rule. """ return self.__state def _set_state(self, v, load=False): """ Setter method for state, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/state (container) If this variable is read-only (config: false) in the source YANG file, then _set_state is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_state() directly. YANG Description: Operational state parameters relating to the match rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """state must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__state = t if hasattr(self, "_set"): self._set() def _unset_state(self): self.__state = YANGDynClass( base=state.state, is_container="container", yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_l2(self): """ Getter method for l2, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/l2 (container) YANG Description: Ethernet header fields """ return self.__l2 def _set_l2(self, v, load=False): """ Setter method for l2, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/l2 (container) If this variable is read-only (config: false) in the source YANG file, then _set_l2 is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_l2() directly. YANG Description: Ethernet header fields """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """l2 must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=l2.l2, is_container='container', yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__l2 = t if hasattr(self, "_set"): self._set() def _unset_l2(self): self.__l2 = YANGDynClass( base=l2.l2, is_container="container", yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_ip(self): """ Getter method for ip, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/ip (container) YANG Description: Top level container """ return self.__ip def _set_ip(self, v, load=False): """ Setter method for ip, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/ip (container) If this variable is read-only (config: false) in the source YANG file, then _set_ip is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_ip() directly. YANG Description: Top level container """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """ip must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=ip.ip, is_container='container', yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__ip = t if hasattr(self, "_set"): self._set() def _unset_ip(self): self.__ip = YANGDynClass( base=ip.ip, is_container="container", yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_transport(self): """ Getter method for transport, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/transport (container) YANG Description: Transport fields container """ return self.__transport def _set_transport(self, v, load=False): """ Setter method for transport, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/transport (container) If this variable is read-only (config: false) in the source YANG file, then _set_transport is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_transport() directly. YANG Description: Transport fields container """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """transport must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=transport.transport, is_container='container', yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__transport = t if hasattr(self, "_set"): self._set() def _unset_transport(self): self.__transport = YANGDynClass( base=transport.transport, is_container="container", yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) def _get_action(self): """ Getter method for action, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/action (container) YANG Description: The forwarding policy action to be applied for packets matching the rule. """ return self.__action def _set_action(self, v, load=False): """ Setter method for action, mapped from YANG variable /network_instances/network_instance/policy_forwarding/policies/policy/rules/rule/action (container) If this variable is read-only (config: false) in the source YANG file, then _set_action is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_action() directly. YANG Description: The forwarding policy action to be applied for packets matching the rule. """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass( v, base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) except (TypeError, ValueError): raise ValueError( { "error-string": """action must be of a type compatible with container""", "defined-type": "container", "generated-type": """YANGDynClass(base=action.action, is_container='container', yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=True)""", } ) self.__action = t if hasattr(self, "_set"): self._set() def _unset_action(self): self.__action = YANGDynClass( base=action.action, is_container="container", yang_name="action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace="http://openconfig.net/yang/network-instance", defining_module="openconfig-network-instance", yang_type="container", is_config=True, ) sequence_id = __builtin__.property(_get_sequence_id, _set_sequence_id) config = __builtin__.property(_get_config, _set_config) state = __builtin__.property(_get_state, _set_state) l2 = __builtin__.property(_get_l2, _set_l2) ip = __builtin__.property(_get_ip, _set_ip) transport = __builtin__.property(_get_transport, _set_transport) action = __builtin__.property(_get_action, _set_action) _pyangbind_elements = OrderedDict( [ ("sequence_id", sequence_id), ("config", config), ("state", state), ("l2", l2), ("ip", ip), ("transport", transport), ("action", action), ] )
38.921131
386
0.594418
5,414
52,310
5.5157
0.038604
0.073337
0.053446
0.06021
0.987442
0.980175
0.980175
0.980175
0.980175
0.980175
0
0.002325
0.309272
52,310
1,343
387
38.950112
0.824145
0.197075
0
0.88932
0
0.013592
0.258576
0.088474
0
0
0
0
0
1
0.04466
false
0
0.026214
0
0.11165
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
2097391972054eac44f85f1274d471b62c4f974a
83
py
Python
release/scripts/presets/framerate/25.py
rbabari/blender
6daa85f14b2974abfc3d0f654c5547f487bb3b74
[ "Naumen", "Condor-1.1", "MS-PL" ]
365
2015-02-10T15:10:55.000Z
2022-03-03T15:50:51.000Z
release/scripts/presets/framerate/25.py
rbabari/blender
6daa85f14b2974abfc3d0f654c5547f487bb3b74
[ "Naumen", "Condor-1.1", "MS-PL" ]
45
2015-01-09T15:34:20.000Z
2021-10-05T14:44:23.000Z
release/scripts/presets/framerate/25.py
rbabari/blender
6daa85f14b2974abfc3d0f654c5547f487bb3b74
[ "Naumen", "Condor-1.1", "MS-PL" ]
172
2015-01-25T15:16:53.000Z
2022-01-31T08:25:36.000Z
import bpy bpy.context.scene.render.fps = 25 bpy.context.scene.render.fps_base = 1
20.75
37
0.783133
15
83
4.266667
0.6
0.3125
0.46875
0.65625
0.75
0
0
0
0
0
0
0.04
0.096386
83
3
38
27.666667
0.813333
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
7
20a91efce66b98b0e0c04de015861910d9c80361
116
py
Python
python/testData/inspections/PyMethodOverridingInspection/DefaultArgument.py
jnthn/intellij-community
8fa7c8a3ace62400c838e0d5926a7be106aa8557
[ "Apache-2.0" ]
2
2019-04-28T07:48:50.000Z
2020-12-11T14:18:08.000Z
python/testData/inspections/PyMethodOverridingInspection/DefaultArgument.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
173
2018-07-05T13:59:39.000Z
2018-08-09T01:12:03.000Z
python/testData/inspections/PyMethodOverridingInspection/DefaultArgument.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
2
2020-03-15T08:57:37.000Z
2020-04-07T04:48:14.000Z
class B: def foo(self, arg1): pass class C(B): def foo(self, arg1, arg2=None): #pass pass
12.888889
41
0.525862
18
116
3.388889
0.555556
0.131148
0.229508
0.360656
0.491803
0
0
0
0
0
0
0.039474
0.344828
116
8
42
14.5
0.763158
0.034483
0
0.333333
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
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
1
0
1
0
0
1
0
0
7
20ca9c65dbaf784540937c3a8b54d514029daeca
17,444
py
Python
src/tests/tests.py
vtbassmatt/django-expression-fields
5bdf58087126ab0ce913ed84021c8476c2e7d901
[ "MIT" ]
20
2015-10-03T05:26:35.000Z
2021-11-27T19:38:28.000Z
src/tests/tests.py
vtbassmatt/django-expression-fields
5bdf58087126ab0ce913ed84021c8476c2e7d901
[ "MIT" ]
null
null
null
src/tests/tests.py
vtbassmatt/django-expression-fields
5bdf58087126ab0ce913ed84021c8476c2e7d901
[ "MIT" ]
1
2021-11-25T18:43:37.000Z
2021-11-25T18:43:37.000Z
import unittest from decimal import Decimal from django.forms import Form from expression_fields.fields import DivideDecimalField, DecimalExpressionField class DivDecForm(Form): field1 = DivideDecimalField(max_digits=5, decimal_places=2, required=False) field2 = DivideDecimalField(max_digits=4, decimal_places=1) field3 = DivideDecimalField(max_digits=5, decimal_places=0, required=False) class DivideDecimalTests(unittest.TestCase): def test_base_behavior(self): """ Sanity test to make sure we didn't break the base DecimalField. """ form1 = DivDecForm({'field1': '256.32', 'field2': '123.4'}) form2 = DivDecForm({'field1': '256', 'field2': '123'}) form3 = DivDecForm({'field2': '123'}) form4 = DivDecForm({'field1': '123'}) form5 = DivDecForm({'field2': '123', 'field3': '456'}) form6 = DivDecForm({'field2': '123', 'field3': '456.0'}) form7 = DivDecForm({'field1': '', 'field2': '0.0'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('256.32')) self.assertEqual(form1.cleaned_data['field2'], Decimal('123.4')) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('256')) self.assertEqual(form2.cleaned_data['field2'], Decimal('123')) self.assertTrue(form3.is_valid()) self.assertFalse(form4.is_valid()) self.assertTrue(form5.is_valid()) self.assertFalse(form6.is_valid()) self.assertTrue(form7.is_valid()) self.assertEqual(form7.cleaned_data['field1'], None) self.assertEqual(form7.cleaned_data['field2'], Decimal('0')) self.assertEqual(form7.cleaned_data['field3'], None) def test_divide(self): """ Test a few instances of fields with a '/'. """ form1 = DivDecForm({'field1': '1/2', 'field2': '2/1', 'field3': '3/3'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form1.cleaned_data['field2'], Decimal('2')) self.assertEqual(form1.cleaned_data['field3'], Decimal('1')) form2 = DivDecForm({'field1': '1/3', 'field2': '1/3', 'field3': '1/3'}) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('.33')) self.assertEqual(form2.cleaned_data['field2'], Decimal('.3')) self.assertEqual(form2.cleaned_data['field3'], Decimal('0')) form3 = DivDecForm({'field1': '1/4', 'field2': '1/4', 'field3': '1/4'}) self.assertTrue(form3.is_valid()) self.assertEqual(form3.cleaned_data['field1'], Decimal('.25')) self.assertEqual(form3.cleaned_data['field2'], Decimal('.2')) self.assertEqual(form3.cleaned_data['field3'], Decimal('0')) form4 = DivDecForm({'field1': '1/2', 'field2': '1/2', 'field3': '1/2'}) self.assertTrue(form4.is_valid()) self.assertEqual(form4.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field2'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field3'], Decimal('0')) def test_negative_numerators(self): """ Test a few instances of negative numerators. """ formN1 = DivDecForm({'field1': '-1/2', 'field2': '-2/1', 'field3': '-3/3'}) self.assertTrue(formN1.is_valid()) self.assertEqual(formN1.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN1.cleaned_data['field2'], Decimal('-2')) self.assertEqual(formN1.cleaned_data['field3'], Decimal('-1')) formN2 = DivDecForm({'field1': '-1/3', 'field2': '-1/3', 'field3': '-1/3'}) self.assertTrue(formN2.is_valid()) self.assertEqual(formN2.cleaned_data['field1'], Decimal('-.33')) self.assertEqual(formN2.cleaned_data['field2'], Decimal('-.3')) self.assertEqual(formN2.cleaned_data['field3'], Decimal('-0')) formN3 = DivDecForm({'field1': '-1/4', 'field2': '-1/4', 'field3': '-1/4'}) self.assertTrue(formN3.is_valid()) self.assertEqual(formN3.cleaned_data['field1'], Decimal('-.25')) self.assertEqual(formN3.cleaned_data['field2'], Decimal('-.2')) self.assertEqual(formN3.cleaned_data['field3'], Decimal('0')) formN4 = DivDecForm({'field1': '-1/2', 'field2': '-1/2', 'field3': '-1/2'}) self.assertTrue(formN4.is_valid()) self.assertEqual(formN4.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field2'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field3'], Decimal('0')) def test_negative_denominators(self): """ Test a few instances of negative numerators. """ formN1 = DivDecForm({'field1': '1/-2', 'field2': '2/-1', 'field3': '3/-3'}) self.assertTrue(formN1.is_valid()) self.assertEqual(formN1.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN1.cleaned_data['field2'], Decimal('-2')) self.assertEqual(formN1.cleaned_data['field3'], Decimal('-1')) formN2 = DivDecForm({'field1': '1/-3', 'field2': '1/-3', 'field3': '1/-3'}) self.assertTrue(formN2.is_valid()) self.assertEqual(formN2.cleaned_data['field1'], Decimal('-.33')) self.assertEqual(formN2.cleaned_data['field2'], Decimal('-.3')) self.assertEqual(formN2.cleaned_data['field3'], Decimal('-0')) formN3 = DivDecForm({'field1': '1/-4', 'field2': '1/-4', 'field3': '1/-4'}) self.assertTrue(formN3.is_valid()) self.assertEqual(formN3.cleaned_data['field1'], Decimal('-.25')) self.assertEqual(formN3.cleaned_data['field2'], Decimal('-.2')) self.assertEqual(formN3.cleaned_data['field3'], Decimal('0')) formN4 = DivDecForm({'field1': '1/-2', 'field2': '1/-2', 'field3': '1/-2'}) self.assertTrue(formN4.is_valid()) self.assertEqual(formN4.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field2'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field3'], Decimal('0')) def test_divide_negative_by_negative(self): """ Ensure that -/- is positive. """ form1 = DivDecForm({'field1': '-1/-2', 'field2': '-2/-1', 'field3': '-3/-3'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form1.cleaned_data['field2'], Decimal('2')) self.assertEqual(form1.cleaned_data['field3'], Decimal('1')) form2 = DivDecForm({'field1': '-1/-3', 'field2': '-1/-3', 'field3': '-1/-3'}) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('.33')) self.assertEqual(form2.cleaned_data['field2'], Decimal('.3')) self.assertEqual(form2.cleaned_data['field3'], Decimal('0')) form3 = DivDecForm({'field1': '-1/-4', 'field2': '-1/-4', 'field3': '-1/-4'}) self.assertTrue(form3.is_valid()) self.assertEqual(form3.cleaned_data['field1'], Decimal('.25')) self.assertEqual(form3.cleaned_data['field2'], Decimal('.2')) self.assertEqual(form3.cleaned_data['field3'], Decimal('0')) form4 = DivDecForm({'field1': '-1/-2', 'field2': '-1/-2', 'field3': '-1/-2'}) self.assertTrue(form4.is_valid()) self.assertEqual(form4.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field2'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field3'], Decimal('0')) class DecExprForm(Form): field1 = DecimalExpressionField(max_digits=5, decimal_places=2, required=False) field2 = DecimalExpressionField(max_digits=4, decimal_places=1) field3 = DecimalExpressionField(max_digits=5, decimal_places=0, required=False) class DecimalExpressionDivisionTests(unittest.TestCase): """Cloned from DivideDecimalField tests""" def test_base_behavior(self): """ Sanity test to make sure we didn't break the base DecimalField. """ form1 = DecExprForm({'field1': '256.32', 'field2': '123.4'}) form2 = DecExprForm({'field1': '256', 'field2': '123'}) form3 = DecExprForm({'field2': '123'}) form4 = DecExprForm({'field1': '123'}) form5 = DecExprForm({'field2': '123', 'field3': '456'}) form6 = DecExprForm({'field2': '123', 'field3': '456.0'}) form7 = DecExprForm({'field1': '', 'field2': '0.0'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('256.32')) self.assertEqual(form1.cleaned_data['field2'], Decimal('123.4')) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('256')) self.assertEqual(form2.cleaned_data['field2'], Decimal('123')) self.assertTrue(form3.is_valid()) self.assertFalse(form4.is_valid()) self.assertTrue(form5.is_valid()) # The assertion below would fail since all inputs are rounded # to the correct number of digits after the decimal. This is # documented in the README. # self.assertFalse(form6.is_valid()) self.assertTrue(form7.is_valid()) self.assertEqual(form7.cleaned_data['field1'], None) self.assertEqual(form7.cleaned_data['field2'], Decimal('0')) self.assertEqual(form7.cleaned_data['field3'], None) def test_divide(self): """ Test a few instances of fields with a '/'. """ form1 = DecExprForm({'field1': '1/2', 'field2': '2/1', 'field3': '3/3'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form1.cleaned_data['field2'], Decimal('2')) self.assertEqual(form1.cleaned_data['field3'], Decimal('1')) form2 = DecExprForm({'field1': '1/3', 'field2': '1/3', 'field3': '1/3'}) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('.33')) self.assertEqual(form2.cleaned_data['field2'], Decimal('.3')) self.assertEqual(form2.cleaned_data['field3'], Decimal('0')) form3 = DecExprForm({'field1': '1/4', 'field2': '1/4', 'field3': '1/4'}) self.assertTrue(form3.is_valid()) self.assertEqual(form3.cleaned_data['field1'], Decimal('.25')) self.assertEqual(form3.cleaned_data['field2'], Decimal('.2')) self.assertEqual(form3.cleaned_data['field3'], Decimal('0')) form4 = DecExprForm({'field1': '1/2', 'field2': '1/2', 'field3': '1/2'}) self.assertTrue(form4.is_valid()) self.assertEqual(form4.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field2'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field3'], Decimal('0')) def test_negative_numerators(self): """ Test a few instances of negative numerators. """ formN1 = DecExprForm({'field1': '-1/2', 'field2': '-2/1', 'field3': '-3/3'}) self.assertTrue(formN1.is_valid()) self.assertEqual(formN1.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN1.cleaned_data['field2'], Decimal('-2')) self.assertEqual(formN1.cleaned_data['field3'], Decimal('-1')) formN2 = DecExprForm({'field1': '-1/3', 'field2': '-1/3', 'field3': '-1/3'}) self.assertTrue(formN2.is_valid()) self.assertEqual(formN2.cleaned_data['field1'], Decimal('-.33')) self.assertEqual(formN2.cleaned_data['field2'], Decimal('-.3')) self.assertEqual(formN2.cleaned_data['field3'], Decimal('-0')) formN3 = DecExprForm({'field1': '-1/4', 'field2': '-1/4', 'field3': '-1/4'}) self.assertTrue(formN3.is_valid()) self.assertEqual(formN3.cleaned_data['field1'], Decimal('-.25')) self.assertEqual(formN3.cleaned_data['field2'], Decimal('-.2')) self.assertEqual(formN3.cleaned_data['field3'], Decimal('0')) formN4 = DecExprForm({'field1': '-1/2', 'field2': '-1/2', 'field3': '-1/2'}) self.assertTrue(formN4.is_valid()) self.assertEqual(formN4.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field2'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field3'], Decimal('0')) def test_negative_denominators(self): """ Test a few instances of negative numerators. """ formN1 = DecExprForm({'field1': '1/-2', 'field2': '2/-1', 'field3': '3/-3'}) self.assertTrue(formN1.is_valid()) self.assertEqual(formN1.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN1.cleaned_data['field2'], Decimal('-2')) self.assertEqual(formN1.cleaned_data['field3'], Decimal('-1')) formN2 = DecExprForm({'field1': '1/-3', 'field2': '1/-3', 'field3': '1/-3'}) self.assertTrue(formN2.is_valid()) self.assertEqual(formN2.cleaned_data['field1'], Decimal('-.33')) self.assertEqual(formN2.cleaned_data['field2'], Decimal('-.3')) self.assertEqual(formN2.cleaned_data['field3'], Decimal('-0')) formN3 = DecExprForm({'field1': '1/-4', 'field2': '1/-4', 'field3': '1/-4'}) self.assertTrue(formN3.is_valid()) self.assertEqual(formN3.cleaned_data['field1'], Decimal('-.25')) self.assertEqual(formN3.cleaned_data['field2'], Decimal('-.2')) self.assertEqual(formN3.cleaned_data['field3'], Decimal('0')) formN4 = DecExprForm({'field1': '1/-2', 'field2': '1/-2', 'field3': '1/-2'}) self.assertTrue(formN4.is_valid()) self.assertEqual(formN4.cleaned_data['field1'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field2'], Decimal('-.5')) self.assertEqual(formN4.cleaned_data['field3'], Decimal('0')) def test_divide_negative_by_negative(self): """ Ensure that -/- is positive. """ form1 = DecExprForm({'field1': '-1/-2', 'field2': '-2/-1', 'field3': '-3/-3'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form1.cleaned_data['field2'], Decimal('2')) self.assertEqual(form1.cleaned_data['field3'], Decimal('1')) form2 = DecExprForm({'field1': '-1/-3', 'field2': '-1/-3', 'field3': '-1/-3'}) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('.33')) self.assertEqual(form2.cleaned_data['field2'], Decimal('.3')) self.assertEqual(form2.cleaned_data['field3'], Decimal('0')) form3 = DecExprForm({'field1': '-1/-4', 'field2': '-1/-4', 'field3': '-1/-4'}) self.assertTrue(form3.is_valid()) self.assertEqual(form3.cleaned_data['field1'], Decimal('.25')) self.assertEqual(form3.cleaned_data['field2'], Decimal('.2')) self.assertEqual(form3.cleaned_data['field3'], Decimal('0')) form4 = DecExprForm({'field1': '-1/-2', 'field2': '-1/-2', 'field3': '-1/-2'}) self.assertTrue(form4.is_valid()) self.assertEqual(form4.cleaned_data['field1'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field2'], Decimal('.5')) self.assertEqual(form4.cleaned_data['field3'], Decimal('0')) class DecimalExpressionTests(unittest.TestCase): """more interesting expressions to test""" def test_valid(self): """ Some simple valid expressions. """ form1 = DecExprForm({'field1': '-2+1', 'field2': '1-2', 'field3': '1+-2'}) self.assertTrue(form1.is_valid()) self.assertEqual(form1.cleaned_data['field1'], Decimal('-1')) self.assertEqual(form1.cleaned_data['field2'], Decimal('-1')) self.assertEqual(form1.cleaned_data['field3'], Decimal('-1')) form2 = DecExprForm({'field1': 'pi', 'field2': 'pi', 'field3': 'pi'}) self.assertTrue(form2.is_valid()) self.assertEqual(form2.cleaned_data['field1'], Decimal('3.14')) self.assertEqual(form2.cleaned_data['field2'], Decimal('3.1')) self.assertEqual(form2.cleaned_data['field3'], Decimal('3')) form3 = DecExprForm({'field1': 'sin(90)', 'field2': 'cos(-180)*100', 'field3': 'pow(2,5)'}) self.assertTrue(form3.is_valid()) self.assertEqual(form3.cleaned_data['field1'], Decimal('0.89')) self.assertEqual(form3.cleaned_data['field2'], Decimal('-59.8')) self.assertEqual(form3.cleaned_data['field3'], Decimal('32')) form4 = DecExprForm({'field1': 'abs(-1/2)', 'field2': 'abs(-10)', 'field3': 'sqrt(4)'}) self.assertTrue(form4.is_valid()) self.assertEqual(form4.cleaned_data['field1'], Decimal('0.5')) self.assertEqual(form4.cleaned_data['field2'], Decimal('10')) self.assertEqual(form4.cleaned_data['field3'], Decimal('2')) def test_invalid(self): """ Some ways to try and blow it up. """ formN1 = DecExprForm({'field1': 'ceil', 'field2': 'int', 'field3': '2+x'}) self.assertFalse(formN1.is_valid()) formN2 = DecExprForm({'field1': '-', 'field2': '*', 'field3': '2++3'}) self.assertFalse(formN2.is_valid()) formN3 = DecExprForm({'field1': '1**2', 'field2': 'pow(1,2,3)', 'field3': 'abs(5,6)'}) self.assertFalse(formN3.is_valid())
50.416185
99
0.616602
2,028
17,444
5.199211
0.065582
0.173558
0.051119
0.087633
0.894348
0.879078
0.866939
0.835262
0.825209
0.809086
0
0.067999
0.18224
17,444
345
100
50.562319
0.671153
0.044141
0
0.661417
0
0
0.147949
0
0
0
0
0
0.685039
1
0.047244
false
0
0.015748
0
0.106299
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
1
0
0
0
0
0
0
0
0
0
7
20cb4d63b79da18793744b107461f14ca2217fcf
37,690
py
Python
View/Control/Collection.py
parente/clique
e0a36e592d194a822f0078781d08a2d1aa63c9e4
[ "BSD-3-Clause" ]
3
2015-05-02T10:00:50.000Z
2018-10-26T02:42:13.000Z
View/Control/Collection.py
parente/clique
e0a36e592d194a822f0078781d08a2d1aa63c9e4
[ "BSD-3-Clause" ]
null
null
null
View/Control/Collection.py
parente/clique
e0a36e592d194a822f0078781d08a2d1aa63c9e4
[ "BSD-3-Clause" ]
1
2018-10-26T02:42:14.000Z
2018-10-26T02:42:14.000Z
''' Defines classes for browsing collections of items like lists or trees. @author: Peter Parente <parente@cs.unc.edu> @copyright: Copyright (c) 2008 Peter Parente @license: BSD License All rights reserved. This program and the accompanying materials are made available under the terms of The BSD License which accompanies this distribution, and is available at U{http://www.opensource.org/licenses/bsd-license.php} ''' import Base, Output, Support, Interface class Collection(Base.Control): ''' Virtual class. Collection of items. Model must implement IInteractive, IInfiniteCollection. ISeekable and IFiniteCollection are optional. @ivar label: Label for collection items @type label: string ''' def __init__(self, parent, model, name, label, default_name): ''' Initializes an instance. See instance variables for parameter descriptions. ''' super(Collection, self).__init__(parent, model, name, default_name) self.label = label def OnActivate(self, message, auto_focus): ''' Ensures the control is ready and an item is selected. Plays OutIntroduction. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param auto_focus: Did this object receive the focus automatically? @type auto_focus: boolean @return: Is the control ready for interaction? @rtype: boolean ''' if super(Collection, self).OnActivate(message, auto_focus): p = self.OutIntroduction(message, auto_focus) self.Output(self, p) if not auto_focus: self.NotifyAboutChange() return True else: return False def OnPrevHigh(self, message): ''' Selects the first item in the collection Plays OutFirstItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: exist = Interface.IFiniteCollection(self.model).FirstItem() except NotImplementedError: p = self.OutNotImplemented(message, 'Skipping to the first item is not possible.') self.Output(self, p) else: if exist: p = self.OutFirstItem(message) self.NotifyAboutChange() self.Output(self, p) def OnPrevMid(self, message): ''' Selects the previous item in the collection. Plays OutWrapItem or OutCurrentItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' wrap = Interface.IInfiniteCollection(self.model).PrevItem() if wrap: p = self.OutWrapItem(message) else: p = self.OutCurrentItem(message) self.Output(self, p) self.NotifyAboutChange() def OnNextMid(self, message): ''' Selects the next item in the collection. Plays OutWrapItem or OutCurrentItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' wrap = Interface.IInfiniteCollection(self.model).NextItem() if wrap: p = self.OutWrapItem(message) else: p = self.OutCurrentItem(message) self.Output(self, p) self.NotifyAboutChange() def OnText(self, message): ''' Selects the next item in the collection beginning with the pressed character. Plays OutNotImplemented, OutWrapSeekItem, OutSeekItem, or OutNoSeekItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: r = Interface.ISeekable(self.model).SeekToItem(message.Char) except NotImplementedError: p = self.OutNotImplemented(message, 'Seeking by letter is not available.') else: if r == True: p = self.OutWrapSeekItem(message, message.Char) elif r == False: p = self.OutSeekItem(message, message.Char) else: p = self.OutNoSeekItem(message, message.Char) self.NotifyAboutChange() self.Output(self, p) def OnMoreInfo(self, message): ''' Gives more information about the selected item. Calls OutDetailCurrent. @param message: Input message that triggered this event handler @type message: L{Input.Messages.InboundMessage} ''' p = self.OutDetailCurrent(message) self.Output(self, p) def OutCurrentItem(self, message): ''' Virtual method. Outputs information about the current item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' return None def OutFirstItem(self, message): ''' Outputs the information about the first item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' return None def OutWrapItem(self, message): ''' Virtual method. Outputs information about the current item that was selected by wrapping past a collection bound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' pass class List(Collection): ''' Linear list of selectable items. Model must implement IInteractive and IInfiniteCollection. ISeekable, IList, IDeleteable, and IDetailable are optional. @ivar order: Order in which fields should be reported @type order: list ''' def __init__(self, parent, model, name='', label='item', order=None): ''' Initializes an instance. See instance variables for parameter descriptions. ''' super(List, self).__init__(parent, model, name, label, default_name='list') self.empty = 'The %s list is empty.' self.order = order def GetSpeakableIndex(self): ''' @return: Speakable description of the index of the current element @rtype: string ''' try: m = Interface.IFiniteCollection(self.model) except NotImplementedError: return '' if m.GetItemCount() > 0: return '%s %d of %d' % (self.label, m.GetIndex()+1, m.GetItemCount()) else: return '' def OnNextHigh(self, message): ''' Changes the sort order of the list if possible. Plays OutNotImplemented, OutCurrentSort, OutWrapSort. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: wrap = Interface.ISortable(self.model).SortPrev() except NotImplementedError: p = self.OutNotImplemented(message, 'Sorting not available.') else: if wrap: p = self.OutWrapSort(message) else: p = self.OutCurrentSort(message) self.Output(self, p) def OnNextLow(self, message): ''' Changes the sort order of the list if possible. Plays OutNotImplemented, OutCurrentSort, OutWrapSort. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: wrap = Interface.ISortable(self.model).SortNext() except NotImplementedError: p = self.OutNotImplemented(message, 'Sorting not available.') else: if wrap: p = self.OutWrapSort(message) else: p = self.OutCurrentSort(message) self.Output(self, p) def OnPrevLow(self, message): ''' Selects the last item in the collection Plays OutNotImplemented, OutCurrentItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: exist = Interface.IList(self.model).LastItem() except NotImplementedError: p = self.OutNotImplemented(message, 'Skipping to the last item is not possible.') self.Output(self, p) else: if exist: p = self.OutLastItem(message) self.NotifyAboutChange() self.Output(self, p) def OnDelete(self, message): ''' Deletes an item from the list if deletion is allowed. Calls OutNotImplemented, OutDeleteItem. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' try: m = Interface.IDeletable(self.model) except NotImplementedError: p = self.OutNotImplemented(message, 'Deletion is not available.') else: m.Delete() p = self.OutDeleteItem(message) self.NotifyAboutChange() self.Output(self, p) def OutIntroduction(self, message, auto_focus): ''' Outputs the name of the list, the index of the current item, and the name of the current item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param auto_focus: Did this object receive the focus automatically? @type auto_focus: boolean @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' # the control exists, tell the user about it m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech='%s, %s' % (self.Name, self.GetSpeakableIndex()), sound=Output.ISound(self).Action('start'), person=Output.SUMMARY), p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) return p def OutDeadLong(self, message): ''' Outputs a message stating the list is not available. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' # the control is missing, inform the user p = Output.Packet(self, message) p.AddMessage(speech='The list of %s is not available' % self.Name, person=Output.SUMMARY) return p def OutChange(self, message): ''' Outputs the number of items or the currently selected item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) try: # report the number of items in the list if it is finite m = Interface.IFiniteCollection(self.model) p.AddMessage(sound=Output.ISound(self).Action('start'), person=Output.SUMMARY, speech='%d items in %s' % (m.GetItemCount(), self.Name)) except NotImplementedError: # report the selected item if infinite m = Interface.IInfiniteCollection(self.model) p.AddMessage(sound=Output.ISound(self).Action('start'), person=Output.SUMMARY, speech=m.GetSelectedName(self.empty % self.Name)) return p def OutCurrentSort(self, message): ''' Outputs the name of the current sort key. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ISortable(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSortName(), person=Output.SUMMARY) return p def OutCurrentItem(self, message): ''' Outputs the name of the current item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) return p def OutLastItem(self, message): ''' Outputs the name of the current item and its index. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(speech=self.GetSpeakableIndex(), person=Output.SUMMARY) return p def OutFirstItem(self, message): ''' Outputs the name of the current item and its index. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(speech=self.GetSpeakableIndex(), person=Output.SUMMARY) return p def OutSeekItem(self, message, text): ''' Outputs the name of the current item and its index. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param text: Text to seek @type text: string @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(speech=self.GetSpeakableIndex(), person=Output.SUMMARY) p2 = Output.Packet(self, message, group=Output.NARRATOR) p2.AddMessage(speech=text, letters=True) return p, p2 OutSearchItem = OutSeekItem def OutWrapSeekItem(self, message, text): ''' Outputs the name of the current item, its index, and the wrap sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param text: Text to seek @type text: string @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(speech=self.GetSpeakableIndex(), sound=Output.ISound(self).Action('wrap'), person=Output.SUMMARY) p2 = Output.Packet(self, message, group=Output.NARRATOR) p2.AddMessage(speech=text, letters=True) return p, p2 OutWrapSearchItem = OutWrapSeekItem def OutWrapItem(self, message): ''' Outputs the name of the current item and the wrap sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(sound=Output.ISound(self).Action('wrap'), person=Output.SUMMARY) return p def OutWrapSort(self, message): ''' Outputs the name of the current sort key. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ISortable(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSortName(), sound=Output.ISound(self).Action('wrap'), person=Output.SUMMARY) return p @Support.generator_method('List') def OutDetailCurrent_gen(self, message): ''' Outputs the name of the item and the index of the item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message, listen=True, name='details') p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) yield p p = Output.Packet(self, message, listen=True, name='details') p.AddMessage(speech=self.GetSpeakableIndex(), person=Output.SUMMARY) yield p try: m = Interface.IDetailable(self.model) except NotImplementedError: return fields = m.GetFields() # put all field names in desired order if self.order is not None: order = self.order + [f for f in fields if f not in self.order] else: # otherwise, sort alphabetically order = fields.keys() order.sort() # speak every name/value pair one at a time for name in order: try: # ignore keys that do not exist value = fields[name] except KeyError: continue p = Output.Packet(self, message, listen=True, name='details') p.AddMessage(speech='%s: %s' % (name, value), person=Output.CONTENT) yield p def OutDeleteItem(self, message): ''' Ouputs the name of the newly selected item and the deletion sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IInfiniteCollection(self.model) p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) p.AddMessage(sound=Output.ISound(self).Action('delete'), person=Output.SUMMARY) return p def OutWhereAmI(self, message): ''' Outputs the name and sound of the list. @param message: Packet message that triggered this event handler @type message: L{Output.Messages.PacketMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' p = super(List, self).OutWhereAmI(message) s = 'browsing the %s list' % self.Name p.AddMessage(speech=s, sound=Output.ISound(self).Action('start'), person=Output.SUMMARY) return p class StridedList(List): ''' Linear list of selectable items that can be navigated at multiple levels. Model must implement IInteractive, IInfiniteCollection, and IStrideable. ISeekable, IList, IDeleteable, and IDetailable are optional. ''' def GetSpeakableLevel(self): ''' @return: Speakable description of the current level @rtype: string ''' return 'browsing by %s' % Interface.IStrideable(self.model).GetLevel() def GetSpeakableIndex(self): ''' Gets the same value returned by GetSpeakableLevel. This method only exists to enable the easy reuse of OutDetailCurrent_gen from the parent class. @return: Speakable description of the current level @rtype: string ''' return self.GetSpeakableLevel() def OnLow(self, message): ''' Selects the next smaller stride level. Plays OutNextLevel or OutSmallestStride. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' if Interface.IStrideable(self.model).NextLevel(): p = self.OutNextLevel(message) self.NotifyAboutChange() else: p = self.OutSmallestStride(message) self.Output(self, p) def OnHigh(self, message): ''' Selects the next larger stride level. Plays OutPrevLevel or OutLargestStride. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' if Interface.IStrideable(self.model).PrevLevel(): p = self.OutPrevLevel(message) self.NotifyAboutChange() else: p = self.OutLargestStride(message) self.Output(self, p) def OutIntroduction(self, message, auto_focus): ''' Outputs the name of the list, the current stride level, and the name of the current item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param auto_focus: Did this object receive the focus automatically? @type auto_focus: boolean @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.IStrideable(self.model) p = Output.Packet(self, message) p.AddMessage(speech='%s, %s' % (self.Name, self.GetSpeakableLevel()), sound=Output.ISound(self).Action('start'), person=Output.SUMMARY) m = Interface.IInfiniteCollection(self.model) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), person=Output.CONTENT) return p def OutNextLevel(self, message): ''' Outputs the name of the next stride level and the next level sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(speech=self.GetSpeakableLevel(), person=Output.SUMMARY, sound=Output.ISound(self).Action('next')) return p def OutPrevLevel(self, message): ''' Outputs the name of the previous stride level and the next level sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(speech=self.GetSpeakableLevel(), person=Output.SUMMARY, sound=Output.ISound(self).Action('previous')) return p def OutSmallestStride(self, message): ''' Outputs the smallest stride level reached sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(sound=Output.ISound(self).State('last'), person=Output.SUMMARY) return p def OutLargestStride(self, message): ''' Outputs the largest stride level reached sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(sound=Output.ISound(self).State('first'), person=Output.SUMMARY) return p class Tree(Collection): ''' Hierarchy of nested lists. Model must implment IInteractive, ITree, ISeekable, and IStrideable. ''' def __init__(self, parent, model, name='', label='sibling'): ''' Initializes an instance. See instance variables for parameter description. ''' super(Tree, self).__init__(parent, model, name, label, default_name='tree') self.empty = 'The %s tree is empty.' def GetSpeakableLevel(self): ''' @return: Speakable description of the current level @rtype: string ''' return 'level %d' % Interface.IStrideable(self.model).GetLevel() def GetSpeakableIndex(self): ''' @return: Speakable description of the index of the current element @rtype: string ''' m = Interface.IFiniteCollection(self.model) c = m.GetItemCount() if c > 0: return '%s %d of %d' % (self.label, m.GetIndex()+1, c) else: return '' def GetSpeakableChildCount(self): ''' @return: Speakable description of the number of children of the current item @rtype: string ''' children = Interface.ITree(self.model).GetChildCount() if children > 0: return '%d children' % children else: return '' def OnLow(self, message): ''' Navigates to a lower level in the tree. Plays OutNextLevel or OutLeafOfTree. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} ''' if Interface.IStrideable(self.model).NextLevel(): # report current item name, level and children p = self.OutNextLevel(message) self.NotifyAboutChange() else: p = self.OutLeafOfTree(message) self.Output(self, p) def OnHigh(self, message): ''' Navigates to a higher level in the tree. Plays OutPrevLevel or OutRootOfTree. @param message: Message that caused this event handler to fire @type message: L{Input.MessagesInboundMessage} ''' if Interface.IStrideable(self.model).PrevLevel(): # report current item name, level and children p = self.OutPrevLevel(message) self.NotifyAboutChange() else: p = self.OutRootOfTree(message) self.Output(self, p) def OutIntroduction(self, message, auto_focus): ''' Outputs the name of the tree, the index of the current item, the level of the current item, and the name of the current item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param auto_focus: Did this object receive the focus automatically? @type auto_focus: boolean @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' # the control exists, tell the user about it m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) s = '%s, %s, %s' % (self.Name, self.GetSpeakableLevel(), self.GetSpeakableIndex()) p.AddMessage(speech=s, sound=Output.ISound(self).Action('start'), person=Output.SUMMARY) if m.GetItemCount() == 0: s = '' else: s = '%s, in %s'% (m.GetSelectedName(self.empty % self.Name), m.GetParentName()) p.AddMessage(speech=s, sound=sound, person=Output.CONTENT) return p def OutDeadLong(self, message): ''' Outputs a message stating the list is not available. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' # the control is missing, inform the user p = Output.Packet(self, message) p.AddMessage(speech='The tree of %s is not available' % self.Name) return p def OutRootOfTree(self, message): ''' Outputs the root of tree sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(sound=Output.ISound(self).State('first'), person=Output.SUMMARY) return p def OutLeafOfTree(self, message): ''' Outputs the leaf of tree sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' p = Output.Packet(self, message) p.AddMessage(sound=Output.ISound(self).State('last'), person=Output.SUMMARY) return p def OutNextLevel(self, message): ''' Outputs the name of the selected item, the number of children of the current item, the level of the current item, the index of the item among its siblings, and the next level sound. Plays the children indicator too if the item has children. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech = '%s, %s' % (self.GetSpeakableLevel(), self.GetSpeakableIndex()), person=Output.SUMMARY, sound=Output.ISound(self).Action('next')) p.AddMessage(speech='%s, in %s' % (m.GetSelectedName(self.empty % self.Name), m.GetParentName()), sound=sound, person=Output.CONTENT) return p def OutPrevLevel(self, message): ''' Outputs the name of the selected item, the number of children of the current item, the level of the current item, the index of the item among its siblings, and the previous level sound. Plays the children indicator too if the item has children. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech = '%s, %s' % (self.GetSpeakableLevel(), self.GetSpeakableIndex()), person=Output.SUMMARY, sound=Output.ISound(self).Action('previous')) p.AddMessage(speech='%s, in %s' % (m.GetSelectedName(self.empty % self.Name), m.GetParentName()), sound=sound, person=Output.CONTENT) return p def OutFirstItem(self, message): ''' Outputs the name of the selected item, the number of children of the current item, the level of the current item, the index of the item among its siblings, and the previous level sound. Plays the children indicator too if the item has children. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech = '%s, %s' % (self.GetSpeakableLevel(), self.GetSpeakableIndex()), person=Output.SUMMARY, sound=Output.ISound(self).Action('previous')) p.AddMessage(speech='%s, in %s' % (m.GetSelectedName(self.empty % self.Name), m.GetParentName()), sound=sound, person=Output.CONTENT) return p @Support.generator_method('Tree') def OutDetailCurrent_gen(self, message): ''' Outputs the name of the current selection; its child count, level, and index; and its containing element. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None # speak the item name p = Output.Packet(self, message, listen=True, name='details') p.AddMessage(speech='%s, in %s' % (m.GetSelectedName(self.empty % self.Name), m.GetParentName()), sound=sound, person=Output.CONTENT) yield p # then its location p = Output.Packet(self, message, listen=True, name='details') p.AddMessage(speech='%s, %s, %s' % (self.GetSpeakableChildCount(), self.GetSpeakableLevel(), self.GetSpeakableIndex()), person=Output.SUMMARY) yield p def OutSeekItem(self, message, text): ''' Outputs the name of the selected item, the number of children of the current item, the level of the current item, the index of the item among its siblings, and the has children sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param text: Text to seek @type text: string @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), sound=sound, person=Output.CONTENT) p2 = Output.Packet(self, message, group=Output.NARRATOR) p2.AddMessage(speech=text, letters=True) return p, p2 def OutWrapSeekItem(self, message, text): ''' Outputs the name of the selected item, the number of children of the current item, the level of the current item, the index of the item among its siblings, the has children sound, and the wrap sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @param text: Text to seek @type text: string @return: Packet of information to be output @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), sound=sound, person=Output.CONTENT) p.AddMessage(person=Output.SUMMARY, sound=Output.ISound(self).Action('wrap')) p2 = Output.Packet(self, message, group=Output.NARRATOR) p2.AddMessage(speech=text, letters=True) return p, p2 def OutWrapItem(self, message): ''' Outputs the name of the current item, the wrap sound, and the has children sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), sound=sound, person=Output.CONTENT) p.AddMessage(sound=Output.ISound(self).Action('wrap'),person=Output.SUMMARY) return p def OutCurrentItem(self, message): ''' Outputs the name of the current item and the has children sound. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) if m.HasChildren(): sound = Output.ISound(self).State('navigable') else: sound = None p = Output.Packet(self, message) p.AddMessage(speech=m.GetSelectedName(self.empty % self.Name), sound=sound, person=Output.CONTENT) return p def OutChange(self, message): ''' Outputs the name of the selected item. @param message: Message that caused this event handler to fire @type message: L{Input.Messages.InboundMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' m = Interface.ITree(self.model) # report the name of the selected item p = Output.Packet(self, message) p.AddMessage(sound=Output.ISound(self).Action('start'), person=Output.SUMMARY, speech='%s selected in %s' % (m.GetSelectedName(self.empty % self.Name), self.Name)) return p def OutWhereAmI(self, message): ''' Outputs the name and sound of the tree. @param message: Packet message that triggered this event handler @type message: L{Output.Messages.PacketMessage} @return: Output to be played @rtype: L{Output.Messages.OutboundPacket} ''' p = super(Tree, self).OutWhereAmI(message) s = 'browsing the %s tree' % self.Name p.AddMessage(speech=s, sound=Output.ISound(self).Action('start'), person=Output.SUMMARY) return p if __name__ == '__main__': pass
34.546288
82
0.656487
4,524
37,690
5.456897
0.077144
0.039211
0.032406
0.033054
0.84028
0.811885
0.794669
0.772755
0.74918
0.716612
0
0.000773
0.244548
37,690
1,090
83
34.577982
0.866259
0.417485
0
0.748988
0
0
0.03983
0
0
0
0
0
0
1
0.119433
false
0.004049
0.002024
0
0.226721
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
20d74829c0d10698f13a90d95ad16e924e06a537
37,217
py
Python
trojsten/reviews/tests.py
MvonK/web
b701a6ea8fb6f0bdfb720e66d0a430db13db8bff
[ "MIT" ]
5
2018-04-22T22:44:02.000Z
2021-04-26T20:44:44.000Z
trojsten/reviews/tests.py
MvonK/web
b701a6ea8fb6f0bdfb720e66d0a430db13db8bff
[ "MIT" ]
250
2018-04-24T12:04:11.000Z
2022-03-09T06:56:47.000Z
trojsten/reviews/tests.py
MvonK/web
b701a6ea8fb6f0bdfb720e66d0a430db13db8bff
[ "MIT" ]
8
2019-04-28T11:33:03.000Z
2022-02-26T13:30:36.000Z
#!/usr/bin/env python # -*- coding: utf-8 -*- import io import shutil import sys import tempfile import zipfile from os import path from django.conf import settings from django.contrib.auth.models import Group from django.contrib.sites.models import Site from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import formset_factory from django.test import TestCase, override_settings from django.urls import reverse from django.utils import timezone from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ from trojsten.contests.models import Competition, Round, Semester, Task from trojsten.people.models import User from trojsten.reviews import constants as review_constants from trojsten.reviews import helpers from trojsten.reviews.forms import BasePointForm, BasePointFormSet, UploadZipForm, ZipForm from trojsten.submit import constants as submit_constants from trojsten.submit.models import Submit from trojsten.utils.test_utils import get_noexisting_id try: from urllib.request import quote, unquote except ImportError: from urllib import quote, unquote class UploadZipFormTests(TestCase): def test_only_zip_extension_is_valid(self): z = UploadZipForm(data={}, files={"file": SimpleUploadedFile("file.wtf", b"abc")}) self.assertFalse(z.is_valid()) def test_zip_extension_check_is_case_insensitive(self): z = UploadZipForm(data={}, files={"file": SimpleUploadedFile("file.ZIP", b"abc")}) self.assertTrue(z.is_valid()) def test_no_zip_file_uploaded_is_handled_correctly(self): z = UploadZipForm(data={}, files={}) self.assertFalse(z.is_valid()) class ReviewZipFormTests(TestCase): def setUp(self): self.choices = [(47, "Meno Priezvisko")] self.test_str = "ľščťžýáíéúňďôä" self.test_str_win1250 = self.test_str.encode("cp1250") self.test_str_utf8 = self.test_str.encode("utf8") self.valid_files_win1250 = set([self.test_str_win1250]) self.valid_files_utf8 = set([self.test_str_utf8]) if sys.version_info[0] == 3: # FIXME: remove this check when we stop supporting python2.7 self.valid_files_win1250 = set([unquote(quote(self.test_str_win1250))]) self.valid_files_utf8 = set([self.test_str_utf8.decode("utf8")]) self.user = User(pk=47) self.user.save() pass def test_win_1250_valid(self): d = ZipForm( { "filename": quote(self.test_str_win1250), "points": 3, "user": 47, "comment": self.test_str, }, choices=self.choices, max_value=47, valid_files=self.valid_files_win1250, ) self.assertTrue(d.is_valid()) def test_win_1250_encode(self): z = ZipForm( initial={ "filename": self.test_str_win1250, "points": 3, "user": 47, "comment": self.test_str_win1250, }, choices=self.choices, max_value=47, valid_files=self.valid_files_win1250, ) self.assertEqual(z.initial["filename"], quote(self.test_str_win1250)) self.assertEqual(z.initial["comment"], self.test_str) def test_utf8_valid(self): d = ZipForm( { "filename": quote(self.test_str_utf8), "points": 3, "user": 47, "comment": self.test_str, }, choices=self.choices, max_value=47, valid_files=self.valid_files_utf8, ) self.assertTrue(d.is_valid()) def test_utf8_encode(self): z = ZipForm( initial={ "filename": self.test_str_utf8, "points": 3, "user": 47, "comment": self.test_str_utf8, }, choices=self.choices, max_value=47, valid_files=self.valid_files_utf8, ) self.assertEqual(z.initial["filename"], quote(self.test_str_utf8)) self.assertEqual(z.initial["comment"], self.test_str) class ReviewTest(TestCase): def setUp(self): year = timezone.now().year + 2 self.user = User.objects.create_user( username="TestUser", password="password", first_name="Jozko", last_name="Mrkvicka", graduation=year, ) self.staff = User.objects.create_user( username="TestStaff", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) self.staff.is_staff = True self.staff.save() group = Group.objects.create(name="Test Group") group.user_set.add(self.staff) competition = Competition.objects.create(name="TestCompetition", organizers_group=group) competition.sites.add(Site.objects.get(pk=settings.SITE_ID)) semester = Semester.objects.create( number=1, name="Test semester 1", year=1, competition=competition ) start = timezone.now() + timezone.timedelta(-8) end = timezone.now() + timezone.timedelta(-4) test_round = Round.objects.create( number=1, semester=semester, solutions_visible=True, start_time=start, end_time=end, visible=True, ) self.no_submit_task = Task.objects.create(number=1, name="Test task 1", round=test_round) self.task = Task.objects.create(number=2, name="Test task 2", round=test_round) self.submit = Submit.objects.create(task=self.task, user=self.user, submit_type=1, points=5) self.submit.time = self.task.round.start_time + timezone.timedelta(0, 5) self.submit.save() self.url_name = "admin:review_task" def test_redirect_to_login(self): # Najprv sa posle na login, potom na admin login, a az potom na povodnu stranku. # Posledna cast za next je double quoted, posledne next je len quoted. url = reverse(self.url_name, kwargs={"task_pk": 1}) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to, fetch_redirect_response=False) def test_redirect_to_admin_login(self): # Tato url nie je vobec quoted. url = reverse(self.url_name, kwargs={"task_pk": 1}) response = self.client.get(url, follow=True) self.client.force_login(self.user) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to) def test_invalid_task(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": get_noexisting_id(Task)}) response = self.client.get(url) self.assertEqual(response.status_code, 404) def test_staff_not_in_group(self): staff = User.objects.create_user( username="TestStaffOther", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) staff.is_staff = True staff.save() self.client.force_login(staff) url = reverse(self.url_name, kwargs={"task_pk": self.no_submit_task.id}) response = self.client.get(url) self.assertEqual(response.status_code, 403) def test_valid_task(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.no_submit_task.id}) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, self.no_submit_task.name) def test_not_reviewable_submit(self): for s_type in [ submit_constants.SUBMIT_TYPE_SOURCE, submit_constants.SUBMIT_TYPE_TESTABLE_ZIP, submit_constants.SUBMIT_TYPE_EXTERNAL, ]: submit = Submit.objects.create( task=self.no_submit_task, user=self.user, submit_type=s_type, points=5 ) submit.time = self.no_submit_task.round.start_time + timezone.timedelta(0, 5) submit.save() self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.no_submit_task.id}) response = self.client.get(url) self.assertNotContains(response, self.user.get_full_name()) def test_description_submit(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) self.assertContains(response, self.user.get_full_name()) def test_reviewed(self): comment = "TESTINGcomment" multi_line_comment = """Comment On More Lines""" self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) self.submit.reviewer_comment = comment self.submit.save() response = self.client.get(url) self.assertNotContains(response, comment) self.assertNotContains(response, multi_line_comment) self.submit.testing_status = submit_constants.SUBMIT_STATUS_REVIEWED self.submit.save() response = self.client.get(url) self.assertContains(response, comment) self.submit.reviewer_comment = multi_line_comment self.submit.save() response = self.client.get(url) self.assertNotContains(response, comment) self.assertContains(response, multi_line_comment) def test_hidden_points_alert(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) self.task.description_points_visible = False self.task.save() response = self.client.get(url) self.assertContains(response, _("Description points are hidden in results!")) self.task.description_points_visible = True self.task.save() response = self.client.get(url) self.assertNotContains(response, _("Description points are hidden in results!")) def test_submitted_at_end_of_round(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) submit = Submit.objects.create(task=self.task, user=self.user, submit_type=1, points=5) submit.time = self.task.round.end_time submit.save() response = self.client.get(url) self.assertContains(response, self.user.get_full_name()) @override_settings(SUBMIT_PATH=tempfile.mkdtemp(dir=path.join(path.dirname(__file__), "test_data"))) class DownloadLatestSubmits(TestCase): @classmethod def tearDownClass(cls): shutil.rmtree(settings.SUBMIT_PATH) super(DownloadLatestSubmits, cls).tearDownClass() def setUp(self): year = timezone.now().year + 2 self.user = User.objects.create_user( username="TestUser", password="password", first_name="Jozko", last_name="Mrkvicka", graduation=year, ) self.staff = User.objects.create_user( username="TestStaff", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) self.staff.is_staff = True self.staff.save() self.protocol = """<protokol><runLog> <test><name>0.sample.a.in</name><resultCode>1</resultCode><resultMsg>OK</resultMsg><time>28</time></test> <test><name>0.sample.b.in</name><resultCode>1</resultCode><resultMsg>OK</resultMsg><time>28</time></test> <score>100</score><details> Score: 100 </details><finalResult>1</finalResult><finalMessage>OK (OK: 100 %)</finalMessage> </runLog></protokol> """ group = Group.objects.create(name="Test Group") group.user_set.add(self.staff) competition = Competition.objects.create(name="TestCompetition", organizers_group=group) competition.sites.add(Site.objects.get(pk=settings.SITE_ID)) semester = Semester.objects.create( number=1, name="Test semester 1", year=1, competition=competition ) test_round = Round.objects.create( number=1, semester=semester, solutions_visible=True, visible=True ) self.task = Task.objects.create(number=2, name="TestTask2", round=test_round) self.url_name = "admin:download_latest_submits" def test_redirect_to_login(self): # Should send user to administrator login url = reverse(self.url_name, kwargs={"task_pk": 1}) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to, fetch_redirect_response=False) def test_redirect_to_admin_login(self): # Tato url nie je vobec quoted. url = reverse(self.url_name, kwargs={"task_pk": 1}) response = self.client.get(url, follow=True) self.client.force_login(self.user) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to) def test_invalid_task(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": get_noexisting_id(Task)}) response = self.client.get(url) self.assertEqual(response.status_code, 404) def test_staff_not_in_group(self): staff = User.objects.create_user( username="TestStaffOther", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) staff.is_staff = True staff.save() self.client.force_login(staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) self.assertEqual(response.status_code, 403) def test_valid_task(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertRegexpMatches( response["Content-Disposition"], r"filename=.*%s.*" % slugify(self.task.name) ) def test_only_description_submit(self): submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() submit_file = helpers.submit_download_filename(submit, 0) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") self.assertIsNone(zipped_file.testzip()) self.assertIn(submit_file, zipped_file.namelist()) zipped_file.close() f.close() def test_only_source_submit(self): submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_SOURCE, filepath=path.join(path.dirname(__file__), "test_data", "submits", "source.cpp"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() submit_file = helpers.submit_download_filename(submit, 0) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") self.assertIsNone(zipped_file.testzip()) # pretoze k nemu nemam description tak nie je co reviewovat self.assertNotIn(submit_file, zipped_file.namelist()) zipped_file.close() f.close() def test_source_description_submit(self): desc_submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) desc_submit.time = self.task.round.start_time + timezone.timedelta(0, 5) desc_submit.save() submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_SOURCE, filepath=path.join(path.dirname(__file__), "test_data", "submits", "source.cpp"), protocol=self.protocol, protocol_id="test_id_47", ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() submit_file = helpers.submit_source_download_filename(submit, desc_submit.id, 0) protocol_file = helpers.submit_protocol_download_filename(submit, desc_submit.id, 0) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") self.assertIsNone(zipped_file.testzip()) self.assertIn(submit_file, zipped_file.namelist()) self.assertIn(protocol_file, zipped_file.namelist()) zipped_file.close() f.close() def test_comment_in_submit(self): comment = """TESTINGComment\ns diakritikou áäčďéíľňóŕšťúýž""" submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() Submit.objects.create( task=self.task, user=self.user, points=5, reviewer_comment=comment, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, ) comm_file = "%s%s" % ( helpers.submit_directory(submit, 0), review_constants.REVIEW_COMMENT_FILENAME, ) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") data = zipped_file.read(comm_file) self.assertEqual(data.decode("utf-8"), comment) zipped_file.close() f.close() def test_points_in_submit(self): points = 47 submit = Submit.objects.create( task=self.task, user=self.user, points=0, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() Submit.objects.create( task=self.task, user=self.user, points=points, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, ) points_file = "%s%s" % ( helpers.submit_directory(submit, 0), review_constants.REVIEW_POINTS_FILENAME, ) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") data = zipped_file.read(points_file) self.assertEqual(int(data), points) zipped_file.close() f.close() def test_description_without_file(self): submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath="", ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") data = zipped_file.read(review_constants.REVIEW_ERRORS_FILENAME) self.assertIn(self.user.get_full_name(), data.decode("utf-8")) zipped_file.close() f.close() def test_source_description_without_files(self): desc_submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath="", ) desc_submit.time = self.task.round.start_time + timezone.timedelta(0, 5) desc_submit.save() submit = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_SOURCE, filepath="", ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") data = zipped_file.read(review_constants.REVIEW_ERRORS_FILENAME) self.assertIn(self.user.get_full_name(), data.decode("utf-8")) zipped_file.close() f.close() def test_exclude_review_in_download_latest_submits(self): submit = Submit.objects.create( task=self.task, user=self.user, points=0, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() submit_file = helpers.submit_download_filename(submit, 0) review = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, filepath=path.join(path.dirname(__file__), "test_data", "submits", "review.txt"), ) review_file = helpers.submit_download_filename(review, 0) self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") self.assertIsNone(zipped_file.testzip()) self.assertIn(submit_file, zipped_file.namelist()) self.assertNotIn(review_file, zipped_file.namelist()) zipped_file.close() f.close() def test_include_review_in_download_latest_reviewed_submits(self): submit = Submit.objects.create( task=self.task, user=self.user, points=0, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, filepath=path.join(path.dirname(__file__), "test_data", "submits", "description.txt"), ) submit.time = self.task.round.start_time + timezone.timedelta(0, 5) submit.save() submit_file = helpers.submit_download_filename(submit, 0) review = Submit.objects.create( task=self.task, user=self.user, points=5, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, filepath=path.join(path.dirname(__file__), "test_data", "submits", "review.txt"), ) review_file = helpers.submit_download_filename(review, 0) self.client.force_login(self.staff) url = reverse("admin:download_latest_reviewed_submits", kwargs={"task_pk": self.task.id}) response = self.client.get(url) f = io.BytesIO(b"".join(response.streaming_content)) zipped_file = zipfile.ZipFile(f, "a") self.assertIsNone(zipped_file.testzip()) self.assertNotIn(submit_file, zipped_file.namelist()) self.assertIn(review_file, zipped_file.namelist()) zipped_file.close() f.close() class ReviewEditTest(TestCase): def setUp(self): year = timezone.now().year + 2 self.user = User.objects.create_user( username="TestUser", password="password", first_name="Jozko", last_name="Mrkvicka", graduation=year, ) self.staff = User.objects.create_user( username="TestStaff", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) self.staff.is_staff = True self.staff.save() group = Group.objects.create(name="Test Group") group.user_set.add(self.staff) competition = Competition.objects.create(name="TestCompetition", organizers_group=group) competition.sites.add(Site.objects.get(pk=settings.SITE_ID)) semester = Semester.objects.create( number=1, name="Test semester 1", year=1, competition=competition ) start = timezone.now() + timezone.timedelta(-8) end = timezone.now() + timezone.timedelta(-4) test_round = Round.objects.create( number=1, semester=semester, solutions_visible=True, start_time=start, end_time=end, visible=True, ) self.task = Task.objects.create(number=2, name="Test task 2", round=test_round) self.submit = Submit.objects.create(task=self.task, user=self.user, submit_type=1, points=5) self.submit.time = self.task.round.start_time + timezone.timedelta(0, 5) self.submit.save() self.url_name = "admin:review_edit" def test_redirect_to_login(self): # Should send user to administrator login url = reverse(self.url_name, kwargs={"task_pk": 1, "submit_pk": 1}) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to, fetch_redirect_response=False) def test_redirect_to_admin_login(self): # Tato url nie je vobec quoted. url = reverse(self.url_name, kwargs={"task_pk": 1, "submit_pk": 1}) response = self.client.get(url, follow=True) self.client.force_login(self.user) response = self.client.get(url) redirect_to = "%s?next=%s" % (reverse("admin:login"), url) self.assertRedirects(response, redirect_to) def test_invalid_task(self): self.client.force_login(self.staff) url = reverse( self.url_name, kwargs={"task_pk": get_noexisting_id(Task), "submit_pk": get_noexisting_id(Submit)}, ) response = self.client.get(url) self.assertEqual(response.status_code, 404) def test_staff_not_in_group(self): staff = User.objects.create_user( username="TestStaffOther", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, ) staff.is_staff = True staff.save() self.client.force_login(staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id, "submit_pk": self.submit.id}) response = self.client.get(url) self.assertEqual(response.status_code, 403) def test_valid_task(self): self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id, "submit_pk": self.submit.id}) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, self.task.name) self.assertContains(response, self.user.get_full_name()) def test_reviewed(self): comment = """TESTINGComment s diakritikou áäčďéíľňóŕšťúýž""" self.client.force_login(self.staff) url = reverse(self.url_name, kwargs={"task_pk": self.task.id, "submit_pk": self.submit.id}) response = self.client.get(url) self.assertNotContains(response, comment) self.submit.reviewer_comment = comment self.submit.save() response = self.client.get(url) self.assertContains(response, comment) multi_line_comment = "Comment\nOn\nMore\nLines" self.submit.reviewer_comment = multi_line_comment self.submit.save() response = self.client.get(url) self.assertContains(response, multi_line_comment) class PointFormSetTests(TestCase): def setUp(self): year = timezone.now().year + 2 self.user1 = User.objects.create_user( username="TestUser1", password="password", first_name="Jozko", last_name="Mrkvicka", graduation=year, pk=1, ) group = Group.objects.create(name="Test Group") competition = Competition.objects.create(name="TestCompetition", organizers_group=group) competition.sites.add(Site.objects.get(pk=settings.SITE_ID)) semester = Semester.objects.create( number=1, name="Test semester 1", year=1, competition=competition ) test_round = Round.objects.create( number=1, semester=semester, solutions_visible=True, visible=True, start_time=timezone.now() + timezone.timedelta(-4), end_time=timezone.now() + timezone.timedelta(-1), ) self.task = Task.objects.create( number=2, name="TestTask2", round=test_round, description_points=9 ) submit = Submit.objects.create( task=self.task, user=self.user1, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, points=0, testing_status=submit_constants.SUBMIT_STATUS_IN_QUEUE, ) submit.time = test_round.end_time + timezone.timedelta(hours=-1) submit.save() self.form_set_class = formset_factory(BasePointForm, BasePointFormSet, extra=0) self.data = { "form-TOTAL_FORMS": "1", "form-INITIAL_FORMS": "0", "form-MAX_NUM_FORMS": "1000", "form-0-user": "1", "form-0-points": "", "form-0-reviewer_comment": "", } def test_add_new_reviews(self): self.data["form-0-points"] = 4 self.data["form-0-reviewer_comment"] = "Nic moc" form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertTrue(form_set.is_valid()) form_set.save(self.task) users = helpers.get_latest_submits_for_task(self.task) self.assertEqual(users[self.user1]["review"].points, 4) self.assertEqual(users[self.user1]["review"].reviewer_comment, "Nic moc") def test_edit_review(self): Submit.objects.create( task=self.task, user=self.user1, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, points=7, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, reviewer_comment="First comment", ) self.data["form-0-points"] = 9 self.data["form-0-reviewer_comment"] = "Second comment" form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertTrue(form_set.is_valid()) form_set.save(self.task) users = helpers.get_latest_submits_for_task(self.task) self.assertEqual(users[self.user1]["review"].points, 9) self.assertEqual(users[self.user1]["review"].reviewer_comment, "Second comment") def test_empty_points(self): form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertTrue(form_set.is_valid()) form_set.save(self.task) users = helpers.get_latest_submits_for_task(self.task) self.assertNotIn("review", users[self.user1]) def test_empty_points_with_review(self): Submit.objects.create( task=self.task, user=self.user1, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, points=7, testing_status=submit_constants.SUBMIT_STATUS_REVIEWED, reviewer_comment="First comment", ) form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertTrue(form_set.is_valid()) form_set.save(self.task) users = helpers.get_latest_submits_for_task(self.task) self.assertNotIn("review", users[self.user1]) def test_invalid_negative_points(self): self.data["form-0-points"] = -47 form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertFalse(form_set.is_valid()) def test_invalid_too_many_points(self): self.data["form-0-points"] = 47 form_set = self.form_set_class( self.data, form_kwargs={"max_points": self.task.description_points} ) self.assertFalse(form_set.is_valid()) class ZIPUploadTests(TestCase): def setUp(self): year = timezone.now().year + 2 self.user1 = User.objects.create_user( username="TestUser1", password="password", first_name="Jozko", last_name="Mrkvicka", graduation=year, pk=1, ) self.staff = User.objects.create_user( username="TestStaff", password="password", first_name="Jozko", last_name="Veduci", graduation=2014, pk=2, ) self.staff.is_staff = True self.staff.save() group = Group.objects.create(name="Test Group") group.user_set.add(self.staff) competition = Competition.objects.create(name="TestCompetition", organizers_group=group) competition.sites.add(Site.objects.get(pk=settings.SITE_ID)) semester = Semester.objects.create( number=1, name="Test semester 1", year=1, competition=competition ) test_round = Round.objects.create( number=1, semester=semester, solutions_visible=True, visible=True, start_time=timezone.now() + timezone.timedelta(-4), end_time=timezone.now() + timezone.timedelta(-1), ) self.task = Task.objects.create( number=2, name="TestTask2", round=test_round, description_points=9 ) submit = Submit.objects.create( pk=1, task=self.task, user=self.user1, submit_type=submit_constants.SUBMIT_TYPE_DESCRIPTION, points=0, testing_status=submit_constants.SUBMIT_STATUS_IN_QUEUE, ) submit.time = test_round.end_time + timezone.timedelta(hours=-1) submit.save() def test_upload(self): self.client.force_login(self.staff) with open(path.join(path.dirname(__file__), "test_data", "zip_all.zip"), "rb") as zip: response = self.client.post( reverse("admin:review_task", kwargs={"task_pk": self.task.id}), {"Upload": "Upload", "file": zip}, follow=True, ) self.assertContains(response, "Super riesenie!") self.assertContains(response, "11") self.assertContains(response, "0123.pdf") self.assertNotContains(response, "Thumbs.db")
38.487073
113
0.625037
4,386
37,217
5.100319
0.078431
0.02861
0.031381
0.035673
0.84135
0.824721
0.812025
0.789763
0.775458
0.757667
0
0.012646
0.258457
37,217
966
114
38.526915
0.79792
0.012817
0
0.704276
0
0.002375
0.07716
0.012279
0
0
0
0.001035
0.087886
1
0.06057
false
0.015439
0.032067
0
0.10095
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
4557ecfd9097806ebda9fb7d86243f13bafec3a0
6,130
py
Python
tests/scripts/test_pkgcheck_show.py
floppym/pkgcheck
07215eac255a88b3a0c351f35626a1c79d9f2632
[ "BSD-3-Clause" ]
18
2015-04-24T23:15:30.000Z
2022-02-14T04:14:56.000Z
tests/scripts/test_pkgcheck_show.py
floppym/pkgcheck
07215eac255a88b3a0c351f35626a1c79d9f2632
[ "BSD-3-Clause" ]
351
2015-03-08T07:07:47.000Z
2022-03-21T11:57:58.000Z
tests/scripts/test_pkgcheck_show.py
floppym/pkgcheck
07215eac255a88b3a0c351f35626a1c79d9f2632
[ "BSD-3-Clause" ]
19
2015-03-08T01:16:10.000Z
2022-03-17T10:37:26.000Z
import itertools from functools import partial from unittest.mock import patch import pytest from pkgcheck import __title__ as project from pkgcheck import base, objects from pkgcheck.addons import caches from pkgcheck.scripts import run class TestPkgcheckShow: script = partial(run, project) @pytest.fixture(autouse=True) def _setup(self, testconfig): self.args = [project, '--config', testconfig, 'show'] def test_show_no_args(self, capsys): # defaults to outputting keywords list if no option is passed with patch('sys.argv', self.args): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') assert out == sorted(objects.KEYWORDS.keys()) assert excinfo.value.code == 0 def test_show_keywords(self, capsys): for arg in ('-k', '--keywords'): # regular mode with patch('sys.argv', self.args + [arg]): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') regular_output = out assert out == sorted(objects.KEYWORDS.keys()) assert excinfo.value.code == 0 # verbose mode with patch('sys.argv', self.args + [arg, '-v']): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') verbose_output = out assert excinfo.value.code == 0 # verbose output shows much more info assert len(regular_output) < len(verbose_output) def test_show_checks(self, capsys): for arg in ('-c', '--checks'): # regular mode with patch('sys.argv', self.args + [arg]): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') regular_output = out assert out == sorted(objects.CHECKS.keys()) assert excinfo.value.code == 0 # verbose mode with patch('sys.argv', self.args + [arg, '-v']): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') verbose_output = out assert excinfo.value.code == 0 # verbose output shows much more info assert len(regular_output) < len(verbose_output) def test_show_scopes(self, capsys): for arg in ('-s', '--scopes'): with patch('sys.argv', self.args + [arg]): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') assert out == list(base.scopes) assert excinfo.value.code == 0 regular_output = '\n'.join(itertools.chain(out)) # verbose mode with patch('sys.argv', self.args + [arg, '-v']): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') assert excinfo.value.code == 0 verbose_output = '\n'.join(itertools.chain(out)) # verbose output shows more info assert len(regular_output) < len(verbose_output) def test_show_reporters(self, capsys): for arg in ('-r', '--reporters'): # regular mode with patch('sys.argv', self.args + [arg]): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') regular_output = out assert out == sorted(objects.REPORTERS.keys()) assert excinfo.value.code == 0 # verbose mode with patch('sys.argv', self.args + [arg, '-v']): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') verbose_output = out assert excinfo.value.code == 0 # verbose output shows much more info assert len(regular_output) < len(verbose_output) def test_show_caches(self, capsys): for arg in ('-C', '--caches'): with patch('sys.argv', self.args + [arg]): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') cache_objs = caches.CachedAddon.caches.values() assert out == sorted(x.type for x in cache_objs) assert excinfo.value.code == 0 regular_output = '\n'.join(itertools.chain(out)) # verbose mode with patch('sys.argv', self.args + [arg, '-v']): with pytest.raises(SystemExit) as excinfo: self.script() out, err = capsys.readouterr() assert not err out = out.strip().split('\n') assert excinfo.value.code == 0 verbose_output = '\n'.join(itertools.chain(out)) # verbose output shows more info assert len(regular_output) < len(verbose_output)
38.553459
69
0.514845
652
6,130
4.779141
0.139571
0.06258
0.042362
0.056483
0.811617
0.794288
0.77439
0.77439
0.77439
0.77439
0
0.002877
0.376346
6,130
158
70
38.797468
0.812189
0.054323
0
0.756098
0
0
0.033725
0
0
0
0
0
0.268293
1
0.056911
false
0
0.065041
0
0.138211
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
b3447643bc55400e00274745b46d7ceb13d1e340
22,245
py
Python
semitorchclass.py
yuachen/CausalDA
5e376d209b6632b4920482db4bbe2727086ce133
[ "MIT" ]
15
2020-10-30T14:28:43.000Z
2022-03-30T07:12:59.000Z
semitorchclass.py
yuachen/CausalDA
5e376d209b6632b4920482db4bbe2727086ce133
[ "MIT" ]
2
2022-01-22T06:30:25.000Z
2022-02-10T03:07:00.000Z
semitorchclass.py
yuachen/CausalDA
5e376d209b6632b4920482db4bbe2727086ce133
[ "MIT" ]
null
null
null
""" ``semitorchclass`` provides classes implementing various domain adaptation methods using torch and gradient method. All domain adaptation methods have to be subclass of BaseEstimator. This implementation takes advantage of gradient method to optimize covariance match or MMD match in addition to mean match. """ from abc import abstractmethod import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import mmd # check gpu avail device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") # simple linear model in torch class LinearModel(nn.Module): def __init__(self, d): super(LinearModel, self).__init__() self.lin1 = nn.Linear(d, 1, bias=True) def forward(self, x): x = self.lin1(x) return x class BaseEstimator(): """Base class for domain adaptation""" @abstractmethod def fit(self, data, source, target): """Fit model. Arguments: data (dict of (X, y) pairs): maps env index to the (X, y) pair in that env source (list of indexes): indexes of source envs target (int): single index of the target env """ self.source = source self.target = target return self @abstractmethod def predict(self, X): """Use the learned estimator to predict labels on fresh target data X """ def __str__(self): """For easy name printing """ return self.__class__.__name__ class ZeroBeta(BaseEstimator): """Estimator that sets beta to zero""" def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) with torch.no_grad(): model.lin1.weight.data = torch.zeros_like(model.lin1.weight) model.lin1.bias.data = torch.zeros_like(model.lin1.bias) self.model = model xtar, _ = data[target] self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX class Tar(BaseEstimator): """Oracle Linear regression (with l1 or l2 penalty) trained on the target domain""" def __init__(self, lamL2=0.0, lamL1=0.0, lr=1e-4, epochs=10): self.lamL2 = lamL2 self.lamL1 = lamL1 self.lr = lr self.epochs = epochs def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) # torch.nn.init.kaiming_normal_(model.lin1.weight, mode='fan_in') torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) # opt = optim.SGD(model.parameters(), lr=self.lr, momentum=0.9) self.losses = np.zeros(self.epochs) xtar, ytar = data[target] # oracle estimator uses target labels for epoch in range(self.epochs): opt.zero_grad() loss = loss_fn(model(xtar), ytar.view(-1, 1)) + \ self.lamL2 * torch.sum(model.lin1.weight ** 2) + \ self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) # Perform gradient descent loss.backward() opt.step() self.losses[epoch] = loss.item() self.model = model self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX def __str__(self): return self.__class__.__name__ + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) class SrcPool(BaseEstimator): """Pool all source data together and then run linear regression with l1 or l2 penalty """ def __init__(self, lamL2=0.0, lamL1=0.0, lr=1e-4, epochs=10): self.lamL2 = lamL2 self.lamL1 = lamL1 self.lr = lr self.epochs = epochs def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) # custom initialization with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) # opt = optim.SGD(model.parameters(), lr=self.lr, momentum=0.9) self.losses = np.zeros(self.epochs) for epoch in range(self.epochs): loss = 0 opt.zero_grad() for m in source: x, y = data[m] loss += loss_fn(model(x), y.view(-1, 1))/len(source) loss += self.lamL2 * torch.sum(model.lin1.weight ** 2) loss += self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) # Perform gradient descent loss.backward() opt.step() self.losses[epoch] = loss.item() self.model = model xtar, _ = data[target] self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX def __str__(self): return self.__class__.__name__ + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) def wayMatchSelector(wayMatch='mean'): if wayMatch == 'mean': return [lambda x: torch.mean(x, dim=0)] elif wayMatch == 'std': return [lambda x: torch.std(x, dim=0)] elif wayMatch == '25p': return [lambda x: torch.kthvalue(x, (1 + round(.25 * (x.shape[0] - 1))), dim=0)] elif wayMatch == '75p': return [lambda x: torch.kthvalue(x, (1 + round(.75 * (x.shape[0] - 1))), dim=0)] elif wayMatch == 'mean+std': return [lambda x: torch.mean(x, dim=0), lambda x: torch.std(x, dim=0)] elif wayMatch == 'mean+std+25p': return [lambda x: torch.mean(x, dim=0), lambda x: torch.std(x, dim=0), lambda x: torch.kthvalue(x, (1 + round(.25 * (x.shape[0] - 1))), dim=0)[0]] elif wayMatch == 'mean+std+25p+75p': return [lambda x: torch.mean(x, dim=0), lambda x: torch.std(x, dim=0), lambda x: torch.kthvalue(x, (1 + round(.25 * (x.shape[0] - 1))), dim=0)[0], lambda x: torch.kthvalue(x, (1 + round(.75 * (x.shape[0] - 1))), dim=0)[0]] else: print("Error: wayMatch not specified correctly, using mean") return [lambda x: torch.mean(x, 0)] class DIP(BaseEstimator): """Pick one source, match mean of X * beta between source and target""" def __init__(self, lamMatch=10., lamL2=0., lamL1=0., sourceInd = 0, lr=1e-4, epochs=10, wayMatch='mean'): self.lamMatch = lamMatch self.lamL2 = lamL2 self.lamL1 = lamL1 self.sourceInd = sourceInd self.lr = lr self.epochs = epochs self.wayMatch = wayMatchSelector(wayMatch) def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) # custom initialization with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) self.losses = np.zeros(self.epochs) for epoch in range(self.epochs): x, y = data[source[self.sourceInd]] xtar, ytar = data[target] opt.zero_grad() loss = loss_fn(model(x), y.view(-1, 1)) + \ self.lamL2 * torch.sum(model.lin1.weight ** 2) + \ self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) for wayMatchLocal in self.wayMatch: loss += self.lamMatch * loss_fn(wayMatchLocal(model(x)), wayMatchLocal(model(xtar))) # Perform gradient descent loss.backward() opt.step() self.losses[epoch] = loss.item() self.model = model xtar, _ = data[target] self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX def __str__(self): return self.__class__.__name__ + "_Match{:.1f}".format(self.lamMatch) + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) class DIPOracle(BaseEstimator): """Pick one source, match mean of X * beta between source and target, use target labels to fit (oracle)""" def __init__(self, lamMatch=10., lamL2=0., lamL1=0., sourceInd = 0, lr=1e-4, epochs=10, wayMatch='mean'): self.lamMatch = lamMatch self.lamL2 = lamL2 self.lamL1 = lamL1 self.sourceInd = sourceInd self.lr = lr self.epochs = epochs self.wayMatch = wayMatchSelector(wayMatch) def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) # custom initialization with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) self.losses = np.zeros(self.epochs) for epoch in range(self.epochs): x, y = data[source[self.sourceInd]] xtar, ytar = data[target] opt.zero_grad() loss = loss_fn(model(xtar), ytar.view(-1, 1)) + \ self.lamL2 * torch.sum(model.lin1.weight ** 2) + \ self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) for wayMatchLocal in self.wayMatch: loss += self.lamMatch * loss_fn(wayMatchLocal(model(x)), wayMatchLocal(model(xtar))) # Perform gradient descent loss.backward() opt.step() self.losses[epoch] = loss.item() self.model = model xtar, _ = data[target] self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX def __str__(self): return self.__class__.__name__ + "_Match{:.1f}".format(self.lamMatch) + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) class DIPweigh(BaseEstimator): '''loop throught all source envs, match the mean of X * beta between source env i and target, weigh the final prediction based loss of env i''' def __init__(self, lamMatch=10., lamL2=0., lamL1=0., lr=1e-4, epochs=10, wayMatch='mean'): self.lamMatch = lamMatch self.lamL2 = lamL2 self.lamL1 = lamL1 self.lr = lr self.epochs = epochs self.wayMatch = wayMatchSelector(wayMatch) def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] models = {} diffs = {} ypreds = {} losses_all = {} for m in source: model = LinearModel(d).to(device) models[m] = model # custom initialization with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) losses_all[m] = np.zeros(self.epochs) for epoch in range(self.epochs): x, y = data[m] xtar, ytar = data[target] opt.zero_grad() loss = loss_fn(model(x), y.view(-1, 1)) + \ self.lamL2* torch.sum(model.lin1.weight ** 2) + \ self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) for wayMatchLocal in self.wayMatch: loss += self.lamMatch * loss_fn(wayMatchLocal(model(x)), wayMatchLocal(model(xtar))) # Perform gradient descent loss.backward() opt.step() losses_all[m][epoch] = loss.item() diffs[m] =0. for wayMatchLocal in self.wayMatch: diffs[m] += loss_fn(wayMatchLocal(model(x)), wayMatchLocal(model(xtar))) ypreds[m] = models[m](xtar) # take the min diff loss to be current best losses and model minDiff = diffs[source[0]] minDiffIndx = source[0] self.losses = losses_all[source[0]] for m in source: if diffs[m] < minDiff: minDiff = diffs[m] minDiffIndx = m self.losses = losses_all[m] self.model = models[m] self.minDiffIndx = minDiffIndx self.total_weight = 0 self.ypred = 0 for m in self.source: self.ypred += torch.exp(-100.*diffs[m]) * ypreds[m] self.total_weight += torch.exp(-100.*diffs[m]) self.ypred /= self.total_weight self.models = models self.diffs = diffs return self def predict(self, X): ypredX1 = 0 for m in self.source: ypredX1 += torch.exp(-100.*self.diffs[m]) * self.models[m](X) ypredX1 /= self.total_weight return ypredX1 def __str__(self): return self.__class__.__name__ + "_Match{:.1f}".format(self.lamMatch) + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) class CIP(BaseEstimator): """Match the conditional (on Y) mean of X * beta across source envs, no target env is needed""" def __init__(self, lamCIP=10., lamL2=0., lamL1=0., lr=1e-4, epochs=10, wayMatch='mean'): self.lamCIP = lamCIP self.lamL2 = lamL2 self.lamL1 = lamL1 self.lr = lr self.epochs = epochs self.wayMatch = wayMatchSelector(wayMatch) def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] model = LinearModel(d).to(device) # custom initialization with torch.no_grad(): model.lin1.bias.data = torch.zeros_like(model.lin1.bias) torch.nn.init.xavier_normal_(model.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(model.parameters(), lr=self.lr) self.losses = np.zeros(self.epochs) for epoch in range(self.epochs): loss = 0 avgmodelxList = [0.] * len(self.wayMatch) opt.zero_grad() for m in source: x, y = data[m] # do the conditional on y xmod = x - torch.mm(y.view(-1, 1), torch.mm(y.view(1, -1), x))/torch.sum(y**2) for i, wayMatchLocal in enumerate(self.wayMatch): avgmodelxList[i] += wayMatchLocal(model(xmod))/len(source) for m in source: x, y = data[m] xmod = x - torch.mm(y.view(-1, 1), torch.mm(y.view(1, -1), x))/torch.sum(y**2) loss += loss_fn(model(x), y.view(-1, 1))/len(source) for i, wayMatchLocal in enumerate(self.wayMatch): loss += self.lamCIP * loss_fn(avgmodelxList[i], wayMatchLocal(model(xmod)))/len(source) loss += self.lamL2 * torch.sum(model.lin1.weight ** 2) loss += self.lamL1 * torch.sum(torch.abs(model.lin1.weight)) # Perform gradient descent loss.backward() opt.step() self.losses[epoch] = loss.item() self.model = model xtar, _ = data[target] self.ypred = self.model(xtar) return self def predict(self, X): ypredX = self.model(X) return ypredX def __str__(self): return self.__class__.__name__ + "_CIP{:.1f}".format(self.lamCIP) + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1) class CIRMweigh(BaseEstimator): """Match the conditional (on Y) mean of X * beta across source envs, use Yhat as proxy of Y to remove the Y parts in X. Match on the residual between one source env and target env""" def __init__(self, lamMatch=10., lamL2=0., lamL1=0., lr=1e-4, epochs=10, wayMatch='mean'): self.lamMatch = lamMatch self.lamL2 = lamL2 self.lamL1 = lamL1 self.lr = lr self.epochs = epochs self.wayMatch = wayMatchSelector(wayMatch) def fit(self, data, source, target): super().fit(data, source, target) d = data[target][0].shape[1] # Step 1: use source envs to match the conditional mean # find beta_invariant models1 = LinearModel(d).to(device) # custom initialization with torch.no_grad(): models1.lin1.bias.data = torch.zeros_like(models1.lin1.bias) torch.nn.init.xavier_normal_(models1.lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(models1.parameters(), lr=self.lr) losses1 = np.zeros(self.epochs) for epoch in range(self.epochs): loss = 0 avgmodelxList = [0.] * len(self.wayMatch) opt.zero_grad() for m in source: x, y = data[m] # do the conditional on y xmod = x - torch.mm(y.view(-1, 1), torch.mm(y.view(1, -1), x))/torch.sum(y**2) for i, wayMatchLocal in enumerate(self.wayMatch): avgmodelxList[i] += wayMatchLocal(models1(xmod))/len(source) for m in source: x, y = data[m] xmod = x - torch.mm(y.view(-1, 1), torch.mm(y.view(1, -1), x))/torch.sum(y**2) loss += loss_fn(models1(x), y.view(-1, 1))/len(source) for i, wayMatchLocal in enumerate(self.wayMatch): loss += self.lamMatch * loss_fn(avgmodelxList[i], wayMatchLocal(models1(xmod)))/len(source) loss += self.lamL2 * torch.sum(models1.lin1.weight ** 2) loss += self.lamL1 * torch.sum(torch.abs(models1.lin1.weight)) # Perform gradient descent loss.backward() opt.step() losses1[epoch] = loss.item() self.models1 = models1 # fix grads now for param in models1.lin1.parameters(): param.requires_grad = False # Step 2: remove the invariant part on all source envs, so that everything is independent of Y # get that coefficient b YsrcMean = 0 ntotal = 0 for m in source: YsrcMean += torch.sum(data[m][1]) ntotal += data[m][1].shape[0] YsrcMean /= ntotal YTX = 0 YTY = 0 for m in source: x, y = data[m] yguess = self.models1(x) yCentered = y - YsrcMean YTY += torch.sum(yguess.t() * yCentered) YTX += torch.mm(yCentered.view(1, -1), x) b = YTX / YTY self.b = b # Step 3: mean match between source and target on the residual, after transforming the covariates X - (X * beta_invariant) * b_invariant models = {} diffs = {} ypreds = {} losses_all = {} for m in source: models[m] = LinearModel(d).to(device) # custom initialization with torch.no_grad(): models[m].lin1.bias.data = torch.zeros_like(models[m].lin1.bias) torch.nn.init.xavier_normal_(models[m].lin1.weight, gain=0.01) # Define loss function loss_fn = F.mse_loss opt = optim.Adam(models[m].parameters(), lr=self.lr) losses_all[m] = np.zeros(self.epochs) x, y = data[m] xmod = x - torch.mm(self.models1(x), b) xtar, ytar = data[target] xtarmod = xtar - torch.mm(self.models1(xtar), b) for epoch in range(self.epochs): loss = loss_fn(models[m](x), y.view(-1, 1)) + \ self.lamL2 * torch.sum(models[m].lin1.weight ** 2) + \ self.lamL1 * torch.sum(torch.abs(models[m].lin1.weight)) for wayMatchLocal in self.wayMatch: loss += self.lamMatch * loss_fn(wayMatchLocal(models[m](xmod)), wayMatchLocal(models[m](xtarmod))) # Perform gradient descent loss.backward() opt.step() opt.zero_grad() losses_all[m][epoch] = loss.item() diffs[m] = 0. for wayMatchLocal in self.wayMatch: diffs[m] += loss_fn(wayMatchLocal(models[m](xmod)), wayMatchLocal(models[m](xtarmod))) ypreds[m] = models[m](xtar) # take the min diff loss to be current best losses and model minDiff = diffs[source[0]] minDiffIndx = source[0] self.losses = losses_all[source[0]] for m in source: if diffs[m] < minDiff: minDiff = diffs[m] minDiffIndx = m self.losses = losses_all[m] self.model = models[m] self.minDiffIndx = minDiffIndx self.total_weight = 0 self.ypred = 0 for m in self.source: self.ypred += torch.exp(-100.*diffs[m]) * ypreds[m] self.total_weight += torch.exp(-100.*diffs[m]) self.ypred /= self.total_weight self.models = models self.diffs = diffs return self def predict(self, X): ypredX1 = 0 for m in self.source: ypredX1 += torch.exp(-100.*self.diffs[m]) * self.models[m](X) ypredX1 /= self.total_weight return ypredX1 def __str__(self): return self.__class__.__name__ + "_Match{:.1f}".format(self.lamMatch) + "_L2={:.1f}".format(self.lamL2) + "_L1={:.1f}".format(self.lamL1)
35.936995
154
0.567139
2,874
22,245
4.300278
0.092902
0.025488
0.025488
0.007929
0.805729
0.79966
0.783963
0.757909
0.744397
0.725625
0
0.027882
0.303484
22,245
618
155
35.995146
0.769782
0.122095
0
0.782609
0
0
0.01709
0
0
0
0
0
0
1
0.08238
false
0
0.016018
0.016018
0.199085
0.002288
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
2fd70f35f3a2ab4727a44f5561b1b6228f9347b9
60
py
Python
tests/test_ttarray.py
sonnerm/ttarray
c962cb2be303dfdb6743aa802bd11b89043e7b71
[ "MIT" ]
null
null
null
tests/test_ttarray.py
sonnerm/ttarray
c962cb2be303dfdb6743aa802bd11b89043e7b71
[ "MIT" ]
null
null
null
tests/test_ttarray.py
sonnerm/ttarray
c962cb2be303dfdb6743aa802bd11b89043e7b71
[ "MIT" ]
null
null
null
import pytest import ttarray def test_something(): pass
12
21
0.766667
8
60
5.625
0.875
0
0
0
0
0
0
0
0
0
0
0
0.183333
60
4
22
15
0.918367
0
0
0
0
0
0
0
0
0
0
0
0
1
0.25
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
1
1
1
1
0
1
0
0
7
6406f8cbda6175caa1a4d0f74f58b756f7d28f22
6,821
py
Python
loldib/getratings/models/NA/na_kassadin/na_kassadin_bot.py
koliupy/loldib
c9ab94deb07213cdc42b5a7c26467cdafaf81b7f
[ "Apache-2.0" ]
null
null
null
loldib/getratings/models/NA/na_kassadin/na_kassadin_bot.py
koliupy/loldib
c9ab94deb07213cdc42b5a7c26467cdafaf81b7f
[ "Apache-2.0" ]
null
null
null
loldib/getratings/models/NA/na_kassadin/na_kassadin_bot.py
koliupy/loldib
c9ab94deb07213cdc42b5a7c26467cdafaf81b7f
[ "Apache-2.0" ]
null
null
null
from getratings.models.ratings import Ratings class NA_Kassadin_Bot_Aatrox(Ratings): pass class NA_Kassadin_Bot_Ahri(Ratings): pass class NA_Kassadin_Bot_Akali(Ratings): pass class NA_Kassadin_Bot_Alistar(Ratings): pass class NA_Kassadin_Bot_Amumu(Ratings): pass class NA_Kassadin_Bot_Anivia(Ratings): pass class NA_Kassadin_Bot_Annie(Ratings): pass class NA_Kassadin_Bot_Ashe(Ratings): pass class NA_Kassadin_Bot_AurelionSol(Ratings): pass class NA_Kassadin_Bot_Azir(Ratings): pass class NA_Kassadin_Bot_Bard(Ratings): pass class NA_Kassadin_Bot_Blitzcrank(Ratings): pass class NA_Kassadin_Bot_Brand(Ratings): pass class NA_Kassadin_Bot_Braum(Ratings): pass class NA_Kassadin_Bot_Caitlyn(Ratings): pass class NA_Kassadin_Bot_Camille(Ratings): pass class NA_Kassadin_Bot_Cassiopeia(Ratings): pass class NA_Kassadin_Bot_Chogath(Ratings): pass class NA_Kassadin_Bot_Corki(Ratings): pass class NA_Kassadin_Bot_Darius(Ratings): pass class NA_Kassadin_Bot_Diana(Ratings): pass class NA_Kassadin_Bot_Draven(Ratings): pass class NA_Kassadin_Bot_DrMundo(Ratings): pass class NA_Kassadin_Bot_Ekko(Ratings): pass class NA_Kassadin_Bot_Elise(Ratings): pass class NA_Kassadin_Bot_Evelynn(Ratings): pass class NA_Kassadin_Bot_Ezreal(Ratings): pass class NA_Kassadin_Bot_Fiddlesticks(Ratings): pass class NA_Kassadin_Bot_Fiora(Ratings): pass class NA_Kassadin_Bot_Fizz(Ratings): pass class NA_Kassadin_Bot_Galio(Ratings): pass class NA_Kassadin_Bot_Gangplank(Ratings): pass class NA_Kassadin_Bot_Garen(Ratings): pass class NA_Kassadin_Bot_Gnar(Ratings): pass class NA_Kassadin_Bot_Gragas(Ratings): pass class NA_Kassadin_Bot_Graves(Ratings): pass class NA_Kassadin_Bot_Hecarim(Ratings): pass class NA_Kassadin_Bot_Heimerdinger(Ratings): pass class NA_Kassadin_Bot_Illaoi(Ratings): pass class NA_Kassadin_Bot_Irelia(Ratings): pass class NA_Kassadin_Bot_Ivern(Ratings): pass class NA_Kassadin_Bot_Janna(Ratings): pass class NA_Kassadin_Bot_JarvanIV(Ratings): pass class NA_Kassadin_Bot_Jax(Ratings): pass class NA_Kassadin_Bot_Jayce(Ratings): pass class NA_Kassadin_Bot_Jhin(Ratings): pass class NA_Kassadin_Bot_Jinx(Ratings): pass class NA_Kassadin_Bot_Kalista(Ratings): pass class NA_Kassadin_Bot_Karma(Ratings): pass class NA_Kassadin_Bot_Karthus(Ratings): pass class NA_Kassadin_Bot_Kassadin(Ratings): pass class NA_Kassadin_Bot_Katarina(Ratings): pass class NA_Kassadin_Bot_Kayle(Ratings): pass class NA_Kassadin_Bot_Kayn(Ratings): pass class NA_Kassadin_Bot_Kennen(Ratings): pass class NA_Kassadin_Bot_Khazix(Ratings): pass class NA_Kassadin_Bot_Kindred(Ratings): pass class NA_Kassadin_Bot_Kled(Ratings): pass class NA_Kassadin_Bot_KogMaw(Ratings): pass class NA_Kassadin_Bot_Leblanc(Ratings): pass class NA_Kassadin_Bot_LeeSin(Ratings): pass class NA_Kassadin_Bot_Leona(Ratings): pass class NA_Kassadin_Bot_Lissandra(Ratings): pass class NA_Kassadin_Bot_Lucian(Ratings): pass class NA_Kassadin_Bot_Lulu(Ratings): pass class NA_Kassadin_Bot_Lux(Ratings): pass class NA_Kassadin_Bot_Malphite(Ratings): pass class NA_Kassadin_Bot_Malzahar(Ratings): pass class NA_Kassadin_Bot_Maokai(Ratings): pass class NA_Kassadin_Bot_MasterYi(Ratings): pass class NA_Kassadin_Bot_MissFortune(Ratings): pass class NA_Kassadin_Bot_MonkeyKing(Ratings): pass class NA_Kassadin_Bot_Mordekaiser(Ratings): pass class NA_Kassadin_Bot_Morgana(Ratings): pass class NA_Kassadin_Bot_Nami(Ratings): pass class NA_Kassadin_Bot_Nasus(Ratings): pass class NA_Kassadin_Bot_Nautilus(Ratings): pass class NA_Kassadin_Bot_Nidalee(Ratings): pass class NA_Kassadin_Bot_Nocturne(Ratings): pass class NA_Kassadin_Bot_Nunu(Ratings): pass class NA_Kassadin_Bot_Olaf(Ratings): pass class NA_Kassadin_Bot_Orianna(Ratings): pass class NA_Kassadin_Bot_Ornn(Ratings): pass class NA_Kassadin_Bot_Pantheon(Ratings): pass class NA_Kassadin_Bot_Poppy(Ratings): pass class NA_Kassadin_Bot_Quinn(Ratings): pass class NA_Kassadin_Bot_Rakan(Ratings): pass class NA_Kassadin_Bot_Rammus(Ratings): pass class NA_Kassadin_Bot_RekSai(Ratings): pass class NA_Kassadin_Bot_Renekton(Ratings): pass class NA_Kassadin_Bot_Rengar(Ratings): pass class NA_Kassadin_Bot_Riven(Ratings): pass class NA_Kassadin_Bot_Rumble(Ratings): pass class NA_Kassadin_Bot_Ryze(Ratings): pass class NA_Kassadin_Bot_Sejuani(Ratings): pass class NA_Kassadin_Bot_Shaco(Ratings): pass class NA_Kassadin_Bot_Shen(Ratings): pass class NA_Kassadin_Bot_Shyvana(Ratings): pass class NA_Kassadin_Bot_Singed(Ratings): pass class NA_Kassadin_Bot_Sion(Ratings): pass class NA_Kassadin_Bot_Sivir(Ratings): pass class NA_Kassadin_Bot_Skarner(Ratings): pass class NA_Kassadin_Bot_Sona(Ratings): pass class NA_Kassadin_Bot_Soraka(Ratings): pass class NA_Kassadin_Bot_Swain(Ratings): pass class NA_Kassadin_Bot_Syndra(Ratings): pass class NA_Kassadin_Bot_TahmKench(Ratings): pass class NA_Kassadin_Bot_Taliyah(Ratings): pass class NA_Kassadin_Bot_Talon(Ratings): pass class NA_Kassadin_Bot_Taric(Ratings): pass class NA_Kassadin_Bot_Teemo(Ratings): pass class NA_Kassadin_Bot_Thresh(Ratings): pass class NA_Kassadin_Bot_Tristana(Ratings): pass class NA_Kassadin_Bot_Trundle(Ratings): pass class NA_Kassadin_Bot_Tryndamere(Ratings): pass class NA_Kassadin_Bot_TwistedFate(Ratings): pass class NA_Kassadin_Bot_Twitch(Ratings): pass class NA_Kassadin_Bot_Udyr(Ratings): pass class NA_Kassadin_Bot_Urgot(Ratings): pass class NA_Kassadin_Bot_Varus(Ratings): pass class NA_Kassadin_Bot_Vayne(Ratings): pass class NA_Kassadin_Bot_Veigar(Ratings): pass class NA_Kassadin_Bot_Velkoz(Ratings): pass class NA_Kassadin_Bot_Vi(Ratings): pass class NA_Kassadin_Bot_Viktor(Ratings): pass class NA_Kassadin_Bot_Vladimir(Ratings): pass class NA_Kassadin_Bot_Volibear(Ratings): pass class NA_Kassadin_Bot_Warwick(Ratings): pass class NA_Kassadin_Bot_Xayah(Ratings): pass class NA_Kassadin_Bot_Xerath(Ratings): pass class NA_Kassadin_Bot_XinZhao(Ratings): pass class NA_Kassadin_Bot_Yasuo(Ratings): pass class NA_Kassadin_Bot_Yorick(Ratings): pass class NA_Kassadin_Bot_Zac(Ratings): pass class NA_Kassadin_Bot_Zed(Ratings): pass class NA_Kassadin_Bot_Ziggs(Ratings): pass class NA_Kassadin_Bot_Zilean(Ratings): pass class NA_Kassadin_Bot_Zyra(Ratings): pass
16.357314
46
0.776133
972
6,821
5.020576
0.151235
0.197951
0.42418
0.509016
0.814139
0.814139
0
0
0
0
0
0
0.162879
6,821
416
47
16.396635
0.854641
0
0
0.498195
0
0
0
0
0
0
0
0
0
1
0
true
0.498195
0.00361
0
0.501805
0
0
0
0
null
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
1
0
0
1
0
0
7
640eb87ae946b66624c83e81f7a7d4c8a6f75cbd
6,996
py
Python
src/styles.py
topher-lo/simple-data-flow
b921037c5ef7f65533953d17ab4be9153a3e19a3
[ "MIT" ]
7
2021-05-04T13:28:49.000Z
2022-03-26T10:18:06.000Z
src/styles.py
topher-lo/simple-data-flow
b921037c5ef7f65533953d17ab4be9153a3e19a3
[ "MIT" ]
null
null
null
src/styles.py
topher-lo/simple-data-flow
b921037c5ef7f65533953d17ab4be9153a3e19a3
[ "MIT" ]
1
2021-05-17T09:16:30.000Z
2021-05-17T09:16:30.000Z
"""Code for custom Altair themes. Available themes: - streamlit -- matches theme in Streamlit website - ggplot2 -- hybrid between Streamlit's and ggplot2's themes. """ def streamlit_theme(): font = "IBM Plex Mono" primary_color = "#F63366" font_color = "#262730" grey_color = "#f0f2f6" base_size = 16 lg_font = base_size * 1.25 sm_font = base_size * 0.8 # st.table size xl_font = base_size * 1.75 # noqa config = { "config": { "arc": {"fill": primary_color}, "area": {"fill": primary_color}, "circle": {"fill": primary_color, "stroke": font_color, "strokeWidth": 0.5}, "line": {"stroke": primary_color}, "path": {"stroke": primary_color}, "point": {"stroke": primary_color}, "rect": {"fill": primary_color}, "shape": {"stroke": primary_color}, "symbol": {"fill": primary_color}, "title": { "font": font, "color": font_color, "fontSize": lg_font, "anchor": "start", }, "axis": { "titleFont": font, "titleColor": font_color, "titleFontSize": sm_font, "labelFont": font, "labelColor": font_color, "labelFontSize": sm_font, "gridColor": grey_color, "domainColor": font_color, "tickColor": "#fff", }, "header": { "labelFont": font, "titleFont": font, "labelFontSize": base_size, "titleFontSize": base_size, }, "legend": { "titleFont": font, "titleColor": font_color, "titleFontSize": sm_font, "labelFont": font, "labelColor": font_color, "labelFontSize": sm_font, }, "range": { "category": ["#f63366", "#fffd80", "#0068c9", "#ff2b2b", "#09ab3b"], "diverging": [ "#850018", "#cd1549", "#f6618d", "#fbafc4", "#f5f5f5", "#93c5fe", "#5091e6", "#1d5ebd", "#002f84", ], "heatmap": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], "ramp": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], "ordinal": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], }, } } return config def ggplot2_theme(): font = "IBM Plex Mono" primary_color = "#F63366" font_color = "#262730" grey_color = "#f0f2f6" base_size = 16 lg_font = base_size * 1.25 sm_font = base_size * 0.8 # st.table size xl_font = base_size * 1.75 # noqa config = { "config": { "view": {"fill": grey_color}, "arc": {"fill": primary_color}, "area": {"fill": primary_color}, "circle": {"fill": primary_color, "stroke": font_color, "strokeWidth": 0.5}, "line": {"stroke": primary_color}, "path": {"stroke": primary_color}, "point": {"stroke": primary_color}, "rect": {"fill": primary_color}, "shape": {"stroke": primary_color}, "symbol": {"fill": primary_color}, "title": { "font": font, "color": font_color, "fontSize": lg_font, "anchor": "start", }, "axis": { "titleFont": font, "titleColor": font_color, "titleFontSize": sm_font, "labelFont": font, "labelColor": font_color, "labelFontSize": sm_font, "grid": True, "gridColor": "#fff", "gridOpacity": 1, "domain": False, # "domainColor": font_color, "tickColor": font_color, }, "header": { "labelFont": font, "titleFont": font, "labelFontSize": base_size, "titleFontSize": base_size, }, "legend": { "titleFont": font, "titleColor": font_color, "titleFontSize": sm_font, "labelFont": font, "labelColor": font_color, "labelFontSize": sm_font, }, "range": { "category": ["#f63366", "#fffd80", "#0068c9", "#ff2b2b", "#09ab3b"], "diverging": [ "#850018", "#cd1549", "#f6618d", "#fbafc4", "#f5f5f5", "#93c5fe", "#5091e6", "#1d5ebd", "#002f84", ], "heatmap": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], "ramp": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], "ordinal": [ "#ffb5d4", "#ff97b8", "#ff7499", "#fc4c78", "#ec245f", "#d2004b", "#b10034", "#91001f", "#720008", ], }, } } return config if __name__ == "__main__": pass
30.819383
84
0.345483
432
6,996
5.412037
0.256944
0.102652
0.068435
0.061591
0.867408
0.867408
0.867408
0.867408
0.867408
0.867408
0
0.108961
0.519869
6,996
226
85
30.955752
0.587079
0.032447
0
0.872038
0
0
0.217816
0
0
0
0
0
0
1
0.009479
false
0.004739
0
0
0.018957
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
ff42a6ba8f96b677781f8a10c6c80c4b4f62f230
1,452
py
Python
examples/op_mode.py
thechenderson/bme68x-python-library
ba3d0235509487e7c556887d5e96e669130b1150
[ "MIT" ]
null
null
null
examples/op_mode.py
thechenderson/bme68x-python-library
ba3d0235509487e7c556887d5e96e669130b1150
[ "MIT" ]
null
null
null
examples/op_mode.py
thechenderson/bme68x-python-library
ba3d0235509487e7c556887d5e96e669130b1150
[ "MIT" ]
null
null
null
# This example tests and demonstrates the operation modes # FORCED_MODE, PARALLEL_MODE and SEQUENTIAL_MODE # Without use of BSEC and # With use of BSEC from bme68x import BME68X import bme68xConstants as cnst import bsecConstants as bsec temp_prof = [320, 100, 100, 100, 200, 200, 200, 320, 320, 320] dur_prof = [5, 2, 10, 30, 5, 5, 5, 5, 5, 5] print('TEST W/O BSEC') sensor = BME68X(cnst.BME68X_I2C_ADDR_HIGH, bsec.BSEC_DISABLE) print('\nFORCED MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, 320, 100, cnst.BME68X_FORCED_MODE)) print(sensor.get_data()) print('\nPARALLEL MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, temp_prof, dur_prof, cnst.BME68X_PARALLEL_MODE)) print(sensor.get_data()) print('\nSEQUENTIAL MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, temp_prof, dur_prof, cnst.BME68X_SEQUENTIAL_MODE)) print(sensor.get_data()) print('\n\nDATA WITH BSEC') sensor = BME68X(cnst.BME68X_I2C_ADDR_HIGH, bsec.BSEC_ENABLE) print('\nSEQUENTIAL MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, temp_prof, dur_prof, cnst.BME68X_SEQUENTIAL_MODE)) print(sensor.get_bsec_data()) print('\nPARALLEL MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, temp_prof, dur_prof, cnst.BME68X_PARALLEL_MODE)) print(sensor.get_bsec_data()) print('\nFORCED MODE TEST') print(sensor.set_heatr_conf(cnst.BME68X_ENABLE, 320, 100, cnst.BME68X_FORCED_MODE)) print(sensor.get_bsec_data())
36.3
83
0.777548
233
1,452
4.587983
0.23176
0.130964
0.072965
0.106642
0.739944
0.734331
0.714687
0.703461
0.703461
0.703461
0
0.072252
0.103994
1,452
39
84
37.230769
0.749424
0.098485
0
0.709677
0
0
0.115798
0
0
0
0
0
0
1
0
false
0
0.096774
0
0.096774
0.645161
0
0
0
null
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
7
ff76b4776ef37641df5ab7a9f43722dbf428457a
97
py
Python
libcsbuild/__init__.py
Suresoft-GLaDOS/cxbuild
1eb568bc11ae8854b1a6025c969ec94c96d6a4a9
[ "MIT" ]
2
2021-11-01T02:11:59.000Z
2021-11-04T09:19:45.000Z
libcsbuild/__init__.py
HansolChoe/cxbuild
c289e40efdf92f34e7781772b3b84e0a1c7d0af2
[ "MIT" ]
3
2021-11-04T06:23:38.000Z
2021-11-19T01:54:05.000Z
libcsbuild/__init__.py
HansolChoe/cxbuild
c289e40efdf92f34e7781772b3b84e0a1c7d0af2
[ "MIT" ]
2
2021-11-01T03:01:28.000Z
2021-11-04T09:19:28.000Z
from libcsbuild.variable import * from libcsbuild.console import * from libcsbuild.Args import *
24.25
33
0.814433
12
97
6.583333
0.5
0.531646
0.506329
0
0
0
0
0
0
0
0
0
0.123711
97
3
34
32.333333
0.929412
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
ff861e0535b060a27cbec23c0e99677ed389b40c
14,083
py
Python
deltaRNN.py
cr7anand/neural_temporal_models
0b72be14e1fba0ed681322994e09116496ff19e8
[ "MIT" ]
20
2019-07-05T09:27:20.000Z
2022-03-28T06:36:10.000Z
deltaRNN.py
cr7anand/neural_temporal_models
0b72be14e1fba0ed681322994e09116496ff19e8
[ "MIT" ]
4
2019-10-09T15:37:53.000Z
2020-05-26T08:24:02.000Z
deltaRNN.py
cr7anand/neural_temporal_models
0b72be14e1fba0ed681322994e09116496ff19e8
[ "MIT" ]
3
2020-04-27T07:56:01.000Z
2022-01-25T09:37:59.000Z
#""" #Author :- Ankur Mali #""" import os import sys import tensorflow as tf import numpy as np #from tensorflow.python.ops.rnn_cell import RNNCell #from rnn_cell_impl import RNNCell from rnn_cell_implement import RNNCell class DeltaRNNCell(RNNCell): #""" #Delta RNN - Differential Framework. #Alexander G. Ororbia II, Tomas Mikolov and David Reitter, #"Learning Simpler Language Models with the # Delta Recurrent Neural Network Framework" #""" def __init__(self, num_units, apply_layer_norm=False): self._num_units = num_units self._apply_layer_norm = apply_layer_norm if self._apply_layer_norm: self._layer_norm = tf.contrib.layers.layer_norm @property def input_size(self): return self._num_units @property def output_size(self): return self._num_units @property def state_size(self): return self._num_units def _outer_function(self, inner_function_output, past_hidden_state, activation=tf.nn.relu, wx_parameterization_gate=True, scope=None): #"""Check Equation 3 in Delta RNN paper # for basic understanding and to relate our code with papers maths. #""" assert inner_function_output.get_shape().as_list() == \ past_hidden_state.get_shape().as_list() with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("OuterFunction"): r_bias = tf.get_variable( "outer_function_gate", [self._num_units], dtype=tf.float32, initializer=tf.zeros_initializer) # Equation 5 in Alex(DRNN paper) if wx_parameterization_gate: r = self._W_x_inputs + r_bias else: r = r_bias gate = tf.nn.sigmoid(r) output = activation((1.0 - gate) * inner_function_output + gate * past_hidden_state) return output # End of outer function # Inner function def _inner_function(self, inputs, past_hidden_state, activation=tf.nn.tanh, scope=None): #second order function as described equation 11 in delta rnn paper #This is used in inner function with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("InnerFunction"): with tf.variable_scope("Vh"): V_h = _linear(past_hidden_state, self._num_units, True) with tf.variable_scope("Wx"): self._W_x_inputs = _linear(inputs, self._num_units, True) alpha = tf.get_variable( "alpha", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(2.0)) # alpha value 2.0 works better than 1.0 beta_one = tf.get_variable( "beta_one", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) beta_two = tf.get_variable( "beta_two", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) z_t_bias = tf.get_variable( "z_t_bias", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(0.0)) # 2nd order calculation #You can change activation function but before get familiar with gating operations and mathematical notations d_1_t = alpha * V_h * self._W_x_inputs d_2_t = beta_one * V_h + beta_two * self._W_x_inputs if self._apply_layer_norm: d_1_t = self._layer_norm(d_1_t) d_2_t = self._layer_norm(d_2_t) z_t = activation(d_1_t + d_2_t + z_t_bias) return z_t def __call__(self, inputs, state, scope=None): inner_function_output = self._inner_function(inputs, state) output = self._outer_function(inner_function_output, state) return output, output class DeltaRNNCellBody(RNNCell): # #Delta RNN - Differential Framework. #Alexander G. Ororbia II, Tomas Mikolov and David Reitter, #"Learning Simpler Language Models with the # Delta Recurrent Neural Network Framework" #""" def __init__(self, num_units, apply_layer_norm=False): self._num_units = num_units self._apply_layer_norm = apply_layer_norm if self._apply_layer_norm: self._layer_norm = tf.contrib.layers.layer_norm @property def input_size(self): return self._num_units @property def output_size(self): return self._num_units @property def state_size(self): return self._num_units def _outer_function(self, inner_function_output, past_hidden_state, activation=tf.nn.relu, wx_parameterization_gate=True, scope=None): #"""Check Equation 3 in Delta RNN paper # for basic understanding and to relate our code with papers maths. #""" assert inner_function_output.get_shape().as_list() == \ past_hidden_state.get_shape().as_list() with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("OuterFunction"): r_bias = tf.get_variable( "outer_function_gate", [self._num_units], dtype=tf.float32, initializer=tf.zeros_initializer) # Equation 5 in Alex(DRNN paper) if wx_parameterization_gate: r = self._W_x_inputs + r_bias else: r = r_bias gate = tf.nn.sigmoid(r) output = activation((1.0 - gate) * inner_function_output + gate * past_hidden_state) return output # """ End of outer function """ # """ Inner function """ def _inner_function(self, inputs, past_hidden_state, context, activation=tf.nn.tanh, scope=None): # modified #"""second order function as described equation 11 in delta rnn paper #This is used in inner function #""" with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("InnerFunction"): with tf.variable_scope("Vh"): V_h = _linear(past_hidden_state, self._num_units, True) with tf.variable_scope("Qm"): # modified Q_m = _linear(context, self._num_units, True) with tf.variable_scope("Wx"): self._W_x_inputs = _linear(inputs, self._num_units, True) alpha = tf.get_variable( "alpha", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(2.0)) #""" alpha value 2.0 works better than 1.0""" beta_one = tf.get_variable( "beta_one", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) beta_two = tf.get_variable( "beta_two", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) z_t_bias = tf.get_variable( "z_t_bias", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(0.0)) # 2nd order calculation #You can change activation function but before get familiar with gating operations and mathematical notations d_1_t = alpha * V_h * ( self._W_x_inputs + Q_m ) # modified d_2_t = beta_one * V_h + beta_two * ( self._W_x_inputs + Q_m ) # modified if self._apply_layer_norm: d_1_t = self._layer_norm(d_1_t) d_2_t = self._layer_norm(d_2_t) z_t = activation(d_1_t + d_2_t + z_t_bias) return z_t def __call__(self, inputs, state, context, scope=None): inner_function_output = self._inner_function(inputs, state, context) output = self._outer_function(inner_function_output, state) return output, output class DeltaRNNCellBodyFlow(RNNCell): # #Delta RNN - Differential Framework. #Alexander G. Ororbia II, Tomas Mikolov and David Reitter, #"Learning Simpler Language Models with the # Delta Recurrent Neural Network Framework" #""" def __init__(self, num_units, apply_layer_norm=False): self._num_units = num_units self._apply_layer_norm = apply_layer_norm if self._apply_layer_norm: self._layer_norm = tf.contrib.layers.layer_norm @property def input_size(self): return self._num_units @property def output_size(self): return self._num_units @property def state_size(self): return self._num_units def _outer_function(self, inputs, inner_function_output, past_hidden_state, activation=tf.nn.relu, wx_parameterization_gate=True, scope=None): #"""Check Equation 3 in Delta RNN paper # for basic understanding and to relate our code with papers maths. #""" assert inner_function_output.get_shape().as_list() == \ past_hidden_state.get_shape().as_list() with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("OuterFunction"): r_bias = tf.get_variable("outer_function_vel_bias", [self._num_units], dtype=tf.float32, initializer=tf.zeros_initializer) W_vel = tf.get_variable("outer_function_W_vel", [54, self._num_units ], dtype=tf.float32, initializer=tf.contrib.layers.xavier_initializer()) # Equation 5 in Alex(DRNN paper) if wx_parameterization_gate: #r = self._W_x_inputs + r_bias r = tf.matmul(inputs[:,54:108], W_vel) + r_bias # modified else: r = r_bias gate = tf.nn.sigmoid(r) output = activation((1.0 - gate) * inner_function_output + gate * past_hidden_state) return output # """ End of outer function """ # """ Inner function """ def _inner_function(self, inputs, past_hidden_state, context, activation=tf.nn.tanh, scope=None): # modified #"""second order function as described equation 11 in delta rnn paper #This is used in inner function #""" with tf.variable_scope(scope or type(self).__name__): with tf.variable_scope("InnerFunction"): with tf.variable_scope("Vh"): V_h = _linear(past_hidden_state, self._num_units, True) with tf.variable_scope("Qm"): # modified Q_m = _linear(context, self._num_units, True) with tf.variable_scope("Wx"): self._W_x_inputs = _linear(inputs[:,0:54], self._num_units, True) alpha = tf.get_variable( "alpha", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(2.0)) #""" alpha value 2.0 works better than 1.0""" beta_one = tf.get_variable( "beta_one", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) beta_two = tf.get_variable( "beta_two", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(1.0)) z_t_bias = tf.get_variable( "z_t_bias", [self._num_units], dtype=tf.float32, initializer=tf.constant_initializer(0.0)) # 2nd order calculation #You can change activation function but before get familiar with gating operations and mathematical notations d_1_t = alpha * V_h * ( self._W_x_inputs + Q_m ) # modified d_2_t = beta_one * V_h + beta_two * ( self._W_x_inputs + Q_m ) # modified if self._apply_layer_norm: d_1_t = self._layer_norm(d_1_t) d_2_t = self._layer_norm(d_2_t) z_t = activation(d_1_t + d_2_t + z_t_bias) return z_t def __call__(self, inputs, state, context, scope=None): inner_function_output = self._inner_function(inputs, state, context) output = self._outer_function(inputs, inner_function_output, state) return output, output def _linear(args, output_size, bias, bias_start=0.0, scope=None): #"""Linear mapping """ if args is None or (isinstance(args, (list, tuple)) and not args): raise ValueError("`args` must be specified, please check definition for input variables") if not isinstance(args, (list, tuple)): args = [args] # dimension 1 cell size calculation. total_arg_size = 0 shapes = [a.get_shape().as_list() for a in args] for shape in shapes: if len(shape) != 2: raise ValueError( "Linear is expecting 2Dimensional Arguments: %s" % str(shapes)) if not shape[1]: raise ValueError( "Linear expects shape[1] of arguments: %s" % str(shapes)) else: total_arg_size += shape[1] with tf.variable_scope(scope or "Linear"): matrix = tf.get_variable("Matrix", [total_arg_size, output_size]) if len(args) == 1: res = tf.matmul(args[0], matrix) else: res = tf.matmul(tf.concat(1, args), matrix) if not bias: return res bias_term = tf.get_variable( "Bias", [output_size], initializer=tf.constant_initializer(bias_start)) return res + bias_term
38.373297
159
0.591848
1,736
14,083
4.483871
0.112903
0.043165
0.060123
0.051259
0.877184
0.867677
0.860868
0.855473
0.850462
0.849949
0
0.014074
0.318895
14,083
366
160
38.478142
0.797435
0.155507
0
0.804444
0
0
0.036624
0.001945
0
0
0
0
0.013333
1
0.097778
false
0
0.022222
0.04
0.222222
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
446195e2ac303682c42a162a978e93c5f3aaf75a
135,080
py
Python
nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_compute_api.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_compute_api.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_compute_api.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
# # Copyright (c) 2015-2018 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # import collections import json from six.moves import http_client as httplib import socket import uuid from nfv_common import debug from nfv_common import timers from nfv_common.helpers import coroutine from nfv_common.helpers import Object from nfv_vim import nfvi from nfv_vim.nfvi.objects import v1 as nfvi_objs from nfv_plugins.nfvi_plugins import config from nfv_plugins.nfvi_plugins.openstack import exceptions from nfv_plugins.nfvi_plugins.openstack import neutron from nfv_plugins.nfvi_plugins.openstack import nova from nfv_plugins.nfvi_plugins.openstack import openstack from nfv_plugins.nfvi_plugins.openstack import rest_api from nfv_plugins.nfvi_plugins.openstack import rpc_listener from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.compute_api') def hypervisor_get_admin_state(status): """ Convert the nfvi hypervisor status to a hypervisor administrative state """ if nova.HYPERVISOR_STATUS.ENABLED == status: return nfvi_objs.HYPERVISOR_ADMIN_STATE.UNLOCKED else: return nfvi_objs.HYPERVISOR_ADMIN_STATE.LOCKED def hypervisor_get_oper_state(state): """ Convert the nfvi hypervisor state to a hypervisor operational state """ if nova.HYPERVISOR_STATE.UP == state: return nfvi_objs.HYPERVISOR_OPER_STATE.ENABLED else: return nfvi_objs.HYPERVISOR_OPER_STATE.DISABLED def instance_get_admin_state(vm_state, task_state, power_state): """ Convert the nfvi vm states to an instance administrative state """ if nova.VM_STATE.STOPPED == vm_state: return nfvi_objs.INSTANCE_ADMIN_STATE.LOCKED return nfvi_objs.INSTANCE_ADMIN_STATE.UNLOCKED def instance_get_oper_state(vm_state, task_state, power_state): """ Convert the nfvi vm states to an instance operational state """ oper_state = nfvi_objs.INSTANCE_OPER_STATE.ENABLED if nova.VM_STATE.ERROR == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_STATE.BUILDING == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_STATE.PAUSED == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_STATE.SUSPENDED == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_STATE.STOPPED == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_STATE.DELETED == vm_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif power_state is not None: if nova.VM_POWER_STATE.NO_STATE == power_state \ or nova.VM_POWER_STATE_STR.NO_STATE == power_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_POWER_STATE.PAUSED == power_state \ or nova.VM_POWER_STATE_STR.PAUSED == power_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_POWER_STATE.SHUTDOWN == power_state \ or nova.VM_POWER_STATE_STR.SHUTDOWN == power_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED elif nova.VM_POWER_STATE.CRASHED == power_state \ or nova.VM_POWER_STATE_STR.CRASHED == power_state: oper_state = nfvi_objs.INSTANCE_OPER_STATE.DISABLED return oper_state def instance_get_avail_status(vm_state, task_state, power_state): """ Convert the nfvi vm states to an instance availability status """ avail_status = list() if nova.VM_STATE.RESIZED == vm_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.RESIZED) elif nova.VM_STATE.ERROR == vm_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.FAILED) elif nova.VM_STATE.PAUSED == vm_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.PAUSED) elif nova.VM_STATE.SUSPENDED == vm_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.SUSPENDED) elif nova.VM_STATE.DELETED == vm_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.DELETED) if power_state is not None: if nova.VM_POWER_STATE.NO_STATE == power_state \ or nova.VM_POWER_STATE_STR.NO_STATE == power_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.POWER_OFF) elif nova.VM_POWER_STATE.PAUSED == power_state \ or nova.VM_POWER_STATE_STR.PAUSED == power_state: if nfvi_objs.INSTANCE_AVAIL_STATUS.PAUSED \ not in avail_status: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.PAUSED) elif nova.VM_POWER_STATE.CRASHED == power_state \ or nova.VM_POWER_STATE_STR.CRASHED == power_state: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.CRASHED) if nfvi_objs.INSTANCE_AVAIL_STATUS.FAILED \ not in avail_status: avail_status.append(nfvi_objs.INSTANCE_AVAIL_STATUS.FAILED) return avail_status def instance_get_action(task_state, vm_state=None, power_state=None): """ Convert the nfvi vm states to an instance action """ action = nfvi_objs.INSTANCE_ACTION.NONE if nova.VM_STATE.BUILDING == vm_state: action = nfvi_objs.INSTANCE_ACTION.BUILDING else: if nova.VM_TASK_STATE.MIGRATING == task_state: action = nfvi_objs.INSTANCE_ACTION.MIGRATING elif nova.VM_TASK_STATE.MIGRATING_ROLLBACK == task_state: action = nfvi_objs.INSTANCE_ACTION.MIGRATING_ROLLBACK elif nova.VM_TASK_STATE.POWERING_OFF == task_state: action = nfvi_objs.INSTANCE_ACTION.POWERING_OFF elif nova.VM_TASK_STATE.POWERING_ON == task_state: action = nfvi_objs.INSTANCE_ACTION.POWERING_ON elif nova.VM_TASK_STATE.PAUSING == task_state: action = nfvi_objs.INSTANCE_ACTION.PAUSING elif nova.VM_TASK_STATE.UNPAUSING == task_state: action = nfvi_objs.INSTANCE_ACTION.UNPAUSING elif nova.VM_TASK_STATE.SUSPENDING == task_state: action = nfvi_objs.INSTANCE_ACTION.SUSPENDING elif nova.VM_TASK_STATE.RESUMING == task_state: action = nfvi_objs.INSTANCE_ACTION.RESUMING elif task_state in (nova.VM_TASK_STATE.DELETING, nova.VM_TASK_STATE.SOFT_DELETING): action = nfvi_objs.INSTANCE_ACTION.DELETING elif task_state in (nova.VM_TASK_STATE.REBOOTING, nova.VM_TASK_STATE.REBOOT_PENDING, nova.VM_TASK_STATE.REBOOT_STARTED, nova.VM_TASK_STATE.REBOOTING_HARD, nova.VM_TASK_STATE.REBOOT_PENDING_HARD, nova.VM_TASK_STATE.REBOOT_STARTED_HARD): action = nfvi_objs.INSTANCE_ACTION.REBOOTING elif task_state in (nova.VM_TASK_STATE.REBUILDING, nova.VM_TASK_STATE.REBUILD_BLOCK_DEVICE_MAPPING, nova.VM_TASK_STATE.REBUILD_SPAWNING): action = nfvi_objs.INSTANCE_ACTION.REBUILDING elif task_state in (nova.VM_TASK_STATE.RESIZE_PREP, nova.VM_TASK_STATE.RESIZE_MIGRATING, nova.VM_TASK_STATE.RESIZE_MIGRATED, nova.VM_TASK_STATE.RESIZE_FINISH, nova.VM_TASK_STATE.RESIZE_REVERTING, nova.VM_TASK_STATE.RESIZE_CONFIRMING): action = nfvi_objs.INSTANCE_ACTION.RESIZING return action def instance_get_action_type(vm_action, vm_data=None): """ Convert the nfvi vm actions to an action-type """ parameters = None if nova.VM_ACTION.PAUSE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.PAUSE elif nova.VM_ACTION.UNPAUSE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.UNPAUSE elif nova.VM_ACTION.SUSPEND == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.SUSPEND elif nova.VM_ACTION.RESUME == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.RESUME elif nova.VM_ACTION.LIVE_MIGRATE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.LIVE_MIGRATE if vm_data: parameters = dict() parameters[nfvi_objs.INSTANCE_LIVE_MIGRATE_OPTION.BLOCK_MIGRATION]\ = vm_data.get('block_migration') parameters[nfvi_objs.INSTANCE_LIVE_MIGRATE_OPTION.HOST]\ = vm_data.get('host') elif nova.VM_ACTION.MIGRATE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.COLD_MIGRATE elif nova.VM_ACTION.RESIZE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.RESIZE if vm_data: parameters = dict() parameters[nfvi_objs.INSTANCE_RESIZE_OPTION.INSTANCE_TYPE_UUID]\ = vm_data.get('flavorRef') elif nova.VM_ACTION.CONFIRM_RESIZE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.CONFIRM_RESIZE elif nova.VM_ACTION.REVERT_RESIZE == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.REVERT_RESIZE elif nova.VM_ACTION.REBOOT == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.REBOOT if vm_data: parameters = dict() if nova.VM_REBOOT_TYPE.SOFT == vm_data.get('type'): parameters[nfvi_objs.INSTANCE_REBOOT_OPTION.GRACEFUL_SHUTDOWN]\ = True else: parameters[nfvi_objs.INSTANCE_REBOOT_OPTION.GRACEFUL_SHUTDOWN]\ = False elif nova.VM_ACTION.REBUILD == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.REBUILD if vm_data: parameters = dict() parameters[nfvi_objs.INSTANCE_REBUILD_OPTION.INSTANCE_IMAGE_UUID]\ = vm_data.get('imageRef') name = vm_data.get('name', None) if name: parameters[nfvi_objs.INSTANCE_REBUILD_OPTION.INSTANCE_NAME]\ = name elif nova.VM_ACTION.START == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.START elif nova.VM_ACTION.STOP == vm_action: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.STOP else: action_type = nfvi_objs.INSTANCE_ACTION_TYPE.NONE DLOG.error("Unknown VM action %s" % vm_action) return action_type, parameters def instance_supports_live_migration(instance_data, ports_data): """ Determine if the instance supports live-migration """ # Live migration is not supported if there is a pci-passthrough or # pci-sriov NIC. for port in ports_data: vnic_type = port.get('binding:vnic_type', '') if (vnic_type in [neutron.VNIC_TYPE.DIRECT_PHYSICAL, neutron.VNIC_TYPE.DIRECT]): return False # Live migration is not supported if there is an attached pci passthrough # device. flavor = instance_data['flavor'] flavor_data_extra = flavor.get('extra_specs', None) if flavor_data_extra is not None: if 'pci_passthrough:alias' in flavor_data_extra: return False return True def flavor_data_extra_get(flavor_data_extra): """ Return flavor extra data fields """ heartbeat = flavor_data_extra.get( nfvi_objs.INSTANCE_TYPE_EXTENSION.GUEST_HEARTBEAT, None) if heartbeat and 'true' == heartbeat.lower(): guest_heartbeat = nfvi_objs.INSTANCE_GUEST_SERVICE_STATE.CONFIGURED else: guest_heartbeat = None auto_recovery = flavor_data_extra.get( nfvi_objs.INSTANCE_TYPE_EXTENSION.INSTANCE_AUTO_RECOVERY, None) live_migration_timeout = flavor_data_extra.get( nfvi_objs.INSTANCE_TYPE_EXTENSION.LIVE_MIGRATION_TIMEOUT, None) live_migration_max_downtime = flavor_data_extra.get( nfvi_objs.INSTANCE_TYPE_EXTENSION.LIVE_MIGRATION_MAX_DOWNTIME, None) return (guest_heartbeat, auto_recovery, live_migration_timeout, live_migration_max_downtime) class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI): """ NFVI Compute API Class Definition """ _name = 'Compute-API' _version = '1.0.0' _provider = 'Wind River' _signature = '22b3dbf6-e4ba-441b-8797-fb8a51210a43' @property def name(self): return self._name @property def version(self): return self._version @property def provider(self): return self._provider @property def signature(self): return self._signature def __init__(self): super(NFVIComputeAPI, self).__init__() self._token = None self._directory = None self._rpc_listener = None self._rest_api_server = None self._instance_add_callbacks = list() self._instance_delete_callbacks = list() self._instance_state_change_callbacks = list() self._instance_action_change_callbacks = list() self._instance_action_callbacks = list() self._requests = dict() self._request_times = collections.deque() self._max_concurrent_action_requests = 128 self._max_action_request_wait_in_secs = 45 self._auto_accept_action_requests = False def _host_supports_nova_compute(self, personality): return (('worker' in personality) and (self._directory.get_service_info( OPENSTACK_SERVICE.NOVA) is not None)) def notify_host_enabled(self, future, host_uuid, host_name, host_personality, callback): """ Notify host enabled """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) # Only applies to worker hosts if not self._host_supports_nova_compute(host_personality): response['completed'] = True response['reason'] = '' return response['reason'] = 'failed to get token from keystone' if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s." % host_uuid) return self._token = future.result.data response['reason'] = 'failed to notify nova that host is enabled' future.work(nova.notify_host_enabled, self._token, host_name) future.result = (yield) if not future.result.is_complete(): return response['completed'] = True response['reason'] = '' except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to notify " "nova host services enabled, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to notify " "nova host services enabled, error=%s." % e) finally: callback.send(response) callback.close() def notify_host_disabled(self, future, host_uuid, host_name, host_personality, callback): """ Notify host disabled """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._host_supports_nova_compute(host_personality): response['reason'] = 'failed to get token from keystone' if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s." % host_uuid) return self._token = future.result.data response['reason'] = 'failed to notify nova that ' \ 'host is disabled' future.work(nova.notify_host_disabled, self._token, host_name) try: future.result = (yield) if not future.result.is_complete(): DLOG.error("Nova notify-host-disabled.") return except exceptions.OpenStackRestAPIException as e: if httplib.NOT_FOUND != e.http_status_code: raise response['completed'] = True response['reason'] = '' except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to notify " "nova host services disabled, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to notify " "nova host services disabled, error=%s." % e) finally: callback.send(response) callback.close() def delete_host_services(self, future, host_uuid, host_name, host_personality, callback): """ Delete Host Services, Notify Nova to delete services for a host. """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._host_supports_nova_compute(host_personality): response['reason'] = 'failed to get openstack token from ' \ 'keystone' if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return self._token = future.result.data response['reason'] = 'failed to delete nova services' # Send the delete request to Nova. future.work(nova.delete_host_services, self._token, host_name) future.result = (yield) if not future.result.is_complete(): DLOG.error("Nova delete-host-services failed, operation " "did not complete, host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return response['completed'] = True response['reason'] = '' except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to delete " "nova services, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to delete %s " "nova services, error=%s." % (host_name, e)) finally: callback.send(response) callback.close() def enable_host_services(self, future, host_uuid, host_name, host_personality, callback): """ Enable Host Services, Notify Nova to enable services for a host. """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._host_supports_nova_compute(host_personality): response['reason'] = 'failed to get openstack token from ' \ 'keystone' if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return self._token = future.result.data response['reason'] = 'failed to enable nova services' # Send the Enable request to Nova. future.work(nova.enable_host_services, self._token, host_name) future.result = (yield) if not future.result.is_complete(): DLOG.error("Nova enable-host-services failed, operation " "did not complete, host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return result_data = future.result.data['service'] if not ('enabled' == result_data['status'] and host_name == result_data['host'] and 'nova-compute' == result_data['binary']): DLOG.error("Nova enable-host-services failed, operation " "did not complete, host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return response['completed'] = True response['reason'] = '' except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to enable " "nova services, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to enable %s " "nova services, error=%s." % (host_name, e)) finally: callback.send(response) callback.close() def disable_host_services(self, future, host_uuid, host_name, host_personality, callback): """ Disable Host Services, notify nova to disable services for a host """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) # The following only applies to worker hosts if self._host_supports_nova_compute(host_personality): response['reason'] = 'failed to get openstack token from ' \ 'keystone' if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return self._token = future.result.data response['reason'] = 'failed to disable nova services' # Send the Disable request to Nova. future.work(nova.disable_host_services, self._token, host_name) try: future.result = (yield) if not future.result.is_complete(): DLOG.error("Nova disable-host-services failed, " "operation did not complete, host_uuid=%s, " "host_name=%s." % (host_uuid, host_name)) return result_data = future.result.data['service'] if not ('disabled' == result_data['status'] and host_name == result_data['host'] and 'nova-compute' == result_data['binary']): DLOG.error("Nova disable-host-services failed, " "operation did not complete, host_uuid=%s, " "host_name=%s." % (host_uuid, host_name)) return except exceptions.OpenStackRestAPIException as e: if httplib.NOT_FOUND != e.http_status_code: raise response['completed'] = True response['reason'] = '' except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to disable " "nova services, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to disable %s " "nova services, error=%s." % (host_name, e)) finally: callback.send(response) callback.close() def query_host_services(self, future, host_uuid, host_name, host_personality, callback): """ Query Host Services, return state of Nova Services for a host """ response = dict() response['completed'] = False response['result-data'] = 'enabled' response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._host_supports_nova_compute(host_personality): if self._token is None or \ self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: DLOG.error("OpenStack get-token did not complete, " "host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return self._token = future.result.data # Send Query request to Nova. future.work(nova.query_host_services, self._token, host_name) future.result = (yield) if not future.result.is_complete(): DLOG.error("Nova query-host-services failed, operation " "did not complete, host_uuid=%s, host_name=%s." % (host_uuid, host_name)) return if future.result.data != 'enabled': response['result-data'] = 'disabled' response['completed'] = True return response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to query " "nova services, error=%s." % e) except Exception as e: DLOG.exception("Caught exception while trying to query %s " "nova services, error=%s." % (host_name, e)) finally: callback.send(response) callback.close() def _action_request_complete(self, request_uuid, http_status_code, http_headers=None, http_body=None): """ An action request has been completed. """ if request_uuid is not None: try: request_dispatch = self._requests.get(request_uuid, None) if request_dispatch is not None: if http_status_code is None: http_status_code = httplib.INTERNAL_SERVER_ERROR request_dispatch.send_response(http_status_code) if http_headers is not None: for (key, value) in http_headers: if 'Server' != key and 'Date' != key: request_dispatch.send_header(key, value) request_dispatch.end_headers() if http_body is not None: request_dispatch.wfile.write(http_body) request_dispatch.done() DLOG.info("Sent response for request %s." % request_uuid) del self._requests[request_uuid] remaining = collections.deque() while 0 < len(self._request_times): entry_uuid, timestamp = self._request_times.popleft() if request_uuid != entry_uuid: remaining.append((entry_uuid, timestamp)) del self._request_times self._request_times = remaining except socket.error as e: DLOG.error("Send response for request %s failed, error=%s" % (request_uuid, e)) else: DLOG.error("Request %s no longer exists." % request_uuid) def _ageout_action_requests(self): """ Age out action requests that are stale """ if self._max_concurrent_action_requests < len(self._request_times): oldest_uuid, oldest_timestamp_in_ms = self._request_times.popleft() self._action_request_complete(oldest_uuid, httplib.SERVICE_UNAVAILABLE) DLOG.info("Cancelled %s request, max concurrent action " "requests exceeded, max_requests=%i." % (oldest_uuid, self._max_concurrent_action_requests)) now_in_ms = timers.get_monotonic_timestamp_in_ms() max_wait_in_ms = self._max_action_request_wait_in_secs * 1000 while 0 < len(self._request_times): oldest_uuid, oldest_timestamp_in_ms = self._request_times.pop() elapsed_ms = now_in_ms - oldest_timestamp_in_ms if max_wait_in_ms < elapsed_ms: self._action_request_complete(oldest_uuid, httplib.ACCEPTED) DLOG.info("Auto-accepted %s request, max wait exceeded, " "max_wait_in_ms=%s, elapsed_ms=%s." % (oldest_uuid, max_wait_in_ms, elapsed_ms)) else: self._request_times.appendleft((oldest_uuid, oldest_timestamp_in_ms)) break @coroutine def _audit_action_requests(self): """ Periodic audit of the action requests looking for expired action requests """ while True: timer_id = (yield) DLOG.verbose("Auditing action requests, timer_id=%s." % timer_id) self._ageout_action_requests() def get_host_aggregates(self, future, callback): """ Get a list of host aggregates """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_host_aggregates, self._token) future.result = (yield) if not future.result.is_complete(): return host_aggregate_data_list = future.result.data host_aggregate_objs = list() for host_aggregate_data in host_aggregate_data_list['aggregates']: host_aggregate_obj = nfvi_objs.HostAggregate( host_aggregate_data['name'], host_aggregate_data['hosts'], host_aggregate_data['availability_zone']) host_aggregate_objs.append(host_aggregate_obj) response['result-data'] = host_aggregate_objs response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to get host " "aggregate list, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get host " "aggregate list, error=%s." % e) finally: callback.send(response) callback.close() def get_hypervisors(self, future, callback): """ Get a list of hypervisors """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_hypervisors, self._token) future.result = (yield) if not future.result.is_complete(): return hypervisor_data_list = future.result.data hypervisor_objs = list() for hypervisor_data in hypervisor_data_list['hypervisors']: status = hypervisor_data['status'] state = hypervisor_data['state'] admin_state = hypervisor_get_admin_state(status) oper_state = hypervisor_get_oper_state(state) hypervisor_obj = nfvi_objs.Hypervisor( hypervisor_data['id'], admin_state, oper_state, hypervisor_data['hypervisor_hostname']) hypervisor_objs.append(hypervisor_obj) response['result-data'] = hypervisor_objs response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to get " "hypervisor list, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get hypervisor " "list, error=%s." % e) finally: callback.send(response) callback.close() def get_hypervisor(self, future, hypervisor_uuid, callback): """ Get hypervisor details """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_hypervisor, self._token, hypervisor_uuid) future.result = (yield) if not future.result.is_complete(): return hypervisor_data = future.result.data['hypervisor'] admin_state = hypervisor_get_admin_state(hypervisor_data['status']) oper_state = hypervisor_get_oper_state(hypervisor_data['state']) hypervisor_obj = nfvi_objs.Hypervisor( hypervisor_data['id'], admin_state, oper_state, hypervisor_data['hypervisor_hostname']) if (hypervisor_data['vcpus_used'] is None or hypervisor_data['vcpus'] is None or hypervisor_data['memory_mb_used'] is None or hypervisor_data['free_ram_mb'] is None or hypervisor_data['memory_mb'] is None or hypervisor_data['local_gb_used'] is None or hypervisor_data['local_gb'] is None or hypervisor_data['running_vms'] is None): DLOG.error("Invalid hypervisor data given by nova, hypervisor=%s" % hypervisor_data) else: hypervisor_obj.update_stats(hypervisor_data['vcpus_used'], hypervisor_data['vcpus'], hypervisor_data['memory_mb_used'], hypervisor_data['free_ram_mb'], hypervisor_data['memory_mb'], hypervisor_data['local_gb_used'], hypervisor_data['local_gb'], hypervisor_data['running_vms']) response['result-data'] = hypervisor_obj response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() elif httplib.NOT_FOUND == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.NOT_FOUND else: DLOG.exception("Caught exception while trying to get " "hypervisor details, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get hypervisor " "details, error=%s." % e) finally: callback.send(response) callback.close() def get_instance_types(self, future, paging, callback): """ Get a list of instance types """ response = dict() response['completed'] = False response['reason'] = '' response['page-request-id'] = paging.page_request_id try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data DLOG.verbose("Instance-Type paging (before): %s" % paging) future.work(nova.get_flavors, self._token, paging.page_limit, paging.next_page) future.result = (yield) if not future.result.is_complete(): return flavor_data_list = future.result.data instance_type_objs = list() for flavor_data in flavor_data_list['flavors']: instance_type_obj = nfvi_objs.InstanceType( flavor_data['id'], flavor_data['name']) instance_type_objs.append(instance_type_obj) paging.next_page = None flavor_links = flavor_data_list.get('flavors_links', None) if flavor_links is not None: for flavor_link in flavor_links: if 'next' == flavor_link['rel']: paging.next_page = flavor_link['href'] break DLOG.verbose("Instance-Type paging (after): %s" % paging) response['result-data'] = instance_type_objs response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to get list of " "instance types, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get list of " "instance types, error=%s." % e) finally: callback.send(response) callback.close() def create_instance_type(self, future, instance_type_uuid, instance_type_name, instance_type_attributes, callback): """ Create an instance type """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.create_flavor, self._token, instance_type_uuid, instance_type_name, instance_type_attributes.vcpus, instance_type_attributes.mem_mb, instance_type_attributes.disk_gb) future.result = (yield) if not future.result.is_complete(): return flavor_data = future.result.data['flavor'] instance_type_obj = nfvi_objs.InstanceType( flavor_data['id'], flavor_data['name']) if not flavor_data['OS-FLV-EXT-DATA:ephemeral']: ephemeral_gb = 0 else: ephemeral_gb = flavor_data['OS-FLV-EXT-DATA:ephemeral'] if not flavor_data['swap']: swap_gb = 0 else: swap_gb = flavor_data['swap'] extra_specs = dict() if instance_type_attributes.auto_recovery is not None: extra_specs[ nfvi_objs.INSTANCE_TYPE_EXTENSION.INSTANCE_AUTO_RECOVERY] \ = instance_type_attributes.auto_recovery if instance_type_attributes.live_migration_timeout is not None: extra_specs[ nfvi_objs.INSTANCE_TYPE_EXTENSION.LIVE_MIGRATION_TIMEOUT] \ = instance_type_attributes.live_migration_timeout if instance_type_attributes.live_migration_max_downtime is not None: extra_specs[ nfvi_objs.INSTANCE_TYPE_EXTENSION.LIVE_MIGRATION_MAX_DOWNTIME] \ = instance_type_attributes.live_migration_max_downtime guest_services = dict() auto_recovery = None live_migration_timeout = None live_migration_max_downtime = None if extra_specs: future.work(nova.set_flavor_extra_specs, self._token, instance_type_uuid, extra_specs) future.result = (yield) if not future.result.is_complete(): return flavor_data_extra = future.result.data['extra_specs'] (guest_heartbeat, auto_recovery, live_migration_timeout, live_migration_max_downtime) = \ flavor_data_extra_get(flavor_data_extra) if guest_heartbeat is not None: guest_services['heartbeat'] = guest_heartbeat instance_type_obj.update_details( flavor_data['vcpus'], flavor_data['ram'], flavor_data['disk'], ephemeral_gb, swap_gb, guest_services=guest_services, auto_recovery=auto_recovery, live_migration_timeout=live_migration_timeout, live_migration_max_downtime=live_migration_max_downtime) response['result-data'] = instance_type_obj response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to create an " "instance-type, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to create an " "instance-type, error=%s." % e) finally: callback.send(response) callback.close() def delete_instance_type(self, future, instance_type_uuid, callback): """ Delete an instance type """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.delete_flavor, self._token, instance_type_uuid) future.result = (yield) if not future.result.is_complete(): return response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to delete an " "instance-type, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to delete an " "instance-type, error=%s." % e) finally: callback.send(response) callback.close() def get_instance_type(self, future, instance_type_uuid, callback): """ Get an instance type """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_flavor, self._token, instance_type_uuid) future.result = (yield) if not future.result.is_complete(): return flavor_data = future.result.data['flavor'] instance_type_obj = nfvi_objs.InstanceType( flavor_data['id'], flavor_data['name']) if not flavor_data['OS-FLV-EXT-DATA:ephemeral']: ephemeral_gb = 0 else: ephemeral_gb = flavor_data['OS-FLV-EXT-DATA:ephemeral'] if not flavor_data['swap']: swap_gb = 0 else: swap_gb = flavor_data['swap'] future.work(nova.get_flavor_extra_specs, self._token, instance_type_uuid) future.result = (yield) guest_services = dict() auto_recovery = None live_migration_timeout = None live_migration_max_downtime = None if future.result.is_complete(): flavor_data_extra = future.result.data.get('extra_specs') if flavor_data_extra is not None: (guest_heartbeat, auto_recovery, live_migration_timeout, live_migration_max_downtime) = \ flavor_data_extra_get(flavor_data_extra) if guest_heartbeat is not None: guest_services['heartbeat'] = guest_heartbeat if auto_recovery is not None: if 'false' == auto_recovery.lower(): auto_recovery = False elif 'true' == auto_recovery.lower(): auto_recovery = True else: raise AttributeError("sw:wrs:auto_recovery is %s, " "expecting 'true' or 'false'" % auto_recovery) instance_type_obj.update_details( flavor_data['vcpus'], flavor_data['ram'], flavor_data['disk'], ephemeral_gb, swap_gb, guest_services=guest_services, auto_recovery=auto_recovery, live_migration_timeout=live_migration_timeout, live_migration_max_downtime=live_migration_max_downtime) response['result-data'] = instance_type_obj response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() elif httplib.NOT_FOUND == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.NOT_FOUND else: DLOG.exception("Caught exception while trying to get an " "instance-type, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get an " "instance-type, error=%s." % e) finally: callback.send(response) callback.close() def get_instance_groups(self, future, callback): """ Get a list of instance groupings """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_server_groups, self._token) future.result = (yield) if not future.result.is_complete(): return server_group_list = future.result.data instance_group_objs = list() for server_group in server_group_list['server_groups']: name = server_group.get('name', server_group['id']) members = server_group.get('members', list()) metadata = server_group.get('metadata', None) if metadata is None: best_effort = False else: best_effort = metadata.get('wrs-sg:best_effort', False) server_group_policies = server_group.get('policies', list()) policies = list() for server_group_policy in server_group_policies: if 'affinity' == server_group_policy and best_effort: policies.append( nfvi_objs.INSTANCE_GROUP_POLICY.AFFINITY_BEST_EFFORT) elif 'affinity' == server_group_policy: policies.append(nfvi_objs.INSTANCE_GROUP_POLICY.AFFINITY) elif 'anti-affinity' == server_group_policy and best_effort: policies.append( nfvi_objs.INSTANCE_GROUP_POLICY. ANTI_AFFINITY_BEST_EFFORT) elif 'anti-affinity' == server_group_policy: policies.append( nfvi_objs.INSTANCE_GROUP_POLICY.ANTI_AFFINITY) instance_type_obj = nfvi_objs.InstanceGroup( server_group['id'], name, members, policies) instance_group_objs.append(instance_type_obj) response['result-data'] = instance_group_objs response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to get list of " "instance types, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get list of " "instance types, error=%s." % e) finally: callback.send(response) callback.close() def get_instances(self, future, paging, context, callback): """ Get a list of instances """ response = dict() response['completed'] = False response['reason'] = '' response['page-request-id'] = paging.page_request_id try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data DLOG.verbose("Instance paging (before): %s" % paging) future.work(nova.get_servers, self._token, paging.page_limit, paging.next_page, context=context) future.result = (yield) if not future.result.is_complete(): return instance_data_list = future.result.data instances = list() for instance_data in instance_data_list['servers']: instances.append((instance_data['id'], instance_data['name'])) paging.next_page = None server_links = instance_data_list.get('servers_links', None) if server_links is not None: for server_link in server_links: if 'next' == server_link['rel']: paging.next_page = server_link['href'] break DLOG.verbose("Instance paging (after): %s" % paging) response['result-data'] = instances response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to get a list" " of instances, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get a list of " "instances, error=%s." % e) finally: callback.send(response) callback.close() def create_instance(self, future, instance_name, instance_type_uuid, image_uuid, block_devices, networks, context, callback): """ Create an instance """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.create_server, self._token, instance_name, instance_type_uuid, image_uuid, block_devices, networks, context=context) future.result = (yield) if not future.result.is_complete(): return instance_data = future.result.data['server'] future.work(nova.get_server, self._token, instance_data['id'], context=context) future.result = (yield) if not future.result.is_complete(): return instance_data = future.result.data['server'] future.work(neutron.get_ports_for_instance, self._token, instance_data['id']) future.result = (yield) if (not future.result.is_complete() or future.result.data is None): return ports_data = future.result.data.get('ports', []) nfvi_data = dict() nfvi_data['vm_state'] = instance_data['OS-EXT-STS:vm_state'] nfvi_data['task_state'] = instance_data['OS-EXT-STS:task_state'] nfvi_data['power_state'] = instance_data['OS-EXT-STS:power_state'] nfvi_data['last_update_timestamp'] = instance_data['updated'] if nfvi_data['task_state'] is None: nfvi_data['task_state'] = nova.VM_TASK_STATE.NONE admin_state = instance_get_admin_state(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) oper_state = instance_get_oper_state(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) avail_status = instance_get_avail_status(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) action = instance_get_action(nfvi_data['task_state'], nfvi_data['vm_state'], nfvi_data['power_state']) tenant_uuid = uuid.UUID(instance_data['tenant_id']) live_migration_support = instance_supports_live_migration( instance_data, ports_data) volumes = instance_data.get('os-extended-volumes:volumes_attached', list()) attached_volumes = list() for volume in volumes: attached_volumes.append(volume['id']) instance_obj = nfvi_objs.Instance( instance_data['id'], instance_data['name'], str(tenant_uuid), admin_state, oper_state, avail_status, action, instance_data['OS-EXT-SRV-ATTR:host'], instance_data['flavor'], image_uuid, live_migration_support, attached_volumes, nfvi_data) response['result-data'] = instance_obj response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to create an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to create an " "instance, error=%s." % e) finally: callback.send(response) callback.close() def live_migrate_instance(self, future, instance_uuid, to_host_name, block_storage_migration, context, callback): """ Live migrate an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.live_migrate_server, self._token, instance_uuid, to_host_name, block_storage_migration, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Live migrate instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to live migrate " "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to live migrate " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "live migrate response, error=%s." % e) callback.send(response) callback.close() def cold_migrate_instance(self, future, instance_uuid, to_host_name, context, callback): """ Cold migrate an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.cold_migrate_server, self._token, instance_uuid, to_host_name, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Cold migrate instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to cold migrate " "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to cold migrate " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "cold migrate response, error=%s." % e) callback.send(response) callback.close() def cold_migrate_confirm_instance(self, future, instance_uuid, context, callback): """ Cold migrate confirm an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.cold_migrate_server_confirm, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Cold migrate confirm instance not complete " "instance=%s, future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to cold migrate " "confirm an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to cold migrate " "confirm an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "cold migrate confirm response, error=%s." % e) callback.send(response) callback.close() def cold_migrate_revert_instance(self, future, instance_uuid, context, callback): """ Cold migrate revert an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.cold_migrate_server_revert, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Cold migrate revert instance not complete " "instance=%s, future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to cold migrate " "revert an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to cold migrate " "revert an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "cold migrate revert response, error=%s." % e) callback.send(response) callback.close() def resize_instance(self, future, instance_uuid, instance_type_uuid, context, callback): """ Resize an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.resize_server, self._token, instance_uuid, instance_type_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Resize instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to resize an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to resize an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "resize response, error=%s." % e) callback.send(response) callback.close() def resize_confirm_instance(self, future, instance_uuid, context, callback): """ Resize confirm an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.resize_server_confirm, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Resize confirm instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to resize " "confirm an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to resize confirm " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "resize confirm response, error=%s." % e) callback.send(response) callback.close() def resize_revert_instance(self, future, instance_uuid, context, callback): """ Resize revert an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.resize_server_revert, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Resize revert instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to resize revert" "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to resize revert" "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "resoze revert response, error=%s." % e) callback.send(response) callback.close() def evacuate_instance(self, future, instance_uuid, admin_password, to_host_name, context, callback): """ Evacuate an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.evacuate_server, self._token, instance_uuid, admin_password, to_host_name, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Evacuate instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to evacuate " "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to evacuate " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "evacuate response, error=%s." % e) callback.send(response) callback.close() def reboot_instance(self, future, instance_uuid, graceful_shutdown, context, callback): """ Reboot an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data if graceful_shutdown: reboot_type = nova.VM_REBOOT_TYPE.SOFT else: reboot_type = nova.VM_REBOOT_TYPE.HARD future.work(nova.reboot_server, self._token, instance_uuid, reboot_type, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Reboot instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to reboot " "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to reboot " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "reboot response, error=%s." % e) callback.send(response) callback.close() def rebuild_instance(self, future, instance_uuid, instance_name, image_uuid, admin_password, context, callback): """ Rebuild an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.rebuild_server, self._token, instance_uuid, instance_name, image_uuid, admin_password, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Rebuild instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to rebuild " "an instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to rebuild " "an instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "rebuild response, error=%s." % e) callback.send(response) callback.close() def fail_instance(self, future, instance_uuid, context, callback): """ Fail an instance """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.reset_server_state, self._token, instance_uuid, "error", context=context) future.result = (yield) if not future.result.is_complete(): return response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to fail an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to fail an " "instance, error=%s." % e) finally: callback.send(response) callback.close() def pause_instance(self, future, instance_uuid, context, callback): """ Pause an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.pause_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Pause instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to pause an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to pause an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "pause response, error=%s." % e) callback.send(response) callback.close() def unpause_instance(self, future, instance_uuid, context, callback): """ Unpause an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.unpause_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Unpause instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to unpause an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to unpause an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "unpause response, error=%s." % e) callback.send(response) callback.close() def suspend_instance(self, future, instance_uuid, context, callback): """ Suspend an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.suspend_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Suspend instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to suspend an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to suspend an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "suspend response, error=%s." % e) callback.send(response) callback.close() def resume_instance(self, future, instance_uuid, context, callback): """ Resume an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.resume_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Resume instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to resume an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to resume an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "resume response, error=%s." % e) callback.send(response) callback.close() def start_instance(self, future, instance_uuid, context, callback): """ Start an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.start_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): DLOG.error("Start instance not complete instance=%s, " "future.result=%s." % (instance_uuid, future.result)) return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to start an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to start an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "start response, error=%s." % e) callback.send(response) callback.close() def stop_instance(self, future, instance_uuid, context, callback): """ Stop an instance """ context_response_code = None context_response_headers = None context_response_body = None response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.stop_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): return context_response_code = future.result.ancillary_data.status_code context_response_headers = future.result.ancillary_data.headers context_response_body = future.result.ancillary_data.response response['completed'] = True except exceptions.OpenStackRestAPIException as e: context_response_code = e.http_status_code context_response_headers = e.http_response_headers context_response_body = e.http_response_body if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to stop an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: context_response_code = httplib.INTERNAL_SERVER_ERROR DLOG.exception("Caught exception while trying to stop an " "instance, error=%s." % e) finally: if context is not None: try: self._action_request_complete(context.request_uuid, context_response_code, context_response_headers, context_response_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "stop response, error=%s." % e) callback.send(response) callback.close() def delete_instance(self, future, instance_uuid, context, callback): """ Delete an instance """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.delete_server, self._token, instance_uuid, context=context) try: future.result = (yield) if not future.result.is_complete(): DLOG.error("Failed to delete instance %s." % instance_uuid) return except exceptions.OpenStackRestAPIException as e: if httplib.NOT_FOUND != e.http_status_code: raise response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() else: DLOG.exception("Caught exception while trying to delete an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to delete an " "instance, error=%s." % e) finally: callback.send(response) callback.close() def get_instance(self, future, instance_uuid, context, callback): """ Get an instance """ response = dict() response['completed'] = False response['reason'] = '' try: future.set_timeouts(config.CONF.get('nfvi-timeouts', None)) if self._token is None or self._token.is_expired(): future.work(openstack.get_token, self._directory) future.result = (yield) if not future.result.is_complete() or \ future.result.data is None: return self._token = future.result.data future.work(nova.get_server, self._token, instance_uuid, context=context) future.result = (yield) if not future.result.is_complete(): return instance_data = future.result.data['server'] future.work(neutron.get_ports_for_instance, self._token, instance_uuid) future.result = (yield) if (not future.result.is_complete() or future.result.data is None): return ports_data = future.result.data.get('ports', []) power_state_str = \ nova.vm_power_state_str(instance_data['OS-EXT-STS:power_state']) nfvi_data = dict() nfvi_data['vm_state'] = instance_data['OS-EXT-STS:vm_state'] nfvi_data['task_state'] = instance_data['OS-EXT-STS:task_state'] nfvi_data['power_state'] = power_state_str nfvi_data['last_update_timestamp'] = instance_data['updated'] if nfvi_data['task_state'] is None: nfvi_data['task_state'] = nova.VM_TASK_STATE.NONE admin_state = instance_get_admin_state(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) oper_state = instance_get_oper_state(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) avail_status = instance_get_avail_status(nfvi_data['vm_state'], nfvi_data['task_state'], nfvi_data['power_state']) action = instance_get_action(nfvi_data['task_state'], nfvi_data['vm_state'], nfvi_data['power_state']) tenant_uuid = uuid.UUID(instance_data['tenant_id']) instance_type = instance_data['flavor'] image_data = instance_data.get('image', None) if image_data: image_uuid = image_data.get('id', None) else: image_uuid = None live_migration_support = instance_supports_live_migration( instance_data, ports_data) volumes = instance_data.get('os-extended-volumes:volumes_attached', list()) attached_volumes = list() for volume in volumes: attached_volumes.append(volume['id']) instance_name = instance_data['name'] metadata = instance_data.get('metadata', dict()) # Check instance metadata for the recovery priority recovery_priority = \ nova.get_recovery_priority(metadata, instance_name) # Check instance metadata for the live migration timeout live_migration_timeout = \ nova.get_live_migration_timeout(metadata, instance_name) instance_obj = nfvi_objs.Instance( instance_data['id'], instance_data['name'], str(tenant_uuid), admin_state, oper_state, avail_status, action, instance_data['OS-EXT-SRV-ATTR:host'], instance_type, image_uuid, live_migration_support, attached_volumes, nfvi_data, recovery_priority, live_migration_timeout) response['result-data'] = instance_obj response['completed'] = True except exceptions.OpenStackRestAPIException as e: if httplib.UNAUTHORIZED == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED if self._token is not None: self._token.set_expired() elif httplib.NOT_FOUND == e.http_status_code: response['error-code'] = nfvi.NFVI_ERROR_CODE.NOT_FOUND else: DLOG.exception("Caught exception while trying to get an " "instance, error=%s." % e) response['reason'] = e.http_response_reason except Exception as e: DLOG.exception("Caught exception while trying to get an instance, " "error=%s." % e) finally: callback.send(response) callback.close() def reject_instance_action(self, instance_uuid, message, context): """ Reject an action against an instance """ if context is not None: DLOG.info("Rejecting request %s, message=%s." % (context.request_uuid, message)) # Be aware that Heat process on vote rejects is looking for the # message field to be set to "action-rejected" http_body = ("{\"conflictingRequest\": " "{\"message\": \"action-rejected\", " "\"details\": \"%s\", \"code\": 409}}" % message) http_headers = list() http_headers.append(('Content-Length', len(http_body))) try: self._action_request_complete(context.request_uuid, httplib.CONFLICT, http_headers, http_body) except Exception as e: DLOG.exception("Caught exception while trying to send " "action reject response, error=%s." % e) def instance_state_change_handler(self, message): """ Instance state change handler """ instance_uuid = message.get('server_uuid', None) instance_name = message.get('server_name', None) tenant_uuid = message.get('tenant_id', None) vm_state = message.get('vm_state', None) task_state = message.get('task_state', None) power_state = message.get('power_state', None) host_name = message.get('host_name', None) image_uuid = message.get('image_id', None) recovery_priority = message.get('recovery_priority', None) live_migration_timeout = message.get('live_migration_timeout', None) admin_state = instance_get_admin_state(vm_state, task_state, power_state) oper_state = instance_get_oper_state(vm_state, task_state, power_state) avail_status = instance_get_avail_status(vm_state, task_state, power_state) action = instance_get_action(task_state, vm_state, power_state) tenant_uuid = uuid.UUID(tenant_uuid) if instance_uuid is not None: if task_state is None: task_state = nova.VM_TASK_STATE.NONE if power_state is None: power_state_str = '' else: power_state_str = nova.vm_power_state_str(power_state) nfvi_data = dict() nfvi_data['vm_state'] = vm_state nfvi_data['task_state'] = task_state nfvi_data['power_state'] = power_state_str instance_obj = nfvi_objs.Instance(instance_uuid, instance_name, str(tenant_uuid), admin_state, oper_state, avail_status, action, host_name, None, image_uuid, None, None, nfvi_data, recovery_priority, live_migration_timeout) for callback in self._instance_state_change_callbacks: callback(instance_obj) def instance_action_change_handler(self, message): """ Instance action change handler """ instance_uuid = message.get('server_uuid', None) task_state = message.get('task_state', None) task_status = message.get('task_status', None) reason = message.get('reason', None) DLOG.debug("Instance action-change: instance_uuid=%s, task_state=%s," " task_status=%s, error_msg=%s." % (instance_uuid, task_state, task_status, reason)) action = instance_get_action(task_state) if nova.VM_TASK_STATUS.START == task_status: action_state = nfvi_objs.INSTANCE_ACTION_STATE.STARTED elif nova.VM_TASK_STATUS.COMPLETE == task_status: action_state = nfvi_objs.INSTANCE_ACTION_STATE.COMPLETED else: action_state = nfvi_objs.INSTANCE_ACTION_STATE.UNKNOWN if instance_uuid is not None: action_type = nfvi_objs.INSTANCE_ACTION.get_action_type(action) for callback in self._instance_action_change_callbacks: callback(instance_uuid, action_type, action_state, reason) def instance_delete_handler(self, message): """ Instance delete handler """ instance_uuid = message.get('server_uuid', None) if instance_uuid is not None: for callback in self._instance_delete_callbacks: callback(instance_uuid) def instance_action_rest_api_post_handler(self, request_dispatch): """ Instance Action Rest-API POST handler callback """ token_id = request_dispatch.headers.getheader('X-Auth-Token', None) version \ = request_dispatch.headers.getheader("X-OpenStack-Nova-API-Version", None) content_len \ = int(request_dispatch.headers.getheader('content-length', 0)) content = request_dispatch.rfile.read(content_len) if 'action' != request_dispatch.path.split('/')[-1]: DLOG.error("Invalid url %s received" % request_dispatch.path) request_dispatch.send_response(httplib.BAD_REQUEST) return path_items = request_dispatch.path.split('/') instance_uuid = path_items[-2] tenant_uuid = path_items[2] request_uuid = str(uuid.uuid4()) now_in_ms = timers.get_monotonic_timestamp_in_ms() self._request_times.append((request_uuid, now_in_ms)) self._requests[request_uuid] = request_dispatch DLOG.info("Requests inprogress are %i, new request=%s." % (len(self._requests), request_uuid)) err_msg = "" if content: http_response = httplib.ACCEPTED action_data = json.loads(content) context = Object(token_id=token_id, tenant_id=tenant_uuid, request_uuid=request_uuid, version=version, content=content) instance_action_data = None for vm_action in action_data.keys(): vm_action_data = action_data[vm_action] action_type, action_params \ = instance_get_action_type(vm_action, vm_action_data) instance_action_data = nfvi_objs.InstanceActionData( request_uuid, action_type, action_params, from_cli=True, context=context) break if instance_action_data is not None: DLOG.verbose("Instance %s action=%s" % (instance_uuid, instance_action_data)) for callback in self._instance_action_callbacks: success = callback(instance_uuid, instance_action_data) if not success: DLOG.error("Callback failed for instance_uuid=%s." % instance_uuid) err_msg = "Instance %s could not be found" % instance_uuid http_response = httplib.NOT_FOUND else: http_response = httplib.BAD_REQUEST else: http_response = httplib.NO_CONTENT DLOG.debug("Instance action rest-api post path: %s." % request_dispatch.path) if httplib.ACCEPTED == http_response: if self._auto_accept_action_requests: request_dispatch.send_response(http_response) request_dispatch.done() self._request_times.pop() del self._requests[request_uuid] else: request_dispatch.response_delayed() self._ageout_action_requests() else: request_dispatch.send_response(http_response, message=err_msg) request_dispatch.done() self._request_times.pop() del self._requests[request_uuid] def register_instance_state_change_callback(self, callback): """ Register for instance state change notifications """ self._instance_state_change_callbacks.append(callback) def register_instance_action_change_callback(self, callback): """ Register for instance action change notifications """ self._instance_action_change_callbacks.append(callback) def register_instance_action_callback(self, callback): """ Register for instance action rest api """ self._instance_action_callbacks.append(callback) def register_instance_delete_callback(self, callback): """ Register for instance delete notifications """ self._instance_delete_callbacks.append(callback) def ready_to_initialize(self, config_file): """ Check if the plugin is ready to initialize """ config.load(config_file) # In order for the compute plugin to initialize successfully, the # rabbitmq server must be running. If it is not running, the plugin # initialization cannot register with rabbitmq and will throw an # exception. It is essentially impossible to clean up the plugin in # that case, so we must avoid it. return rpc_listener.test_connection( config.CONF['amqp']['host'], config.CONF['amqp']['port'], config.CONF['amqp']['user_id'], config.CONF['amqp']['password'], config.CONF['amqp']['virt_host'], "nova", "notifications.info") def initialize(self, config_file): """ Initialize the plugin """ config.load(config_file) self._directory = openstack.get_directory( config, openstack.SERVICE_CATEGORY.OPENSTACK) # The name of the listener queue must be prefixed with "notfications." # to ensure the nova vhost policy matches it and configures it as an # HA queue. self._rpc_listener = rpc_listener.RPCListener( config.CONF['amqp']['host'], config.CONF['amqp']['port'], config.CONF['amqp']['user_id'], config.CONF['amqp']['password'], config.CONF['amqp']['virt_host'], "nova", "notifications.info", 'notifications.nfvi_nova_listener_queue') self._rpc_listener.add_message_handler( nova.RPC_MESSAGE_TYPE.NOVA_SERVER_DELETE, nova.rpc_message_server_delete_filter, self.instance_delete_handler) self._rpc_listener.add_message_handler( nova.RPC_MESSAGE_TYPE.NOVA_SERVER_ACTION_CHANGE, nova.rpc_message_server_action_change_filter, self.instance_action_change_handler) self._rpc_listener.add_message_handler( nova.RPC_MESSAGE_TYPE.NOVA_SERVER_STATE_CHANGE, nova.rpc_message_server_state_change_filter, self.instance_state_change_handler) self._rpc_listener.start() self._rest_api_server = rest_api.rest_api_get_server( config.CONF['compute-rest-api']['host'], config.CONF['compute-rest-api']['port']) auto_accept_requests_str = \ config.CONF['compute-rest-api'].get('auto_accept_requests', 'False') if auto_accept_requests_str in ['True', 'true', 'T', 't', 'Yes', 'yes', 'Y', 'y', '1']: self._auto_accept_action_requests = True else: self._auto_accept_action_requests = False self._max_concurrent_action_requests = int( config.CONF['compute-rest-api'].get('max_concurrent_requests', 128)) self._max_action_request_wait_in_secs = int( config.CONF['compute-rest-api'].get('max_request_wait_in_secs', 45)) self._rest_api_server.add_handler( 'POST', '/v2/*', self.instance_action_rest_api_post_handler) self._rest_api_server.add_handler( 'POST', '/v2.1/*', self.instance_action_rest_api_post_handler) interval_secs = max(self._max_action_request_wait_in_secs / 2, 1) timers.timers_create_timer('compute-api-action-requests-audit', interval_secs, interval_secs, self._audit_action_requests) def finalize(self): """ Finalize the plugin """ if self._rpc_listener is not None: self._rpc_listener.stop()
39.187699
84
0.555219
13,719
135,080
5.201618
0.036081
0.053475
0.016185
0.034136
0.83945
0.80366
0.772551
0.740587
0.714368
0.689508
0
0.000806
0.366205
135,080
3,446
85
39.199071
0.832724
0.023527
0
0.716184
0
0
0.102974
0.004779
0
0
0
0
0
1
0.026167
false
0.002818
0.007649
0.002013
0.075684
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
9290bc4c51d4adfeb3e35f4fa6da7942ab6ab775
3,723
py
Python
tspsolver/ga/test/mutation_test.py
samueljackson92/tsp-solver
4f6403b40c7ba9062a9b7ffdde5e7d594163bc2f
[ "MIT" ]
2
2018-12-03T14:37:48.000Z
2020-12-01T23:13:56.000Z
tspsolver/ga/test/mutation_test.py
samueljackson92/tsp-solver
4f6403b40c7ba9062a9b7ffdde5e7d594163bc2f
[ "MIT" ]
null
null
null
tspsolver/ga/test/mutation_test.py
samueljackson92/tsp-solver
4f6403b40c7ba9062a9b7ffdde5e7d594163bc2f
[ "MIT" ]
null
null
null
import unittest import nose.tools import numpy as np from scipy.spatial import distance_matrix from tspsolver.tsp_generator import TSPGenerator from ..population_generation import SimplePopulationGenerator from ..mutation import (SwapCityMutation, DisplacementMutation, InversionMutation, InsertionMutation) class SwapCityMutationTest(unittest.TestCase): def setUp(self): self._num_points = 10 self._pop_size = 5 gen = TSPGenerator(self._num_points) self._data = gen.generate() self._distances = distance_matrix(self._data, self._data) popGen = SimplePopulationGenerator(self._pop_size) self._population = popGen.generate(self._distances[0]) def test_mutate(self): swap_city = SwapCityMutation(1.0) new_pop = swap_city.mutate(self._population.copy()) nose.tools.assert_equal(new_pop.shape, self._population.shape) nose.tools.assert_true(np.any(new_pop != self._population)) class DisplacementMutationTest(unittest.TestCase): def setUp(self): self._num_points = 10 self._pop_size = 5 gen = TSPGenerator(self._num_points) self._data = gen.generate() self._distances = distance_matrix(self._data, self._data) popGen = SimplePopulationGenerator(self._pop_size) self._population = popGen.generate(self._distances[0]) def test_mutate_single(self): mutator = DisplacementMutation(1.0) pop = np.array([[1, 2, 3, 4, 5, 6, 7]]) new_pop = mutator.mutate(pop.copy()) np.testing.assert_array_equal(pop[0], np.sort(new_pop[0])) def test_mutate(self): mutator = DisplacementMutation(1.0) new_pop = mutator.mutate(self._population.copy()) nose.tools.assert_equal(new_pop.shape, self._population.shape) nose.tools.assert_true(np.any(new_pop != self._population)) class InversionMutationTest(unittest.TestCase): def setUp(self): self._num_points = 10 self._pop_size = 5 gen = TSPGenerator(self._num_points) self._data = gen.generate() self._distances = distance_matrix(self._data, self._data) popGen = SimplePopulationGenerator(self._pop_size) self._population = popGen.generate(self._distances[0]) def test_mutate_single(self): mutator = InversionMutation(1.0) pop = np.array([[1, 2, 3, 4, 5, 6, 7]]) new_pop = mutator.mutate(pop.copy()) np.testing.assert_array_equal(pop[0], np.sort(new_pop[0])) def test_mutate(self): mutator = InversionMutation(1.0) new_pop = mutator.mutate(self._population.copy()) nose.tools.assert_equal(new_pop.shape, self._population.shape) nose.tools.assert_true(np.any(new_pop != self._population)) class InsertionMutationTest(unittest.TestCase): def setUp(self): self._num_points = 10 self._pop_size = 5 gen = TSPGenerator(self._num_points) self._data = gen.generate() self._distances = distance_matrix(self._data, self._data) popGen = SimplePopulationGenerator(self._pop_size) self._population = popGen.generate(self._distances[0]) def test_mutate_single(self): mutator = InsertionMutation(1.0) pop = np.array([[1, 2, 3, 4, 5, 6, 7]]) new_pop = mutator.mutate(pop.copy()) np.testing.assert_array_equal(pop[0], np.sort(new_pop[0])) def test_mutate(self): mutator = InsertionMutation(1.0) new_pop = mutator.mutate(self._population.copy()) nose.tools.assert_equal(new_pop.shape, self._population.shape) nose.tools.assert_true(np.any(new_pop != self._population))
32.373913
70
0.674725
462
3,723
5.179654
0.145022
0.045132
0.04346
0.040953
0.834099
0.787296
0.787296
0.787296
0.787296
0.787296
0
0.019441
0.212463
3,723
114
71
32.657895
0.796726
0
0
0.822785
0
0
0
0
0
0
0
0
0.139241
1
0.139241
false
0
0.088608
0
0.278481
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
92981972f37fcc016ce2da0ef71612c139a3d12a
5,568
py
Python
stac_fastapi_asset_search/client.py
cedadev/stac-asset-search-ext
aaacd7d072ec89f016361a856f42d3c5bac3b486
[ "BSD-3-Clause" ]
null
null
null
stac_fastapi_asset_search/client.py
cedadev/stac-asset-search-ext
aaacd7d072ec89f016361a856f42d3c5bac3b486
[ "BSD-3-Clause" ]
null
null
null
stac_fastapi_asset_search/client.py
cedadev/stac-asset-search-ext
aaacd7d072ec89f016361a856f42d3c5bac3b486
[ "BSD-3-Clause" ]
null
null
null
"""Base clients.""" import abc from datetime import datetime from typing import List, Optional, Union import attr from .types import Asset, AssetCollection, AssetSearchPostRequest, AssetSearchGetRequest from stac_fastapi.types.extension import ApiExtension from stac_fastapi.api.models import create_request_model NumType = Union[float, int] @attr.s # type:ignore class BaseAssetSearchClient(abc.ABC): """Defines a pattern for implementing STAC asset search endpoint.""" extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list)) def extension_is_enabled(self, extension: str) -> bool: """Check if an api extension is enabled.""" return any([type(ext).__name__ == extension for ext in self.extensions]) @abc.abstractmethod def post_asset_search( self, search_request: AssetSearchPostRequest, **kwargs ) -> AssetCollection: """Cross catalog asset search (POST). Called with `POST /asset/search`. Args: search_request: search request parameters. Returns: AssetCollection containing assets which match the search criteria. """ ... @abc.abstractmethod def get_asset_search( self, ids: Optional[List[str]] = None, items: Optional[List[str]] = None, collection: Optional[str] = None, bbox: Optional[List[NumType]] = None, datetime: Optional[Union[str, datetime]] = None, role: Optional[List[str]] = None, limit: Optional[int] = 10, query: Optional[str] = None, token: Optional[str] = None, fields: Optional[List[str]] = None, sortby: Optional[str] = None, **kwargs, ) -> AssetCollection: """Cross catalog asset search (GET). Called with `GET /asset/search`. Returns: AssetCollection containing assets which match the search criteria. """ ... @abc.abstractmethod def get_assets(self, collection_id: str, item_id: str, **kwargs,) -> AssetCollection: """item assets (GET). Called with `GET /collection/{collection_id}/items/{item_id}/assets`. Returns: AssetCollection containing assets for given item. """ ... @abc.abstractmethod def get_asset(self, collection_id: str, item_id: str, asset_id: str, **kwargs,) -> Asset: """asset (GET). Called with `GET /collection/{collection_id}/items/{item_id}/assets/{asset_id}`. Returns: Asset containing asset for given id. """ ... @attr.s # type:ignore class AsyncBaseAssetSearchClient(abc.ABC): """Defines a pattern for implementing STAC asset search endpoint.""" extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list)) def extension_is_enabled(self, extension: str) -> bool: """Check if an api extension is enabled.""" return any([type(ext).__name__ == extension for ext in self.extensions]) @abc.abstractmethod def post_asset_search( self, search_request: AssetSearchPostRequest, **kwargs ) -> AssetCollection: """Cross catalog asset search (POST). Called with `POST /asset/search`. Args: search_request: search request parameters. Returns: AssetCollection containing assets which match the search criteria. """ ... @abc.abstractmethod def get_asset_search( self, ids: Optional[List[str]] = None, items: Optional[List[str]] = None, collection: Optional[str] = None, bbox: Optional[List[NumType]] = None, datetime: Optional[Union[str, datetime]] = None, role: Optional[List[str]] = None, limit: Optional[int] = 10, query: Optional[str] = None, token: Optional[str] = None, fields: Optional[List[str]] = None, sortby: Optional[str] = None, **kwargs, ) -> AssetCollection: """Cross catalog asset search (GET). Called with `GET /asset/search`. Returns: AssetCollection containing assets which match the search criteria. """ ... @abc.abstractmethod def get_assets(self, collection_id: str, item_id: str, **kwargs,) -> AssetCollection: """item assets (GET). Called with `GET /collection/{collection_id}/items/{item_id}/assets`. Returns: AssetCollection containing assets for given item. """ ... @abc.abstractmethod def get_asset(self, collection_id: str, item_id: str, asset_id: str, **kwargs,) -> Asset: """asset (GET). Called with `GET /collection/{collection_id}/items/{item_id}/assets/{asset_id}`. Returns: Asset containing asset for given id. """ ... def create_asset_search_get_request_model( extensions, base_model: AssetSearchGetRequest = AssetSearchGetRequest ): """Wrap create_request_model to create the GET request model.""" return create_request_model( "AssetSearchGetRequest", base_model=base_model, extensions=extensions, request_type="GET", ) def create_asset_search_post_request_model( extensions, base_model: AssetSearchPostRequest = AssetSearchPostRequest ): """Wrap create_request_model to create the POST request model.""" return create_request_model( "AssetSearchPostRequest", base_model=base_model, extensions=extensions, request_type="POST", )
33.341317
93
0.633441
595
5,568
5.796639
0.156303
0.051029
0.04639
0.044071
0.849522
0.819948
0.799072
0.779936
0.751522
0.751522
0
0.000967
0.256825
5,568
166
94
33.542169
0.832528
0.296157
0
0.782609
0
0
0.014104
0.01213
0
0
0
0
0
1
0.130435
false
0
0.076087
0
0.293478
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
2baef738c5c00687be8fa00eeae91290de2c0332
3,979
py
Python
vmware-ose-common-test-suites/prj/test_data/test_object/test_object.py
csgtree/object-storage-extension-samples
397f3033ddd4aa1bb1e2079a9e77309a78cc0b0d
[ "Apache-2.0" ]
6
2020-09-11T02:52:42.000Z
2021-04-19T11:20:42.000Z
vmware-ose-common-test-suites/prj/test_data/test_object/test_object.py
csgtree/object-storage-extension-samples
397f3033ddd4aa1bb1e2079a9e77309a78cc0b0d
[ "Apache-2.0" ]
5
2020-12-21T20:14:59.000Z
2022-03-21T14:35:43.000Z
vmware-ose-common-test-suites/prj/test_data/test_object/test_object.py
csgtree/object-storage-extension-samples
397f3033ddd4aa1bb1e2079a9e77309a78cc0b0d
[ "Apache-2.0" ]
4
2021-07-20T09:07:52.000Z
2022-03-21T14:33:44.000Z
from framework.libs.common.utils import load_csv import os # TODO def test_copy_object_provider(): f_name = "test_copy_object_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_delete_object_provider(): f_name = "test_delete_object_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_delete_object_tagging_provider(): f_name = "test_delete_object_tagging_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_delete_objects_provider(): f_name = "test_delete_objects_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_list_objects_provider(): f_name = "test_list_objects_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_list_objects_v2_provider(): f_name = "test_list_objects_v2_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_multipart_upload_provider(): f_name = "test_multipart_upload_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_object_acl_provider(): f_name = "test_object_acl.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_provider(): f_name = "test_put_object_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_provider(): f_name = "test_get_object_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_head_object_provider(): f_name = "test_head_object_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_tagging_provider(): f_name = "test_put_object_tagging_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_tagging_provider(): f_name = "test_get_object_tagging_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_lock_configuration_provider(): f_name = "test_put_object_lock_configuration_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_lock_configuration_provider(): f_name = "test_get_object_lock_configuration_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_retention_provider(): f_name = "test_put_object_retention_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_retention_provider(): f_name = "test_get_object_retention_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_legal_hold_provider(): f_name = "test_put_object_legal_hold_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_legal_hold_provider(): f_name = "test_get_object_legal_hold_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_put_object_acl_provider(): f_name = "test_put_object_acl_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_get_object_acl_provider(): f_name = "test_get_object_acl_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) def test_list_object_versions_provider(): f_name = "test_list_object_versions_prov.csv" folder = os.path.dirname(__file__) return load_csv(os.path.join(folder, f_name)) if __name__ == "__main__": pass
28.421429
58
0.749686
620
3,979
4.282258
0.070968
0.082863
0.107721
0.140866
0.932957
0.896422
0.769115
0.723917
0.723917
0.723917
0
0.000587
0.143001
3,979
139
59
28.625899
0.778006
0.001005
0
0.478261
0
0
0.170652
0.163856
0
0
0
0.007194
0
1
0.23913
false
0.01087
0.021739
0
0.5
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
7
2bb50e9239c756b8398da4da092e7d9c3b7b8440
139
py
Python
src/sdios/api/sdis/__init__.py
hyperqube-io/sdios-api-sdk
17b9b2062933f2dd39cc5e929cd439eab60eba8a
[ "MIT" ]
null
null
null
src/sdios/api/sdis/__init__.py
hyperqube-io/sdios-api-sdk
17b9b2062933f2dd39cc5e929cd439eab60eba8a
[ "MIT" ]
null
null
null
src/sdios/api/sdis/__init__.py
hyperqube-io/sdios-api-sdk
17b9b2062933f2dd39cc5e929cd439eab60eba8a
[ "MIT" ]
null
null
null
from sdios.api.sdis.machine import MachineDriver from sdios.api.sdis.network import NetworkDriver from sdios.api.sdis.sdi import SDIDriver
34.75
48
0.848921
21
139
5.619048
0.52381
0.228814
0.305085
0.40678
0
0
0
0
0
0
0
0
0.086331
139
3
49
46.333333
0.929134
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
a69a0b577ea2950bef0ff2df42d1195edf26a35a
123
py
Python
src/syntaxd/__init__.py
noe/iterative_expansion_lms
a5533a60f6f749673dae2329eeae0646ee2b740d
[ "MIT" ]
5
2020-11-25T11:26:27.000Z
2021-03-31T14:19:40.000Z
src/syntaxd/__init__.py
noe/iterative_expansion_lms
a5533a60f6f749673dae2329eeae0646ee2b740d
[ "MIT" ]
1
2021-05-12T13:51:15.000Z
2021-05-12T13:51:15.000Z
src/syntaxd/__init__.py
noe/iterative_expansion_lms
a5533a60f6f749673dae2329eeae0646ee2b740d
[ "MIT" ]
null
null
null
from syntaxd.fairseq.task import * from syntaxd.fairseq.model.transformer import * from syntaxd.fairseq.criterion import *
30.75
47
0.821138
16
123
6.3125
0.5
0.326733
0.534653
0.475248
0
0
0
0
0
0
0
0
0.097561
123
4
48
30.75
0.90991
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
a69fac406e557948f64765a9dc163e61e0ab0ea9
6,708
py
Python
components/micropython/modules/hackerhotel2019/dashboard/resources/png_icons.py
badgeteam/Firmware
6192b2902c70beb7a298a256d9087274d045fbc0
[ "Apache-2.0" ]
7
2019-02-11T10:02:14.000Z
2019-08-02T00:08:45.000Z
components/micropython/modules/hackerhotel2019/dashboard/resources/png_icons.py
badgeteam/Firmware
6192b2902c70beb7a298a256d9087274d045fbc0
[ "Apache-2.0" ]
17
2019-01-05T18:02:11.000Z
2019-03-09T21:46:43.000Z
components/micropython/modules/hackerhotel2019/dashboard/resources/png_icons.py
badgeteam/Firmware
6192b2902c70beb7a298a256d9087274d045fbc0
[ "Apache-2.0" ]
4
2019-02-15T16:03:20.000Z
2019-06-27T22:23:24.000Z
import uos names = ["alert", "bell", "bug", "busy", "charge", "crown", "earth", "flag", "music", "ok", "wifi", "usb"] data = [ b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x14\x00\x00\x00\x14\x01\x03\x00\x00\x00\xb7G\x8fN\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00LIDAT\x08\x99c`H\xe0c`\xf8\xc0\xc0\xc08\x03\x82\x99y\x18\x18\xd8\x81Blll\x0c<I@\x9c\x0c\xc4\x89}\x0c\x12\x89m\x0c\x16@l\x90p\x8a\xc1\x80\xc1\x8d!!!\r\x88\xf3\x18\x0e0X\x01\xb1\x1dC\xfd\xffg\x0c\xf6\xff\x8f\x01\x00\xf0\xb1\x11MT\xfap\xc9\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x18\x01\x03\x00\x00\x00\xda\xb9\xaf\xbb\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00CIDAT\x08\x99c`\x90``\x00c\x1b \xfe\xcf\xc0\xc0x\xb8\x81\x81\x99\xe1\x00\x18\xb31$``\x16\x06\x05\x06\x1e\x06\x030\x96`\x90a(`\xe0cx\xc0\xc0\x0e\xd6\xf1\xff\xff\x7f0f8\x0c4\xab\x0el&\x00{#\x10\xa3`\x06\xc4l\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x16\x01\x03\x00\x00\x00\xe0\xb3\xce\xcb\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00[IDAT\x08\x99c`\xb0a``\xf8\xcf\xc0\xc0\xf8\xb8\x81!\xf9\xf9\x11\x06c\xb7s\x0cv\x0c5\x0c|\x0c\x05\x0clu\t\x0c\xec\xff\x1f0\xb07<`\xf8\xc7P\x0f\xc4u\x0cL\x0c\x0e\x0c\xcc\x0c\x07\xc0\x98\x9d\xe1\x01\x03?\xc3\x07\x06\xd9\xc6\x1d\x0c\x96\x07g0\x08\x1c\xe6`\x00*a\x00\x9a\t\x00\x10J\x16\x82>\x15\x0e\x1c\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x18\x01\x03\x00\x00\x00\xda\xb9\xaf\xbb\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00CIDAT\x08\x99c`\xb0a`\x00\xe34\x06\x06\xfe\xe7\x1f\x18\xe4\x1b\x7f0H\xc0\xa0\r\x10\xff\x93`08\xcc\xc3\xf0\xb1\xb1\x9f\xe1`c3\x10\xb7\x83\xd9 1\x89:\xa8\x1a(\x04\xe9\x05\x99\xc1\x90\x075\xd3\x86\x01\x00\x18\xd4\x15\xc3k\x11\x9cS\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x13\x01\x03\x00\x00\x00\xb0~_x\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00HIDAT\x08\x99c`0``\x00a\xbb\xf4\x07\x0cu\xe9?\x18\x0e8H0\x1c8 \x03\xc4|\x0c\x07\xdb\x99\x19\x0e\xfegf8\xfc\r\x88\xdb\x98\x19\x0e\xb0\xf11\x1c\xe0\x01\xca\xf1H0\xd4\xcf\xfc\x00\xc4\x0f\x18\x18$ \xfa\x81\x18\x00Vo\x153\x8f\x91\xc9\xc4\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x16\x00\x00\x00\x16\x01\x03\x00\x00\x00\xfez\xfex\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5\xd9\x9f\xdd\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00LIDAT\x08\x99c\x90?\xff\x81\x81\xbf\xf9\x00\x83\xbaq\x03\x10O`Po\x9f\xc0\xc0\xdf~\x80\x81\xff\xfc!\x06\xf9\xf6G`\xcco|\x88A\xadr\x12\x83A\x85\x11\x83\xc5\x9f"\x06\x9b?\x9f\x18\xec\xff#0\x03\x03\x13\x18C\xd8\x0c\x0c\r\x0c,\x00 I\x1c`\x15\xe0;_\x00\x00\x00\x00IEND\xaeB`\x82', b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x18\x01\x03\x00\x00\x00\xda\xb9\xaf\xbb\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00]IDAT\x08\x99c`\xa8c``\xfc\xdf\xc0\xc0\xde\xfc\x80\x81\x9f\xbd\x80A\xbaO\x82\xc1\xb0\x87\x87\xc1\xe0x\x1fC\xc2\xe1\x7f\x0c\t\x07\xe4\x18\x0e633\x1cn?\xccp\x98'\x99\xe1\x18\x08K@h7\x9ec\x0cI@l\xcc\xda\xc3`\xcc\xde\xc3 \xcf.\xc1\xc0\xcfP\xc0\xc0\xde\xf8\x00l&\xd0l\x000+\x1a\x87\xfapJ\xaf\x00\x00\x00\x00IEND\xaeB`\x82", b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x16\x00\x00\x00\x18\x01\x03\x00\x00\x00\xc4p\x9f\x08\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5\xd9\x9f\xdd\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00PIDAT\x08\x99c\xb0\xff\xff\x87\xc1\xc2\xfe\x0f\x03\x03\xff\x1f\x06\xfe\xe3\x7f\x18\xec\x9f\xff\x00\xe2\x0f\x0c\xf6\x8f\x9b\x18\xec\x1f0\x01\xd9\x05@\xfc\t"\x06\xa4\r\xd2?10\xb0\x7f`\x90o\x07\x8a\xcd\x87\xe1C\x0c\xf6}|@\xf5v\x0c\xf6\xff\xffA\xf1\x1f\x10\x06\x00\xa3\xd5)\xdc\x13\n\x03\x9f\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x18\x01\x03\x00\x00\x00\xda\xb9\xaf\xbb\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00KIDAT\x08\x99]\xca\xb1\r@P\x14@\xd1\x93\x18\xc0\x02b6\xb6\x90HP\xb1\xd6\xfbQ\x18\xc4\x02&\xf8\xbcZq\x8a\x9b\\t\xa8\xb47K\xc3\xd0\x12/Wv\xcd~R\xfc\xcd\x94|\xceC\x7f6\xd64\x96]\x94*b2n\xac\xa9\xe7\x03f\xfe\x19\xf1\x0c\x08\x07\xad\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x15\x00\x00\x00\x12\x01\x03\x00\x00\x00\x8e\xdc\x07m\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00LIDAT\x08\x99c``8\xc2\xc0\xc0\xf8\x81\x81\x81\xd9\x80\x81\x81]\x82\xc1\x80\xc7\x80\xa1B\xa6\x80\xe1\x8f\xc1\x13\x86s\x85\x87\x18\x8e?lap>\xcc\xc6\x90\xd8\xc6\x06\x94c`\x90\x90``\x00*a`K`c`?\xc0\xc6\xc0\x08\xc2\rl\x007h\x0e\xdd\xc9\x1e_\x00\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x14\x00\x00\x00\x14\x01\x03\x00\x00\x00\xb7G\x8fN\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00OIDAT\x08\x99c\xb0a\xe0f\x90?\xc0\xc0\xc0\xf8\x80\x81\x81\xc1\x02\x88e\x80\x98\r\x88\x99\xd9\x18,\x18\xdb\x18\xec\x19\x8f107\x9cc`x\x90\xc6\xc0\x90\x00\xc4\x06Y@\xac\xc6` a\xc6P#a\xc7pF\xc2\x8a\xe1\x8c\x80\x1eC\x05P\x13\x10\x03\x00\xd4\xc6\x0c\xf1\xebT\xa8:\x00\x00\x00\x00IEND\xaeB`\x82', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x002\x00\x00\x00\x18\x01\x03\x00\x00\x00\x82\xc6<\xa2\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x01\x8e\x00\x00\x01\x8e\x01\xccj\xb7J\x00\x00\x00\x19tEXtSoftware\x00www.inkscape.org\x9b\xee<\x1a\x00\x00\x00aIDAT\x08\x99c`@\x00~(-\xdf\x00\xa6\xd8\xffChy\x18\r\x15\xb7\x01\xab\x93g\xa8\x00\xf3\xec\x1b>\x80\xe9\xfa\x83\x0f\x18\x18d\x80\xf4\xf1\x03\x0c\x0cr@\xfa?\x084 \xe8\x03\xfc\r`\xf1\x03\xec\x07@\xea\xec\x1b\x98\x1f@\xcca|\x00\xb5\xf7\x83=\x84\xae\x81\xd2\xf6\xff\xa1\xee\x81\xd2\x0c\xf6h4\x10\x00\x006r"\xea\xb6sIe\x00\x00\x00\x00IEND\xaeB`\x82' ] try: uos.mkdir('/media') except: pass media = uos.listdir('/media') for i in range(len(names)): if not names[i]+".png" in media: try: f = open("/media/"+names[i]+".png", 'wb') f.write(data[i]) f.close() except: pass
149.066667
633
0.729129
1,526
6,708
3.203145
0.216907
0.272504
0.163871
0.05401
0.480565
0.474427
0.469722
0.469722
0.469722
0.453151
0
0.30292
0.014759
6,708
44
634
152.454545
0.436677
0
0
0.206897
0
0.413793
0.946482
0.933512
0
0
0
0
0
1
0
false
0.068966
0.034483
0
0.034483
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
1
1
1
null
0
0
0
0
0
0
0
1
0
0
0
0
0
8
a6c7f91c25b0bddfbd85b1171655d57440f3dcce
1,865
py
Python
Validation/Rapports_automatiques/Verification/IBM_PDF/clean.py
cea-trust-platform/trust-code
c4f42d8f8602a8cc5e0ead0e29dbf0be8ac52f72
[ "BSD-3-Clause" ]
12
2021-06-30T18:50:38.000Z
2022-03-23T09:03:16.000Z
Validation/Rapports_automatiques/Verification/IBM_PDF/clean.py
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
null
null
null
Validation/Rapports_automatiques/Verification/IBM_PDF/clean.py
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
2
2021-10-04T09:19:39.000Z
2021-12-15T14:21:04.000Z
import os os.system("rm src/*/*.Zones*") os.system("rm src/*/*DEC*") os.system("rm src/*/*PAR*") os.system("rm src/*/*SEQ*") #POISEUILLE ALIGNED os.system("cd src/poiseuille_pdf_align && trust -clean") #POISEUILLE TILTED os.system("cd src/poiseuille_pdf_tilt_11_dir && trust -clean") os.system("cd src/poiseuille_pdf_tilt_11_hybrid && trust -clean") os.system("cd src/poiseuille_pdf_tilt_11_multi_dir && trust -clean") os.system("cd src/poiseuille_pdf_tilt_30_dir && trust -clean") os.system("cd src/poiseuille_pdf_tilt_30_hybrid && trust -clean") os.system("cd src/poiseuille_pdf_tilt_30_multi_dir && trust -clean") os.system("cd src/poiseuille_pdf_tilt_45_dir && trust -clean") os.system("cd src/poiseuille_pdf_tilt_45_hybrid && trust -clean") os.system("cd src/poiseuille_pdf_tilt_45_multi_dir && trust -clean") #TAYLOR COUETTE os.system("cd src/taylor_couette_pdf_dir && trust -clean") os.system("cd src/taylor_couette_pdf_hybrid && trust -clean") os.system("cd src/taylor_couette_pdf_multi_dir && trust -clean") #CYLINDER os.system("cd src/cylinder_pdf_static_re_20_dir && trust -clean") os.system("cd src/cylinder_pdf_static_re_20_hybrid && trust -clean") os.system("cd src/cylinder_pdf_static_re_20_multi_dir && trust -clean") os.system("cd src/cylinder_pdf_static_re_100_dir && trust -clean") os.system("cd src/cylinder_pdf_static_re_100_hybrid && trust -clean") os.system("cd src/cylinder_pdf_static_re_100_multi_dir && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_20_dir && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_20_hybrid && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_20_multi_dir && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_100_dir && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_100_hybrid && trust -clean") os.system("cd src/cylinder_pdf_rotate_re_100_multi_dir && trust -clean")
47.820513
72
0.776944
319
1,865
4.181818
0.100313
0.173913
0.187406
0.243628
0.865817
0.865817
0.832834
0.804348
0.78036
0.6994
0
0.027923
0.078284
1,865
39
73
47.820513
0.748109
0.030563
0
0
0
0
0.764543
0.468698
0
0
0
0
0
1
0
true
0
0.033333
0
0.033333
0
0
0
0
null
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
null
0
0
0
0
0
0
1
0
0
0
0
0
0
11
5bdbf37e6b9276fbf48ed7bd3ac9926107f80886
140
py
Python
pyfacebook/api/instagram_basic/resource/__init__.py
sns-sdks/python-facebook
9536d30393dee8b2a887b81f103d76262a677eee
[ "Apache-2.0" ]
181
2019-08-28T10:03:49.000Z
2022-03-26T19:36:05.000Z
pyfacebook/api/instagram_basic/resource/__init__.py
sns-sdks/python-facebook
9536d30393dee8b2a887b81f103d76262a677eee
[ "Apache-2.0" ]
159
2019-08-28T10:07:43.000Z
2022-03-30T16:42:23.000Z
pyfacebook/api/instagram_basic/resource/__init__.py
sns-sdks/python-facebook
9536d30393dee8b2a887b81f103d76262a677eee
[ "Apache-2.0" ]
40
2019-09-10T20:12:47.000Z
2022-03-12T16:16:46.000Z
from pyfacebook.api.instagram_basic.resource.user import IGBasicUser from pyfacebook.api.instagram_basic.resource.media import IGBasicMedia
46.666667
70
0.885714
18
140
6.777778
0.611111
0.229508
0.278689
0.42623
0.639344
0.639344
0
0
0
0
0
0
0.057143
140
2
71
70
0.924242
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
750c0f6009442b2042080833151a9be6076073a0
7,879
py
Python
tests/core/test_print_tty.py
bhardiegodaddy/aws-okta-processor
a78e99dcfbdc03135cab509e3784308f66c2d825
[ "MIT" ]
63
2019-02-28T16:39:35.000Z
2022-03-04T19:36:17.000Z
tests/core/test_print_tty.py
bhardiegodaddy/aws-okta-processor
a78e99dcfbdc03135cab509e3784308f66c2d825
[ "MIT" ]
42
2019-04-12T22:18:15.000Z
2022-03-18T01:28:48.000Z
tests/core/test_print_tty.py
bhardiegodaddy/aws-okta-processor
a78e99dcfbdc03135cab509e3784308f66c2d825
[ "MIT" ]
16
2019-03-16T20:40:56.000Z
2022-03-29T13:59:38.000Z
from unittest import TestCase from mock import patch from mock import call from mock import MagicMock import aws_okta_processor.core.print_tty as print_tty class Test(TestCase): @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty( self, mock_io, mock_os, mock_conextlib2, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value = mock_stack mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper calls = [ call(u'STRING'), call(u'\n') ] print_tty.print_tty("STRING") mock_text_wrapper.write.assert_has_calls(calls) mock_os.open.assert_called_once() @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty_no_newline( self, mock_io, mock_os, mock_conextlib2, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value.__enter__.return_value = mock_stack # noqa mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper print_tty.print_tty("STRING", newline=False) mock_os.open.assert_called_once() mock_stack.enter_context.called_once_with(mock_text_wrapper) mock_text_wrapper.write.assert_called_once_with(u'STRING') mock_text_wrapper.flush.assert_called_once() @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty_indent( self, mock_io, mock_os, mock_conextlib2, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value.__enter__.return_value = mock_stack # noqa mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper print_tty.print_tty("STRING", indents=1, newline=False) mock_os.open.assert_called_once() mock_stack.enter_context.called_once_with(mock_text_wrapper) mock_text_wrapper.write.assert_called_once_with(u' STRING') mock_text_wrapper.flush.assert_called_once() @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.sys.stdout') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty_print( self, mock_io, mock_os, mock_conextlib2, mock_print, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value.__enter__.return_value = mock_stack # noqa mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper mock_os.open.side_effect = OSError calls = [ call(u'STRING'), call(u'\n') ] print_tty.print_tty("STRING") mock_print.write.assert_has_calls(calls) mock_stack.close.assert_called_once() mock_text_wrapper.write.assert_not_called() @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.sys.stdout') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty_print_no_newline( self, mock_io, mock_os, mock_conextlib2, mock_print, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value.__enter__.return_value = mock_stack # noqa mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper mock_os.open.side_effect = OSError print_tty.print_tty("STRING", newline=False) mock_print.write.assert_called_once_with("STRING") mock_stack.close.assert_called_once() mock_text_wrapper.write.assert_not_called() @patch('aws_okta_processor.core.print_tty.import_msvcrt') @patch('aws_okta_processor.core.print_tty.sys.stdout') @patch('aws_okta_processor.core.print_tty.contextlib2') @patch('aws_okta_processor.core.print_tty.os') @patch('aws_okta_processor.core.print_tty.io') def test_unix_print_tty_print_indent( self, mock_io, mock_os, mock_conextlib2, mock_print, mock_import_msvcrt ): mock_import_msvcrt.side_effect = ImportError mock_stack = MagicMock() mock_conextlib2.ExitStack.return_value.__enter__.return_value = mock_stack # noqa mock_text_wrapper = MagicMock() mock_io.TextIOWrapper.return_value = mock_text_wrapper mock_os.open.side_effect = OSError print_tty.print_tty("STRING", indents=1, newline=False) mock_print.write.assert_called_once_with(" STRING") mock_stack.close.assert_called_once() mock_text_wrapper.write.assert_not_called() @patch('aws_okta_processor.core.print_tty.import_msvcrt') def test_win_print_tty(self, mock_import_msvcrt): mock_msvcrt = MagicMock() mock_import_msvcrt.return_value = mock_msvcrt calls = ([], []) for char in list("STRING\r\n"): calls[0].append(call(char)) calls[1].append(call(bytes(char.encode()))) print_tty.print_tty("STRING") try: mock_msvcrt.putch.assert_has_calls(calls[0]) except AssertionError: mock_msvcrt.putch.assert_has_calls(calls[1]) @patch('aws_okta_processor.core.print_tty.import_msvcrt') def test_win_print_tty_no_newline(self, mock_import_msvcrt): mock_msvcrt = MagicMock() mock_import_msvcrt.return_value = mock_msvcrt calls = ([], []) for char in list("STRING"): calls[0].append(call(char)) calls[1].append(call(bytes(char.encode()))) print_tty.print_tty("STRING", newline=False) mock_import_msvcrt.assert_called() try: mock_msvcrt.putch.assert_has_calls(calls[0]) except AssertionError: mock_msvcrt.putch.assert_has_calls(calls[1]) @patch('aws_okta_processor.core.print_tty.import_msvcrt') def test_win_print_tty_indent(self, mock_import_msvcrt): mock_msvcrt = MagicMock() mock_import_msvcrt.return_value = mock_msvcrt calls = ([], []) for char in list(" STRING"): calls[0].append(call(char)) calls[1].append(call(bytes(char.encode()))) print_tty.print_tty("STRING", indents=1, newline=False) mock_import_msvcrt.assert_called() try: mock_msvcrt.putch.assert_has_calls(calls[0]) except AssertionError: mock_msvcrt.putch.assert_has_calls(calls[1])
37.341232
90
0.674832
994
7,879
4.924547
0.075453
0.096425
0.101328
0.12666
0.972421
0.968948
0.94954
0.94954
0.94954
0.947089
0
0.005442
0.230359
7,879
210
91
37.519048
0.801781
0.003046
0
0.886486
0
0
0.175691
0.160148
0
0
0
0
0.151351
1
0.048649
false
0
0.183784
0
0.237838
0.297297
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
755c22370f1b6bc7d1af3dc14a5cd4ad5d40a140
111
py
Python
merkle_prefix_tree/__init__.py
abadhikari/merkle-prefix-tree
beac8c47c544d1ce1d507eadafbe694c0ac67a61
[ "MIT" ]
null
null
null
merkle_prefix_tree/__init__.py
abadhikari/merkle-prefix-tree
beac8c47c544d1ce1d507eadafbe694c0ac67a61
[ "MIT" ]
null
null
null
merkle_prefix_tree/__init__.py
abadhikari/merkle-prefix-tree
beac8c47c544d1ce1d507eadafbe694c0ac67a61
[ "MIT" ]
1
2021-12-02T08:31:27.000Z
2021-12-02T08:31:27.000Z
from merkle_prefix_tree.tree import MerklePrefixTree from merkle_prefix_tree.exceptions import AppendOnlyError
55.5
57
0.90991
14
111
6.928571
0.571429
0.206186
0.329897
0.412371
0
0
0
0
0
0
0
0
0.072072
111
2
57
55.5
0.941748
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
f3433894ff8d695fb1e2497632a47ce34d447dd9
13,376
py
Python
pybench/Exceptions.py
haypo/pymicrobench
7c6b92deaf5cf0c3fc965fcfcbc6a78f7d0d10f4
[ "MIT" ]
3
2018-01-17T18:45:23.000Z
2020-10-02T06:26:03.000Z
pybench/Exceptions.py
vstinner/pymicrobench
7c6b92deaf5cf0c3fc965fcfcbc6a78f7d0d10f4
[ "MIT" ]
null
null
null
pybench/Exceptions.py
vstinner/pymicrobench
7c6b92deaf5cf0c3fc965fcfcbc6a78f7d0d10f4
[ "MIT" ]
4
2018-01-17T18:45:23.000Z
2020-10-08T15:24:51.000Z
# Ignore flake8 E722 warning in the whole file: # flake8: noqa import pyperf from six.moves import xrange from pybench import Test class TryRaiseExcept(Test): version = 2.0 operations = 2 + 3 + 3 inner_loops = 8 def test(self, loops): error = ValueError range_it = xrange(loops) t0 = pyperf.perf_counter() for _ in range_it: try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass try: raise error("something") except: pass return pyperf.perf_counter() - t0 class TryExcept(Test): version = 2.0 operations = 15 * 10 # try/except repeated 150 times! inner_loops = 150 def test(self, loops): range_it = xrange(loops) t0 = pyperf.perf_counter() for _ in range_it: try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass try: pass except: pass return pyperf.perf_counter() - t0
19.44186
47
0.243122
743
13,376
4.3607
0.065949
0.487654
0.625926
0.787037
0.925926
0.911728
0.911728
0.896296
0.896296
0.896296
0
0.007381
0.726525
13,376
687
48
19.47016
0.878349
0.006654
0
0.984709
0
0
0.00542
0
0
0
0
0
0
1
0.003058
false
0.470948
0.004587
0
0.022936
0
0
0
0
null
1
1
1
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
12
f3877c95da836efb30850a70a58dbe2d7d78ec9c
11,423
py
Python
platform/core/tests/test_auditor/test_auditor_permission.py
hackerwins/polyaxon
ff56a098283ca872abfbaae6ba8abba479ffa394
[ "Apache-2.0" ]
null
null
null
platform/core/tests/test_auditor/test_auditor_permission.py
hackerwins/polyaxon
ff56a098283ca872abfbaae6ba8abba479ffa394
[ "Apache-2.0" ]
null
null
null
platform/core/tests/test_auditor/test_auditor_permission.py
hackerwins/polyaxon
ff56a098283ca872abfbaae6ba8abba479ffa394
[ "Apache-2.0" ]
null
null
null
# pylint:disable=ungrouped-imports from unittest.mock import patch import pytest import auditor from events.registry import permission as permission_events from tests.test_auditor.utils import AuditorBaseTest @pytest.mark.auditor_mark class AuditorPermissionTest(AuditorBaseTest): """Testing subscribed events""" EVENTS = permission_events.EVENTS def setUp(self): super().setUp() self.tested_events = { permission_events.PERMISSION_PROJECT_DENIED, permission_events.PERMISSION_REPO_DENIED, permission_events.PERMISSION_EXPERIMENT_GROUP_DENIED, permission_events.PERMISSION_EXPERIMENT_DENIED, permission_events.PERMISSION_TENSORBOARD_DENIED, permission_events.PERMISSION_NOTEBOOK_DENIED, permission_events.PERMISSION_BUILD_JOB_DENIED, permission_events.PERMISSION_EXPERIMENT_JOB_DENIED, permission_events.PERMISSION_CLUSTER_DENIED, permission_events.PERMISSION_USER_ROLE_DENIED, } @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_project_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_PROJECT_DENIED, id=1, user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_repo_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_REPO_DENIED, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_experiment_group_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_EXPERIMENT_GROUP_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_experiment_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_EXPERIMENT_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_tensorboard_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_TENSORBOARD_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_notebook_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_NOTEBOOK_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_build_job_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_BUILD_JOB_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_experiment_job_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_EXPERIMENT_JOB_DENIED, id=1, user_id=2, project_id=1, project_user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_cluster_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_CLUSTER_DENIED, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 @patch('executor.executor_service.ExecutorService.record_event') @patch('notifier.service.NotifierService.record_event') @patch('tracker.service.TrackerService.record_event') @patch('activitylogs.service.ActivityLogService.record_event') def test_permission_user_role_denied(self, activitylogs_record, tracker_record, notifier_record, executor_record): auditor.record(event_type=permission_events.PERMISSION_USER_ROLE_DENIED, user_id=2, actor_id=1, actor_name='foo', event='some.event') assert tracker_record.call_count == 1 assert activitylogs_record.call_count == 1 assert notifier_record.call_count == 0 assert executor_record.call_count == 0 del AuditorBaseTest
44.972441
87
0.565701
1,011
11,423
6.059347
0.064293
0.089781
0.097943
0.052236
0.934215
0.887202
0.853738
0.853738
0.853738
0.853738
0
0.010906
0.365841
11,423
253
88
45.150198
0.83476
0.005165
0
0.806306
0
0
0.18225
0.170805
0
0
0
0
0.18018
1
0.04955
false
0
0.022523
0
0.081081
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
f3953eab61ec80e70e1d8ec938382866c724f9e1
176
py
Python
{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/models/__init__.py
leotang1218/cookiecutter-flask-restful
fce15fefaa86a8818f9ea4cdb1f841066ca9efec
[ "MIT" ]
null
null
null
{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/models/__init__.py
leotang1218/cookiecutter-flask-restful
fce15fefaa86a8818f9ea4cdb1f841066ca9efec
[ "MIT" ]
null
null
null
{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/models/__init__.py
leotang1218/cookiecutter-flask-restful
fce15fefaa86a8818f9ea4cdb1f841066ca9efec
[ "MIT" ]
null
null
null
from {{cookiecutter.app_name}}.models.mongo.user import User from {{cookiecutter.app_name}}.models.mongo.blacklist import TokenBlacklist __all__ = ["User", "TokenBlacklist"]
29.333333
75
0.784091
21
176
6.285714
0.52381
0.242424
0.287879
0.348485
0.515152
0.515152
0
0
0
0
0
0
0.079545
176
5
76
35.2
0.814815
0
0
0
0
0
0.102273
0
0
0
0
0
0
0
null
null
0
0.666667
null
null
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
1
0
0
0
1
0
0
0
0
7
f3ab152e8f323507dd9f596711d9bee546123602
939,477
py
Python
projects/src/main/python/CodeJam/Y14R5P1/frank/generated_py_0d9ff97ab25c4fb6bc156877a2ccb79c.py
DynamicCodeSearch/CodeSeer
ee985ece7691691585952eb88565f0e08bdc9113
[ "MIT" ]
5
2020-04-05T18:04:13.000Z
2021-04-13T20:34:19.000Z
projects/src/main/python/CodeJam/Y14R5P1/frank/generated_py_0d9ff97ab25c4fb6bc156877a2ccb79c.py
DynamicCodeSearch/CodeSeer
ee985ece7691691585952eb88565f0e08bdc9113
[ "MIT" ]
1
2020-04-29T21:42:26.000Z
2020-05-01T23:45:45.000Z
projects/src/main/python/CodeJam/Y14R5P1/frank/generated_py_0d9ff97ab25c4fb6bc156877a2ccb79c.py
DynamicCodeSearch/CodeSeer
ee985ece7691691585952eb88565f0e08bdc9113
[ "MIT" ]
3
2020-01-27T16:02:14.000Z
2021-02-08T13:25:15.000Z
import sys sys.path.append('/home/george2/Raise/ProgramRepair/CodeSeer/projects/src/main/python') from CodeJam.Y14R5P1.frank.p1 import * def func_9366e54e3ba44f0393fb0a116c8c29d2(sum0, ps, j, i, sum1): v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) return tmp def func_c7028f344ca34ff7823f76348131104a(sum0, ps, j, i, sum1): v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) return v1 def func_6fb1b25097c1447097115949e403748c(sum0, ps, v1, i): tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp return tmp def func_a1f0562f557a423f9baa7ae207f9c00e(sum0, ps, v1, i): tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp return bestAnswer def func_000b844355f544599d61958ae02db300(sum0, ps, j, i, sum1): v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp return bestAnswer def func_90f3b1598335463eb3c9e77efda8c207(sum0, ps, j, i, sum1): v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp return v1 def func_a3df69fb6acb4556a7fcb8139937e97b(sum0, ps, j, i, sum1): v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp return tmp def func_28053e18ffdd45fbada547c100bda374(sum0, allv, i): ps = allv - sum0[i] j = max(j - 1, i) return ps def func_2d9300dabf6648b2a53a3a6a59cd1460(sum0, allv, i): ps = allv - sum0[i] j = max(j - 1, i) return j def func_4357ebc7d506405e917818171e645837(n, sum0, ps, i, sum1): j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_a6b6bd2e835a485e927b63c579748ad9(n, sum0, ps, i, sum1): j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_4ddd6652084c47b4bbb371b0eb0f1345(n, sum0, ps, i, sum1): j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_8ab0277671904ec784ebbab6587b2582(n, sum0, ps, i, sum1): j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_96fd3b22035544d8b9a161d0a5be0fda(n, sum0, allv, i, sum1): ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_6bcb6d939f8b4a32864d75b4d7d54625(n, sum0, allv, i, sum1): ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_11f053f1602649ceb8dc97d861e8b45c(n, sum0, allv, i, sum1): ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_e0204441c1974461ae9612b51f5b41f4(n, sum0, allv, i, sum1): ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_8189841da26c4077a6f3d85b33752ef2(n, sum0, allv, i, sum1): ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_d2ae85cecdad40bda843cb643c18f46d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return r def func_95a4b37503bc4dd28ff7b94e86991cf7(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return aa def func_bf52ff28569642d7a60944dc42487465(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return x def func_c838b7d4d91f430bad06a5829f8ace37(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return s def func_c3b8811def444f94af103e486f01056e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return n def func_3afbf729b7554596b73e3ae94cdb2571(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return p def func_6dfee5bd0c7043bc8a755aaa28c76414(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return q def func_638dca06c2944f44ba74880dda5b98e7(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return a def func_1de59b260157477c8776ffd6b0a0d4f8(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return x def func_453c06e558524dc6991540ac625b2528(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return aa def func_7ab1d639acef4b07974c969ebcd909ea(n, aa): a = [x for x in aa if x != 0] n = len(a) return x def func_998466b60d1f41f196fa9dc32979c281(n, aa): a = [x for x in aa if x != 0] n = len(a) return a def func_014482df6c29481195f5bbbbb9c1d9d8(n, a): n = len(a) sum0 = [0] * (n + 1) return sum0 def func_e62ab93c74314298b8702a1bd38b34ea(n): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_e2621c96e3ea4bae8b733b028513cdad(n): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_dd492eea452b4799b05134a80845410f(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_92bcd071b3aa43f3af60d6bb7a2f8232(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_71bccde17763488c9c69a0efe20e75e7(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_dbfd505a9530452eaa3b732b179894f8(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_2b9d2bcb8d5142118a41d59f31f44de5(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_72932eac3f1c4bfd9ea8f7acfa887a21(sum0): allv = sum0[-1] bestAnswer = allv return allv def func_efbd1ded4bf34b89929bd98ef823c5d1(sum0): allv = sum0[-1] bestAnswer = allv return bestAnswer def func_414765bad9154294a1d4a942c2340d97(allv): bestAnswer = allv j = 0 return bestAnswer def func_6ce0225cd2cf468db596e5a81c311b79(allv): bestAnswer = allv j = 0 return j def func_3259c31fcd554d5f8bf7cd5062f47194(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_1552e7d99a2548a0bb2366c8b8c8c7d7(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_512bede6d608413b851420d8a1e6619a(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_83d5764b9ce7425aa7eeb6841466ce5f(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_079c336c0fb743ab80d0e5358f24ac66(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_f35c6c556c7e44deac8d8fe39094145c(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_31b1e7ce378947d690e184702ce9a4c6(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_8d7704bc1f15494f94be3d0d7c63b0ca(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_3b0cd0af0d294b60ae959e753dfc0878(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_3eb440061bac4dccb14f1ed15979d85b(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_33f04e8eca56431f98ced7b68b411cf0(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_ceca3bdd3617471d96ce313e84c971e5(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_bd16243e583841a5bc45e680be630fe7(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_a5c37f862b9e4c1685e9c2ede20b690f(bestAnswer, allv): answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_cc5fcbd48eb448efbf7bbc28208cf9cd(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) return q def func_4cc01fdb4b834893ba2f427fe21a4c01(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) return r def func_6a50d26c0ced4c94b1c8f8055905d10a(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) return p def func_77485f11c9de447c82c92750bdeebdcc(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) return n def func_1af364b19df24075b40b631e30035d19(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) return s def func_e2ff5ae4b3574caf9d0dbdcf3ade4ba6(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return s def func_f9e7bee6d13d402b837bf72c4bf4a1ae(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return q def func_bb44573e15f145bc8d6e415398ce2039(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return p def func_f1962e336e424c89bae912ca60bec0e7(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return n def func_78938fe8f87c450ea82c9824da854907(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return a def func_5389c79c47cf45d4a1a68050a09081a7(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return aa def func_e638a20cbac440fb99f0427485a3d0b4(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return x def func_edfda58c65394184be19ce8e259df1a7(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return r def func_908f5a7d8e5047d5854fafa65ca0a26d(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return aa def func_f76a76d8b6894727a4e0591cf6d2b212(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return a def func_67e5dbddce5e494ba7f908f02c6085c7(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return x def func_c475271088f946249752df96d4132d70(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return x def func_04e4866f5a014a4992194383a5a4a798(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return a def func_b6d27529cad543fe9e3df1075512c8d9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return sum0 def func_1af8307fc55b4069a3fb283fefacfa1b(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_3fd410544c004fdf9d14686072a77063(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_5e53ce5c3c074d23ae3fdee5ad1a589d(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_338cc8f285504b16936e571b124e4c95(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_2537eab5812e468790a5900265fbc8c3(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_0df95f05bed345f39b4b8b22f5dc33fc(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_204a5c5a85b841fcb3085a167e2f3158(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_2a8e2dae4af14ba7a03389fef9bd81fd(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_24053d1b00f04eadb00d50d5a0cf1463(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_bc110244fa5d4914b27895a902bd530f(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_3bbf4736189c414db210dd131d594631(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_c6a6296d922a4752b39d7e8c55160575(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_32ff8cf9e1cc490d86f83d63f67111ce(sum0): allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_a3c6c434b64c41c7a7a17ac20c46f1b3(sum0): allv = sum0[-1] bestAnswer = allv j = 0 return j def func_7b752419f2cb467bb14bb825f5a1cc94(sum0): allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_f05bf0f3d2c7491bba3bc925aa1f56a2(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_2f7cfe73b6d348adb302db87a4ed9c8c(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_f4033cc4a44e4350aca39d176897b08d(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_b8172efc11794fe094cc748108a40a5e(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_d8a8a3141920491b8fc4b32d2b36f001(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_260cd9abcca3450088165e9dd506b2c0(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_50224be90ad74626a36171110642688c(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_3325da13594c4e3dba568793a5aa7375(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_199f5c3ec4ff42dbb88a0a061eb5402e(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_749721faff99486fbd096fa09bfcbfe6(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_2efc700e0792468a8eae8d7264fde12d(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_8b4096fcaa394f25a7d797818dbae5a9(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_ed5dd6c915334a65b4fc0ca7047f6884(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_f184a5a2c86d4114ac08739473dcbdd3(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_f8e996e05920479fac682fb0fd2725a9(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_a7c78ddcdba9499c80913be7c9f2be29(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_e6548378c1a545a79ec88542b98ca76c(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_9b6b482884a44dc9b3efd3081378e665(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_5a5111338c674897963c03ce3a72ebe2(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_5f4e2857e5f24824bbaa60e67abcf0ee(n, sum0, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_fa93ab2c26d8477c8034344e5a4d7f0a(bestAnswer, ouf, allv): answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_b4f99bc73db3471dbe656bdd212d304d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return q def func_3356d3b386854322aaadbc1050a76f68(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return r def func_9ee8e89202dd4a37800631498ad4af87(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return p def func_bc9d2e53737b4be385ac1f1bdbc3f134(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return aa def func_a17bf177abba400697fd7ce77f665ce8(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return s def func_7e4f1ac407fa4791a80748d2eb48ca10(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return x def func_fb1108169d5c4a7ca31abd3e9220831b(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] return n def func_32524c3a673e4348b93b53397a604bf5(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return r def func_d94d7bc0e3474f0e92f614167912bb31(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return q def func_457125fea4204106b37c5db31830963b(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return x def func_694b3d3dab9c487498678fd2eb13a706(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return a def func_47877ecab0ec4e9c9e81071ad13a732d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return aa def func_567f5f3a09df47b3a03e30ca1a257edb(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return n def func_50bc96709fd54bcf8ecab99293b3f7e7(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return s def func_c4416153b9a3489ab9afb35b62d069df(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return p def func_57b337e18ff647d999f052a3ac37f152(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return sum0 def func_4bbc4348ff404920a9335c0708a663be(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return x def func_1135ef979aa841c2ac82b9d11fe928b7(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return a def func_60204e55a15f411b8023172ff955f84c(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return aa def func_e578bf3c71d345febb8118f39719f0f1(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return a def func_cbae4854060f4287aa646d1f0b79c4bc(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return x def func_f6b150cc883b4b2aa09f432d7499988e(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_b54d84e36fce418a975f5c6bc2da8092(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_532b3915c3c24186b292f4a127a39a30(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_75b3531dc019428c8f9517e958335839(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_abb6b833b1d3466899698d273d8c289e(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_f0f1234c13c74452bb00a29a78bd0b87(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_c00e9dd98930400fbbeb48823a588114(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_616468c0e36348fd89bb65fd6294ab05(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_35a073ba7be1422e80990fbb6c531328(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_643527c7e2ae43bd8397fe0d54430250(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_f4f8ee439896485298a55c6ee4201793(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_fde07364bb19440487abfb477484096e(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_bde494b89d1946708ec5fcddfde71ef6(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_be97963aa43d47639f9887911d249bbe(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_73189a254b7e459d8eec0f2c1f4287a5(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_858808ba74f944e49ff9274e1776e349(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_c423ac1bb8d5464da48b11aa23efa38f(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_7c993343c57a47ebaecd3fb0dd9b624c(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_1f90e19c19d14a709f44cdba95a2cc88(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_c05796c9725246359567cbf207f5c6d8(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_ac514bcafbd54487a06aa3a735e914aa(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_4a05dcc493c945fc95a601b4188a76f1(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_b9a90d7f400044458060f1caf5d01362(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_9a57ce815c504b8dbb0936ca9795656f(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_c5f407b164724a6782a7824d4954f95a(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_4806ad49713940fab8202625f02d0852(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_456e8b1186c94a2cb2835cb8867d0e81(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_034852ca721447259a67b01813b9878c(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_65c3eaf8c24549e693970e25c01e6c99(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_57149673b3bc4a02865652b94afe8385(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_ae0ae396f0474f43867c0665ecf73389(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_b31528386ad54ac1a3b0d235bd29cea3(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_b383ba4a9cd64d768777b05414da41f0(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_56d0fe10e75748aa85b66b4d22bb9db2(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_616e642920c8455e9cab41dda484b05c(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_7c539937c06247ddb94244701cc33e8b(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_7502d58c257b4ec6a2d8bcc5248abbfd(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_da610328771549d8bfb4aa048fe2c000(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_65c5ede34f0247ceb3295aef049ee2ad(n, sum0, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_1bcf5111f33c4628885a0acb03566aec(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_b3a2336cf64a41c6a732c0aaa1678fa3(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_8d691b7ff59d47bdb97c04b87c938762(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_f6e6738a7b2e4825bfba3f5f1815b27a(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_427a8456422b4ea68e6760b22da25665(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_0a0c272428354dc2a7bdaaabef11e104(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_1357ab3aa1c642e5ad02067e2b34b222(n, sum0, ouf, allv, sum1): for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_7d52d2d17f204cbcab43c416163c696f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return x def func_61b0e5dbedb84e089b93c25917b04f02(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return n def func_c677675b5758479284003eb658630663(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return q def func_f8a176f99e7a441b864371ea2dcb2c71(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return r def func_0e73a06a4c864fb6b6aa44adc1f189c7(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return a def func_4ecc6336b3ca438fb9f9d2f54dd88a80(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return aa def func_a7816f1c41794a4db6ced5e90f950000(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return s def func_122a3ba8b3d84bd1ba030a38fef106da(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] return p def func_26f8479c59cc4759950490653e7b4318(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return s def func_d1e64d8cc02c4f38b4745cd32319742e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return p def func_99c45e626816421aaf843ca9ba3ba379(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return x def func_1c782f7af6204f1cbe686f9b53d1f6a3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return a def func_8460991413b44b63ab3a0d13e1c7f5f6(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return sum0 def func_a331d8bb5763432ab5a1bdeca2562e85(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return n def func_1a7e1fb3c5234889990892cc4e309455(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return r def func_9aa5a839da8e48839c6077690c732c7f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return q def func_ba4f9ccbc66746ee9b5e8549f9aaa22f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return aa def func_458ef14df1114a2d83fec0dcf9e1a89b(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_37c47c2d25ef401dbf67dc73c9832172(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return a def func_e1baa839d4bb4c74a3ea6c6d7404fff1(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_0d0e868e5213484c873452944f898844(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return aa def func_956dfd18b59a449bbffdd245ee3ddcf1(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return x def func_037abde5d6ab4ad6920080cd32ab8a5f(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return x def func_0cb7b1c68b3047259012f088e3bc4454(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_16f14a1beb3d4f36b00c02a409f030c1(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return a def func_cf2f655806cb4f5bb22358848adc8d83(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_d9f412c2946e4d7a9aedc56ca174583a(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_d858e6d8ea8445bfb8ffed333be952b5(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_8d0ff236045b47c1a5aeb5a2ef263cd9(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_e0ff05158ad94a18bf2a607845c8ac1f(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_c3c5e90443f24251a2b31aced4fc775a(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_b4bfb6954f91466194caeb83a70dd9f6(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_d153e18de50e462f90929bf8375b8d2d(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_d7070a4041f2468db64fea51f0333ff6(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_e8020623c50c468c870250a34257a8f2(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_9c4e6145d8644e88b1ea17a6ad64c261(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_dc13160f426f448e8d25ac3e455f8a21(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_7fdeea5666fd49ff80bb7baebd8984f5(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_6a7bb4733b6342c2bbad6ffd524d6d29(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_aa04559655d74cd295033600e66ab7a0(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_d5fe3b85546a4ec4acfd394b19c25278(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_d36c2152467c45da847a3b5e9b2703b3(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_825119e358ee4ed8965f98d5683c314d(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_8fc96404166a48c38cfbb4fe7d30b56a(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_2820848057234223a564adce760302e0(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_5c9d7cceba724c29a6bc2352c4dcd6aa(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_5d4497f5e0b44f2c81ca4572a2705d49(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_fe569f18e9ed4170a3a4a9ad7d56d64a(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_799744d091994369a1a87fc2ddfb35ba(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_a656b82a43b94f349b70f926f1f2e0aa(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_b221f4d75dc84a8f805ad593f5e3249f(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_b523f305588d45568c2194e7c2c85c9b(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_1d5ffaf09c55420d803ca0046bbcd6a5(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_ff1a8bbd4a174fbd919df4a30e7fc511(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_c1c6e9c70c1a4d9ab36e3e19f71d61ee(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_f96f4dd571ba4a6ab407b553a05b5ff7(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_830b6492f3d949b3b08b9f9a55fc49ab(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_e1c36c80b52a40b58137309358a8724e(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_13370d97b34f442e9c42c0081f805fa8(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_2bec56e942ec477fae52e5f139ac3a7e(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_dfd33bf259da455a9b10afc5ca00c283(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_23e6fcbcd0794e0b9fe1df58cdc9e79c(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_258899abf628419dba3aa0796e85000a(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_1b4d5cb74f574a9f9cb4f49adeab8406(n, sum0, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_c3036a9f8ac84803bec6ae110c2f56a9(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_44259e40bb874de1800c160a3727ae34(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_a6866f91b62146bba355c6c3693ae772(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_3848d766335d40298d73c6ff0433be5a(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_6348ddc8ba9f4670b085ee752c631629(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_90e1d9a9f4fc4391bee8dbe3dec27785(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_b68c1906a7524130b55afd22fb6674cb(n, sum0, ouf, allv, sum1): j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_723662e2dce5414d9f650c38a152320d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return q def func_771f2aeca1fb410880bb55c151fba569(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return aa def func_ea4577b9ecf540779ef09aef66fcac76(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return r def func_cbcf58def12d4e56b2840b6891399c0e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return p def func_377e4f9e8aaa40ef85ecf82219e6c8c6(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return s def func_96529c968f2b4bc7a02f1680b376b021(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return n def func_4afe3fd042f143cba06b86d1d85bdb05(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return x def func_d9431e6d5bb64ff0a5d4f3e421efa86c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) return a def func_64882aea1d6e44bda7e70d6b0b249996(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_3b4f9fc6ad89402ca01c027b2ea88622(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return p def func_4de5b2a83abd4cfd9d49383292d6e54a(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_3823b9e0fbfc4f83a62fd7eee86a35be(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return a def func_ff2cde9df1c34d5eabb1e6a5fa8a5903(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return aa def func_219bc09a62f24d759e8cd6d20cc10fe6(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return q def func_8b234d3b987d43d5b4bc13d750e79b3c(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return s def func_909f02ceee42482489c9c443506a9dd3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return n def func_4b9ec07f64794fc798391e61d5b6aff6(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return x def func_6952c66b52be4976ac8596cae4608b01(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return r def func_41f29f6ac7354f1b9da3678bfd427a75(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return aa def func_d1e571d2ff164f9cbf6f1d838165fe9a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return x def func_765cfab86755446994cc9f2b7425f354(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_1f40a0946d034653a2bb31b98f06d5ab(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return a def func_2ebbb8e2b47d471d8268e5fb4e5cce7b(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_2261fefb640b454d960cbd8af49ead5e(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_57d0b6e2515d4601963338493ceef57b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_75ebf7c44d324ca78f7d6750bc64ec5b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return x def func_ef63f48e60ae4900b3aa61d243fba697(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_05f3005f0bec4d8d894a302b4431142a(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return a def func_ffd51af1f07e41e5925c6c4e34be29a9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_8100462642bd4218b2c4134943318eef(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_1a8c07c0f2d64f09a779b92d136a1716(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_6fb126e903f8455995365c4a6f3c033c(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_8b5bda9a3ff849d1a6871bafa02cf7ed(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_4d13e5d34a034941ab1c1e6657e2485a(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_60c69cd0a3a34f3cbf698390f33bdcd2(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_daa54d907f594e21b3ea2d9bb73e9d82(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_dc6ab3aacd77451ca8d94fe76c412923(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_58bb98d517584b2185dbb527d6764ad1(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_185239ba68c443c6b2582d258c679896(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_fe0f0a56ff074cae8ce71c44dedea248(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_7fc5c0bd480e4b0d92c8dd9a0d7bf67a(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_31d7e13da9dc47988bc634a900928686(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_343b3d98f0d84a938d1c5737613149d0(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_737c807ed2964e2997786e26698e9cbc(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_8041dd5730914ae5926491a3780954b4(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_a135821bc5e945a0901d79f01b5005d1(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_aed38e57b859474d9f58bdb5d44f7448(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_90efa0a2db61453492fee621628158fd(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_8b7cb1df22a64ae4aa8de3d015bd50fd(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_6e6377624c54473c807df277939c47ee(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_eca84524829e432d9c8bf70e0bc4cc6a(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_deea78e5f26546e98fdd2890ebce7b44(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_465db3ed2194496097cb5c368671b197(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_684ec74e2621424abcd504be57912390(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_5d01c99cf33a48cdbef6baf2354f89e1(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_0f1dfc5132f24217b2338afcae9b2a35(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_0dbefeb2148f470796384b30f15e50c7(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_b838c64a94044bf8a1c9ca8813c37df8(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_e9363aa2a69e470f9f80db8f2b6f3804(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_3c6ca4fb914a49b890874aedf711729c(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_0e68d658717444f993d50d2766792cda(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_2df44095745d4059b27108621cbce9c6(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_5f5f6bf6cb7e49828fee41020baa1800(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_745ec0319c434543b786b4786c5cf85d(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_4ae3f08530cc4faeb3fac95d6ff1babb(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_db27576438e34afe8b538454d5a0c80c(n, sum0, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_24e8e368a6534e73a299b0bf8b5008ef(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_959e1de9d61241a18cbae0a0c2a78a13(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_652590c3592f4d6f8d07d2abafcfcca8(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_efc31cdaa8d74cbb9725eb4d81f9dc0b(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_531b2b210618442f90bd00f5231771bc(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_848de88c8e2b45db91bda5534d4bc489(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_11806bec31e644268f615322a3b26026(n, sum0, ouf, allv, sum1): bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_cadb9fd23c95465996ca04672b944ce5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return x def func_7b867dc1f5bc4a53a4b305e27b91da75(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return q def func_864df95488844bae88e5979cd2c250c1(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return sum0 def func_ac13abc595f64ff9a058d8efd9f80018(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return r def func_069297d465aa4302a7bc93b8286934dc(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return s def func_205a76346f5c40ae8b69d6877d55c9ce(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return n def func_508ca651766e4004a10982b21e9db925(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return p def func_5fa57a64b66a4c3188445d832b950f68(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return a def func_a864334b68264b87bc4af7b59e5ffeac(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) return aa def func_104d4176c2d6491cac49867e59705cbc(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return n def func_f74f8689e91348a0b55321f8aee742d2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return x def func_b97f282c88914481bfc14d794e5da434(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return p def func_e1202ba44e16493c93c293e82ac303ba(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_e221580e04c24049a137f5c0cec28ad5(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return s def func_a15433e5906a402486e16e68aede9914(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_ea6f193ba8854cc89b6953c8e69ca45a(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return r def func_7dc7201ae9644055ba69693f5d7b3d19(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_5a01fe2dba2b49e8b451b5079ef4d77f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return a def func_7de82f0d4b894a89bab157ab3f10009f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return q def func_5d82cb875d2d4177959309d8cab3ef5f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return aa def func_1abd30ee8cf747ff96d708756dadd699(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return a def func_0c5e78a5031846838b3f2cc969a3001e(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_f693e8320ccb409aac4caa1e8d1c3569(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return aa def func_2ea5937b70b2402faf78ddff33254844(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return x def func_7e5f6ddaa1e8403ea19f19a9db8969af(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_fdaa570c605f4ed2ba48a022db215735(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_7925b579f8194a70975fd12335c05238(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return a def func_7a8a97acb92d437db681b2cd680cfa38(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_8ba867f8b37b47d095a94de8450ea944(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_5b8b5a3c5af54abbbb3a6cedc5ba1fde(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_a10218a2d0ed4a76b3d172be732597d9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return x def func_4668f27363684d1b94846409ae7180f9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_8a8685b6e67547ec8360d11838c7e704(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_3be06b2833734523a4f69cad9221f318(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_e05caa7e5e994e0bbf59abc8ac95ec92(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_06f8a9ef4fb844ef82161d2847cdb925(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_33bfdbe3378441119caff060a66c0717(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_dfb7911d437747f585ce792046c87724(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_7e589c3161df45abab23a96852c187d1(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_0c84493135174cf996159a392762dd0c(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_b972c5319364414a94769f1dd853a755(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_26bb55685f354bdbb191b78d6d005017(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_ba347e533e694057b350ed2621668adc(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_f2f7d6a6b72448998697d639ebb6c700(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_e557092a724c4db984f028efee165c07(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_dad65aa306a34ee28db5eb99c9ab3623(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_f798fc0bcdde46aba41a6607e6b95d98(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_e331c32e8752407083a039618e3ef1bd(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_ea663ab7025345e295ff44b6bc7b9a0e(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_8db4f5d2cdd149a5b755b9c43ad859eb(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_c9561e06eed64a4184585bbd924b36ec(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_4e949bb9aea341cf96b5c1ff53f2bd6e(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_598b9d54bca64b4eb8e577a99efe9517(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_c24140af23904928976215ef0f0f61ce(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_a44bafe1cecb4d28905b0656062dc5f9(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_44b9fc0999974e13b587bf020399c08d(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_035ec2e7fe6c444f8c455b9786ffd37b(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_e48262e5a400449ea73e31b6df96b683(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_f0e47d0b71f54714a105f0f35bd09f0f(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_9ae53822c89245cf99d3119fe572f5c3(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_1ec2e0d67e154e1ba1eef351c68fe4b3(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_156dc6e0b021442c8ceb47199c2fa43b(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_8d37ed50cb5140148eba46c9ed120c72(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_6ce2eb555bcd439495f75f6297527c17(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_d125da5a0d1745eda315aa1663a6c811(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_9f485e8f4aa7490abd30ae0aab8311ab(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_8a03fbea3d4b4d0fb5e6d3803d605cd1(n, sum0, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_d38d36f3644a4e53bd906fa6697695c5(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_ba2510eafe1745c3b82929a5ea3fd3b1(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_2d908186544a453883269ffb0d74f1cf(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_839ed01804ce4fc7ae9d32ddd5fe0c12(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_1a43a3eea9894f8ba5a60408be3e90a9(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_6ad658828c184ad8ad74d8785a058a9e(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_a26dc75801974f73bf34d162a29b469e(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_59d8f02c91ab45d687153ce55f5eabd3(n, sum0, ouf, sum1): allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_9d2c39b52a7a4792bad523ce5d39384e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum1 def func_ed2c8ea0afda43b5bc3619602cb17ab5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return sum0 def func_cd5a2c82144f45029caf7c9bdd34e528(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return r def func_d458e61cfc9e4159aac0207e21f08ce8(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return aa def func_56558222c7644162aa4c8de4769555e5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return x def func_c18d59da276e40998c82514444e21cc9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return s def func_c23b43acb03d4c068ca08287408de177(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return q def func_aa6555a622e347aea019c1aa73c0e450(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return p def func_15a99a9a819f4182bf6c6fbc43d266ae(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return a def func_201d1838d97945418d14a7b540b647df(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) return n def func_b7f31ff9630e4827ad27d96674bcd5e2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return a def func_6d051aba8a0b41dd9f2dd0180401f57c(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return aa def func_09ab1f5edb3f450bbb52e6608e36464f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_da13985cb4754f00bc402f93ab835831(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_70f473c4a93543be9af4cdec53d17a5f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_3eae097aef3143d19fe60fc22fffe4d2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return q def func_4d485ad4b0d1467aa89ecb0f83522b1f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return x def func_e146342f26dd47858eae4a39921deed3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return n def func_4a190a99dfbf413cab22f40f4de52813(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return s def func_37825abe3ee141f088c9b2809ff83c82(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return p def func_1c57dde10e4b4eab9664f7546190096e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return r def func_07447492ba1f4e4b956cbd519c890db6(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return aa def func_b622567bbe6d4e3c857798425771e61b(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_ab32b4a5d68f4103901ea15a4b56847e(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return x def func_ee77efdc31da452ea18b3071974ccc01(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_ca3b84f869a841c1aebcb5fdd750e371(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_9600ab998dcc4ce291ab02e5800b77fd(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_1daa49ee9d4c435db0899d46778f568a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return a def func_5c8ec3a665e043668e8cbf4df4eda51b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_75e6ca63c5b2412cbe27c0e05d7b0239(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_128474a87b4748ec8a04cba6773fae55(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_57d5e9dde2aa417b90643d3515b1ae0a(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_1ba22366cca74ae7859c4034e196887b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_da5544635f094a118387bab5ac773e01(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return a def func_119b38713d3742f6bde61b022f4919a9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return x def func_687a324ae2b1433aac7969742a6df95c(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_e659ee444a464641ab92335d95f51603(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_db8e74af1a7b41ab989683184ef74b97(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_ad381b291cb24183bcf5e56f7ac1d42e(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_bef4488b23b043609abf289cd9219b6f(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_9d20f1b6aca14366bbe2565942d01298(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_0191659c69a64912a36109f1e1f35e15(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_4113b59a8e9b47beaedccb0489f01822(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_531cb4d66adc4d87b3f404f010780a39(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_237614a5f4bb49bbbc86655d6451ec22(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_df34f8348f0e46e2ab4f296838386a6a(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_6aee96dc864f412380d7b02a3676718f(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_de999f26f9a040f6b9aef7243da65864(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_1140af74449f4459b98caf678dc46580(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_1e4419e9ff9542499f2dcc7097805e79(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_c4dad8b97b4a41e392514d40804d81e5(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_703fc1a8ed8346d4a8a17014c1379901(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_ea3f057f92a24f51a051ff0cc2ee87e5(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_356244f07b9c466e92a2d0521585da9e(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_c5c734f4819449a98edd94e4db4c5270(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_1432bb8e4fa44c06953b54676301930c(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_054461809c004085b43699427560a522(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_34764f340ecc4bf89b17ee9bcc90eaf6(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_92bc7959211f439993891d3cb7295ca2(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_7048776cbfc94ef79083ca3009d4dbe5(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_885ec26da7254661882098f7cb3cc52c(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_012e425f0eb24221a78d9b7cc5c8b792(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_ab3dca28c7024e7cbbfe6766cb7f1e1f(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_54495ac6b14840d49a76e737e41adebb(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_139590bec83c41efb34be90c8ce71a20(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_17c25d6c64984ae7bc7454a6fec278db(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_89a97825dc4845c1b92359bca7c5ee4a(n, sum0, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_6806b601234948c78685fb22ecfbdaf6(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_b24ec8c8333445a69e870d384c3b25d0(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_a8867a4e1b0a4d4692dde2c8e27ef33e(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_c39a7768baee475f91ba1457f891cb06(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_8f9e2cd7d69340a99c5cda5aeb365051(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_ba2d7c513475406aa4288af510f40e64(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_a23c43ae35164cb096948370126fda37(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_ede94975a64b49049f6ae1e6bf58fee5(n, sum0, ouf, a, sum1): for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_d0a37413d9f54c569478a3595c5cdff0(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum0 def func_2b96c4d9620b4b7982b505a6eefb5105(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return i def func_89e9b85a26c544a086aedb0df8518457(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return a def func_a739149f7b9c4a66879b5a179e607fc2(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return aa def func_8950cf6d63e64811bbfc92294e2db368(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return sum1 def func_d330898f48f64641b269448d408a56b9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return x def func_fa0bc27282894aaaa51e59d26159f5ab(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return p def func_a069cac6f4a943368fca29268583c839(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return s def func_29503c3e6fef4bb9b060ec03846a338f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return r def func_5e5c3b47d4604c749abb44d8926cc698(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return q def func_c1ee4721fa4347988b32a3b253c8edad(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] return n def func_e46193477f944cc594c7b95ed69ed697(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_962c3925ab91406bb6d35ebb3c9f81e4(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return x def func_5da007c696994102abec5a5729d2c416(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return a def func_459a492a92e04a3db6760f5a9909fa83(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_02dd3451f25444018e56dd418d8c521b(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return s def func_de8b61b6695c4822a6a63df1eee283fe(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return r def func_824eb95d103246368c5a039b3ce70ce5(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return aa def func_5195e8eac9154680a3da42848775242f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_7d379303322d4eb99174f51fc6ff1f89(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_bc4c27c7b4ca46a0966c347addeb7668(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return q def func_6cbb3971ccb64144b3103b6c225f718e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return n def func_3971f8bd09a94e60badc3d82fa36d6fd(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return p def func_d86749847b10437f8ae17d16b3410a14(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return x def func_74832609afb74f7f9bc10147789a305a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_e55e8291451b420781fb4438592fb70c(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return a def func_2700ea89841b4497b2e0b06b69f3d990(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return aa def func_a06253e8d064446188a18303b66b2d91(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_86f526a3ae4c486093d6df2f6486aa0b(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_676da792b4cd4746a2d058816ff801d4(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_da4699718f684d5bba5affa2a2916f24(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_79f08c4200e945248dc17aaa714c1cc0(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_c2119b1f3ba64491b149a67c00e59dc6(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_aa3c82724c6d4b5ebc559bd2c8d45136(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_91386b323f2c4963b3ddd0d116ffa8f3(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_71ccf1ff26f0495791771fe4cecf61cb(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return x def func_0aad9ce9d22f41aeaab806889152aac8(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_b0804a90e2c2462f89ee31f3e87d8f4f(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_98a1f52f42eb48e98f667634396c1981(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return a def func_a6fc11be5695452c88915f15db14b097(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_aef63fbb5f14434db1a1c585ca43d90b(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_ad7cdd02f92945fe9598971924f88e03(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_531561c68bab480598a1e609e85570ce(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_5ff401507eec421f87b54baaab690daf(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_b19fdc4fd3934e0397d4d909ace74cea(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_45efdb147dda42d6b0cd6cf8e38bd824(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_f2f8ef25248245cca7007e9bf9274ff8(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_dd5d6276785f4eaf9bad263cca311b66(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_bc50ce1c677242faad458af88ab6c834(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_728dc919ca4d430d96c65b6bb254ef10(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_a030538fe98649fb816f3e00e17110a9(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_7b3b7042ea1942f2baee6b6de77f92a1(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_a8aab68ca7d44b7b8e71847f83f0545d(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_181b200d5ba64ff8b7f01a21bc87a322(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_be9b7af50d1d4a1b8b76437749e0fecd(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_986edb6e383a4e95818b5a40913bb5df(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_4f76281b322c4e6bac1036ad37b50be1(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_d712d2d88b814b70b56eaa49c952ecf1(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_0ed4e80b375d42ff92d0f22a566b766c(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_96c20820037a42c0a7d60b04a8aeecdf(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_a1a6903fcb1f428faf30197ab294fb73(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_6031dff404e146f7b201b24ae2236ba4(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_f23e24aa1c8945308f699207e8b6ef15(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_78544090c67d412094363b15de3bf2cf(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_8355a38f30244b338b1b13aed95a9d7a(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_420319d315ba40c8a42c58ad39cf70df(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_6c1bbd203eb244e9a32998dccc99809a(n, sum0, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_f030a30050b04edbafc5274f00f2118f(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_0446f91c69bc47fbb0c850d121143276(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_214ad7a1a64140bba767df7c7dc83743(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_4df3eab54c334c06b408f1ac5885e549(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_18bf9e054a37431296af8ca032d5ec8f(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_6e3c4cf704e6407f9016552a369ea855(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_c2ed0ccd72644b80a3d873f02c40ce52(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_b6ec475d402e46d1bd7c576a7ce7ba38(n, sum0, ouf, a, sum1): for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_c477e3897e2d4b87bbedc1da367b5c8e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return s def func_6ad7bcbfbf0a4138aa43e6b4a376ceda(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return p def func_866f09c202f64ca08698740fd8cffbc0(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return q def func_c1e6506118f243c38d9b3c49a7789b09(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return r def func_ade11e1570d3422d8ebc05dd05fef9af(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return a def func_7a3723a7f6234ad8b4354019563ba9d5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return n def func_7dc8dbaf664e4fc189691bf5aefec7c3(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return aa def func_b758a6f6138443fdbb9ccabd59e78564(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum1 def func_8ec65912c89b400f867257fd7ac5375c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return sum0 def func_64c56b52c8c242e8b5ee7514ef5fe4da(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return x def func_5157328dcf1745918b1bb856e664c792(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] return i def func_4a6ff05343594bb886f41727853f22c9(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return a def func_9f4a9d91f77745e199eb3a8c74935474(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return s def func_59a49b4264334389954bef695d1cce0f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_ca289c50a83646fdaac9906c8c5350f2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return p def func_14464b256c724dfe8eb72f5860c1ef4e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_2ef2ed5f1853420ebf18c8705557aa22(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_63b9e772dbd649b78832670b1922abef(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return r def func_d8f98bfbaffa4781acb3a22f4fb98166(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_dd2a61cb17ee43e985fa6e987a714689(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return x def func_4d17044e7cff45ad98d6dcd00cc665ba(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_66c0c9f5e4c24aab8c08ec51211c1c8d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return n def func_3e924ab553d440d7ae924163ece9843c(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return aa def func_b34d79a475d64eb7a3b44f018adcd1a5(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return q def func_00c42cd4fbba4c9aa77d2b0878d70b94(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return aa def func_b11420c1969748a2ad81492d6e8ee488(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_3618132e297d4fe7b7ea22d83497337e(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_94fe07d133fa4a53bb240760cd614fbb(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return a def func_12fc962036b44d9ba788218d5c99a714(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_86d413e7a9444f5b9636df577829ae56(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_0770dd90b25e4c5c96912e7bf0481713(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return x def func_5146844e9a314c588cb4a3a862e9b586(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_90d4c57877254ecca44daf8f9d3a6f06(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_06b8d5038a8b43bbad2eba741a75ae4b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_1fadc6331c134885b44dd4563e36ca6f(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_66dbe008de0040aca5a02337d3b2c934(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return a def func_7a1844e05d2c44d190ee678d629a8d01(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_0f126ac36b2142fd8d0b7b7ba86416e9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return x def func_9f6faaafeff34e159144c70e4c7ec567(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_281e915febd9471dbafcde9176f2250d(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_f995aeda22f84eb7aafde347855ec219(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_0e90eddf49b94ffc9dc1a6a29df4a4bc(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_77061586d0ff48a1a9601c022aac5177(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_d2d753163dfd4113a6f105ba2685f886(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_acb49691e51f46cead8fa7303fe82395(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_57d221703297450cb9894561ede69905(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_29bc710a3cad401d8423e25d1aa5cb2a(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_ab46d9e181594291be4a6074e9fa126c(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_214861888ba54f2ca47f7d655673b7a1(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_8aeb1bb1d7c74af8abedde5d8ab05e5d(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_5891e2d8c06e4a5facd00af3678c8458(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_de7a83fe3b6a471686e51fc7f80c0c9c(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_de9b0b98e18d4261b95b3cb5ed7ab18b(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_34833f9e50af42fa9b4f4aeb8ce61e3f(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_804e896a253f46c996820f7ee27ba7f8(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_351a1fd47b9c4075a00b0ac2ee3c9abb(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_878fd13dd2584ff89a14910c97ea0ebe(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_5faf2add46344504a002136247fe4020(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_6b2af523be5f45188af3d7a9157cb806(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_2c7c60d8c3104adbb1b60a5a928a3905(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_47d393a6ad3c419085fd5b2fc4ee5383(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_6ca92be4360c4e5eaea232fa92c53363(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_6f3e1fae3e0f4f75a97f373b9315ceb6(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_e0e3e47d99c04a83b2629f62795ed35b(n, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_449e97e67f28434688700109799c39dc(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_036a507bce984383bab65131f5e36c1a(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_f6fd5dcda2d249fcbbcdef0b67156fe1(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_1bdc7d47e5ab405eb9cb6df80d7d7843(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_ce50a14c09c040eba617aa0539136ade(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_382543952e004e59b4493136bfcac8c1(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_d40d81aff830449699e5c1cf32afc566(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_a329ab3f81d14e4c9c6027306ff3da90(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_9331b690758a415fabf8579cd3f332d8(n, sum0, ouf, a): sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_97f3ebacffba4eb280bbb715f97dee8d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return allv def func_bba40c5d397c431fa08cff49509dc5a3(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return r def func_900c57d51ee04dde97e0dc7f5566040d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return q def func_9a2bf7cb0f1043b5ad810bc10fb87935(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum0 def func_b2c0d387902140e78b6208b93b2fd8c9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return i def func_3101822c2b3b4cfbb6ee041cc0470fef(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return p def func_9e2f4a7385cc49bf876ae6a193f4b920(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return n def func_9948b65a744c48cfbb4ebfc9e85cc4a0(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return sum1 def func_706798865b8a4d0a8c2b77eccec56135(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return x def func_f840db3f64a84eb39d6232959970357c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return s def func_54c4267409a64f178c747768892e69a7(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return a def func_90d29caf75344cce8169ad7b75373717(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] return aa def func_5a349e35974a427b98c61cd78ff7b550(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_432681e0a1c24ddf82147ae3b6a751e2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return p def func_ee393213a09d4f93b3d88dd2ef3d6a7e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_ebab4ba0a82a4077a9488e0f66cfb0a8(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return x def func_333229244d1749c38bb6f9dd6029979a(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return q def func_29cd03bad71247c49414a5610f4fc351(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return r def func_f61f3ac171374f7ca2bbb8fc2bb20056(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_61b85b191f064a7f9305769ba4a44320(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return s def func_ec63d97c629d44dba0ee841b9598693d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_8019433ca33045a7a31db18fdaf0b29d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_fa320b1c27924999a33e268d9dc504bc(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return a def func_93a42f0db02949d0922ca182559d56e0(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_32b473e62d274b69b397b6720e6fd2f1(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return aa def func_55b702d3e02d4c94ab4b1483f9596934(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return n def func_8ee83f939b0147a3b9bae5feacca03c9(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_56babf604b0c4f44bc389b761a92bd89(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_44f183800e4e42a29c95488eb1a73858(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_9c6f86fab6ae41ac88c1e215212e6bec(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return aa def func_d4114101af4c419cb0a78c0d96948ebb(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return a def func_c746c61147d6423586d18dcd0d2c90b9(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_1b1021798bfe4375aafb864658799dcc(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_d01a5dbcb34947cbaf9a2f15250e46ed(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_182277f4a6694f21bb881e8f6812741a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_25c8085f7955410584fa2958ad71ef0b(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return x def func_0e2f8a514d5e41198292ba1133d91d1a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_03b4867f8d954e228c4091b565b63935(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_985ebb7466be44c8bb928f4662c082b9(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_2510bed6d11c4c759a0b8a71cc1f631e(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_0906b5eea35644d58ba702cb7d4850ff(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_a3da57f5236c4c0a886ba77dc8e53cda(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_f387a10715b94634a24e2f4e3d535bfe(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return x def func_8c445c38fd954331a06625dfdaa69efa(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_8bea988429f643b388c7c11486c1bd2f(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_11a2bee1fa184ace9dc79473e0d008ce(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_b229d9665ceb4ce29a8402a82a5c97f6(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_756a0a874ff54f67954cc1ba233edb4d(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return a def func_46eb2d372a6044fa97dc8fe776c8c485(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_910121ec17214244bd88f570c131c249(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_c55ed46ba0a8408391bd82320e532267(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_e16fa4015dc34fdab60a80c2abf62180(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_cf058c2e5b424157bcc445607abd325a(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_1fec191469d2499fa403a3df99e45b33(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_7d0be09cd5184945aed50da4347270c4(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_0e2e1821126745f0a56d5218aeabe177(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_0a24e2b088174eea89d1cdf21cbbd20f(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_c0c1d18b25734fe981416423bb8001e1(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_47d0ade5dfab4c1fb5663966996722c3(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_4042606945d040328a0b10cf1fd1928b(n, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_6fa3d4cdbe884d9e85f134b24f6c0fc7(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_3dc1b6a07687417da34d6dfd2b38a4d5(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_2eead9b2b37b4ac0ae65e65fdc306794(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_5d3e248379c94a03ae12584b53c4de18(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_9f2ba0222d5e411c8d057e3ec13937d5(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_9a7af39b5eb640ab85e8992ae5910786(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_b1268609c72a41b1b081574c01d76c6c(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_2bd54001a1be40cf9f8066542f6bc27f(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_b73d7a3086ae4034b131ab73e50b9aee(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_0a1f701dea46407a982fb4dcc747aeb3(n, ouf, a): sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_2b1b79baf6d74393b90094c5079d463c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return aa def func_732a984ed7bd48a5a7ba62d2bbda87fb(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum1 def func_398089d011284e498cb947ec37e73534(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return q def func_71dbb326c309465d82662e4cba14d834(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return bestAnswer def func_c05747351635458fbc82fc9657f33f89(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return a def func_a6e7f55060bc4a068f8ce73fce3f5e50(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return r def func_1c271325d5be4ed6a087fa947ba30421(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return i def func_3330f86fc595453b8fea4bed7fb9b364(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return s def func_0afafb204b004acdb79573730ed2d2d2(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return n def func_4c835aceb3f84c2785c3ca8526fc8175(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return sum0 def func_ecfd207a4c52431687585f0d03bf67da(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return allv def func_e61dcb8290f14ad783bf2f0f3b6cffa2(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return p def func_7157c9e608344e8893d2960de9f3d44f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv return x def func_614776fe032c4db98759fe0add0255e0(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return p def func_25606cf29d054268a53a5185b19cc151(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_5c21c0dc729647d58bb959a4a850e8f2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_bfd3bad12780449892e046809dc3fd78(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return s def func_7a8a9ab2b0574a38b8afbbce6528a67f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_f1a74b4ca6ce46d3bc4726420d6215f0(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return aa def func_9090aba990054f8eacaba2bc7dcccbf5(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_d7912c1483f943018c24a189f9a2b795(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_a175f22abc104b70b3c7b50a1180685e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_0e628567d67849aa8cebe9cc8af469a0(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return a def func_da0a01b1802540d6982a0300dd482a33(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_c23d6396dbde45629692e84d960eb9f4(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return x def func_b9f48b7fd439451a90fbb6ec7164a227(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return r def func_36469aa2e3a54f2c9950f7e7cbde3ffd(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_14a2dc10ba7147d59e3651b2de879b3c(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_98ebe8e7425440939e13553d1b85d2b6(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return n def func_f867b30f84ca477c8c82803d3f1936ba(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return q def func_43f3c6e5fffc429c8969aa46613f051f(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_2ebbfdb3ce064966ab2b09cba774fdd2(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_35b60f51f5e04548a7da7c4650e12b4c(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return x def func_ba8c9f75218d4f1eb3da868f0a7add34(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_f3ec67a694dc41d19f84a88e7c306b1c(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_2e73a10623c14b3a8d499a9952437e10(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_015ffcb03a774240a5d1b63242621ff1(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_3d6cc37783284b88ab984d9c66c5230f(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return aa def func_447af3d72a1f4d6c8af2fd7d429031f6(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_e3575d0a69644cc99dc79ac54e9d8d26(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_a979de60d91d4d7d9610e259027eae2d(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_5277d0ea19ff41d99f67321ba2db34fd(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_7ebae28e86f2452c882ad696e170fcb2(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return a def func_cb2b2c482b0e47db8ad555a24142607d(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_07b1247f3f58454c9e52c13cadccba55(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return x def func_a79c5ed8c9194de2b34577bd71ecd09c(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_bb4812c6cae04b09953963c3dc559262(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_208a0d0cd1344f4b91f3154eac236121(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_f5dfaa07203b47b4a2e08777e4d158fb(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return a def func_7dd1e2968cc14ad9acb1bf4f29ebbc2a(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_69d818f3e68c4866a31af17ce5add2eb(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_a56e638f973142b9b1abf7fdd21c3a8b(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_a16117e2c1a545fea658f2116cc4dd05(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_ecbff9e9587740ce9baf1da75c518c80(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_94c2d04dd8e54d87b513e88748924aa6(n, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_ecfbb8b2104f43c097d594404d9d1d6e(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_5becaa76eb5246fea922984ed7508c4b(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_e8d0853a2fdf49bbb3894db76807d1c9(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_d2de71f460694c219aef2969aea4309b(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_c19c1c0a574d47d6980a266874cf60e7(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_a5aba63927094127b2cc096f7cba06dd(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_db92577439af43608089e277bab40dd2(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_33156ee726814d2eb95bc5215d084928(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_5c5d6292221148ad97d7ecc8cc6696ce(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_b3b3cf8f598346d48abdfae66ae1507b(n, ouf, a): n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_3bf3672e66bd4031ab49ead7c2753bfe(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return bestAnswer def func_5427208d7c764770a64fbb98f50e25f1(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return i def func_64d1639af72c48b3b33d2ad8ea9887de(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return p def func_1f717a6b50bc4e2ebb90cf5acc97fbde(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return r def func_6713e7f5b66a4ecd8b59a9f2f3c48dc4(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum1 def func_50eaee1128af4f68a8c8b5a70da2f5c9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return s def func_ab5445954a234f90b127186693d015f9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return n def func_9fcd7604c2154906a9f34ad6ba57e989(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return sum0 def func_eb93498df8f54a7dabe9dc8a2697316e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return j def func_5b37aa76d12244c1b8e14c39e4ba904c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return x def func_459e62d5722246f2a835cd86f817e5fd(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return a def func_23b2dbd8055b406c9d2213698a951df5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return allv def func_6d36a5c578f046beb2524142a7d9403b(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return aa def func_8d03af1fb43b419596a86a10853a8023(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 return q def func_b258cb3715164600972f1fec0778d534(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_194ea1e6c73d42a5b38ddcb3bd69a44b(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_247d0d1c357a4b3aa3a10d5fcf27e2cd(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return p def func_76db762b51b74208910ceda7d2502e1d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return a def func_8031f33b2c0043579fcbbfc84405f1cf(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_61fee87cf8d44780a539b4b091c74370(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return r def func_81f4cb6bef6d435f81dc2c03b0efba41(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return s def func_70872dcea1ef483887d42f84359f7259(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return aa def func_2f2683559088431e826ffcf561be3116(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return x def func_8048c529eed84307b97ec4e21d643c92(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_fa1105bb3cd94d5bbaa7a80e64235dba(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_ed14874b0e254db4a7bc4f6a6ed5d26a(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_4e27f7c838974342b840fc06b6c43686(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_faa679231aa24313aa3cf9b7b4d8e534(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_d48e0d01b899495da7f98abd955111b3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_454b8619de394c83a5a1d88ced45610c(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return q def func_4b5daa8a710c48128454f6e4153490fb(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_fb35ddbd61d44e198ec791a152d26e64(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return n def func_925a4ca8674c4549a5135f55c000ba16(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_106326ff8ed9451c8b6c544b6a08cd8c(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return aa def func_d07f626ed6a345cbad7ddd704f73182a(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_248a2bb21f84418aa6a276f691c580bb(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_efdb11c62025470fad4e21edf91928fc(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_57c842040a9f420188a637e010138366(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_918067a014f244c1ab372e211b4636aa(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return x def func_69686462ea414544ae33e443865cf0da(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return a def func_9af25729f0a34120b1e4cac4e9c6d9e5(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_5c333391bc594253a95f9dd3b65d53ba(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_a0645403d0d946f496a7bdcad114361d(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_7c1e4a13557d42958564892dca8407b9(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_a76c57432ece4319b1a9719f419f2463(r, n, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_768dc55cf23942ef9ae09687010543c1(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_51dc81ac69e24f0eafd7f43202edb45b(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_29acfdf08b5045528c70fa5ac9955651(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return a def func_5d04e744b5da4d55a90a0c9901a17baa(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_b8eab0f2185141df82065790e82d4d0c(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_e7dc48bc1df6455fbf7d3e556edf0d53(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return x def func_205a7be4bed74dfab5f6f63e933e85e6(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_1fc3e91f6b8e44cdb249f7603c860aff(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_fdd7c827726345a4aca766b4fe5bddac(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_ddcdc7bdb24a4a81be72c42ba96ac3bf(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_463f3372a0e741c987d004e93a1abd12(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_0c93c9bfd7274a5b8d3ef394b1bdcf99(n, ouf, aa): a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_fe8b9f2a1cbc4759acb5d535ddaa93fa(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return tmp def func_45afc3ac5f814e5bbe298502c4c11fc9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return aa def func_47d28a0df45b42bf8bc9035eaf654af1(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum0 def func_0529f21679ab4b7f8c442f84e101364c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return s def func_92ca7e1e5a134443b2603119b216d98b(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return n def func_7aa8d871cc99422e83d7d6f090b9ea5f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return v1 def func_5a9469a48fbe498e82fb4cb3b2d3893e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return sum1 def func_e60d05d47147489b88c4bcb0660e0886(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return r def func_112e7845011d412bbd4b8bdee7ad0f00(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return x def func_80e9cb2ac90044eba1adf95286070fc8(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return ps def func_baab8f71e8f64d3fb28400c4199287ee(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return allv def func_bea53c821033479886491f81d506627d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return bestAnswer def func_38bcfb5b36bc49cba11f79a259f446fe(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return i def func_24b52fda97eb4fc5a8f7d928c8ee6f7c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return p def func_0d7ef27559cf42168fa33979b63d2f35(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return j def func_438317cbcb0746b29e263316fbfc8902(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return a def func_41afb4f0018b4e9fb63a536df4b341fb(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break return q def func_05df08a5a0b94e4bac50e01cb3eadc9a(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_1a4f2638614445e7b30d9938ad93376f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return q def func_7cfbd496c9474dc5b6688c10c57c9ebe(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_a974eab382084fff97ed49a359d8c858(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_bb74da3a0f0a49529606cf76819b913d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_befe41dfc19840f2a828651c6cc683ab(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_b5d4fbee21e94aa2afaa7997a5a056ec(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_6d278d9d188e4123856f83131d1cc7a3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return x def func_2d245bf5772a4617921aef3ea6a7fed2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return r def func_5e4b9c3bd501446bbc8adbda7f60e34e(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_730545603b8d4b31b58a842bbd1f2c77(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return p def func_eba5fed8b9414729b5a2fd78f10edd7f(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_2d7ab159b5f9456f91ecf237494fda1d(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return s def func_abcf2b58c625478aa1c9ea99a0405314(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_61dc134d67e24b91b52efdb29bdc5ba0(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_326ba297ac704fe7b2aac76d1f0774ad(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return a def func_8ff0240fb9474070b1a07804176a4bd3(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return n def func_88b6a55dfe584e50a0c99804552f0ff2(inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return aa def func_86eb879d557c4dea971c7870fb7f624f(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_7451318129734403a97eb4682f603d35(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_7f40b8428c1e4e12a1648d93bdc11233(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_86d3c7db62a64503b9a482cf9ed1a2fc(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_dd4007814596414ab0cb84910c8c8953(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_0f4bd92120da4e8ba169c6b3bc051c93(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_5388507d69cb4aa4b9f93bce9cbb6d0c(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return a def func_e9e3bc4a169f4d009a12639785702a0d(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return x def func_78e3560d9707488dbece4056320d4547(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_0ccaf469f2d947ca9465f6e115da9602(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return aa def func_0cf979edb3fd459eb00ff0779580947b(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_46781e3680134113abdbe7f009b399b4(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_657edadcc7684c90a83acd8b519c1cdc(r, n, ouf, q, p, s): aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_30b790d052f54d04882a37dfae1bacda(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return r def func_82274935491348aa915ee9073db13765(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return a def func_18ff9563af2b40218ca096cf87686b85(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return bestAnswer def func_ad32272d63dd496cb4d322d648a73f14(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return x def func_435014638a0d4ff599681dd41ea3a8cc(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum0 def func_02b9d554128949cf9e7f6b12b8aea82c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return ps def func_4f898a7094f74e54b88e6edcabccb38d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return p def func_147dce35bd874272ab272d15230272b7(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return n def func_278daa9ead11483b8a2b44e441c071e3(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return tmp def func_ef0f52937d5c4e52bb7fa72643867e6d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return v1 def func_856033bc5ba74564b6e53dd1d0018b77(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return sum1 def func_5c2d7e7f790248d5b147e1aaa71ec21e(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return j def func_25efcb7071e94b9a9cf6d59bcdce8430(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return allv def func_44539c770bca44ae985536b928412741(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return aa def func_6c3adfbef1bc4ac48323bac0c2b65b15(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return answer def func_2dc5ddc014e74bb3a0a890f920ab9aa8(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return s def func_8195eafcc8a242db8e854d2863354ac9(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return q def func_63a1c23684a04cee9ffeb392d4a90fbb(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) return i def func_b55386c2519848f4a97e7e4dec1bec68(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return s def func_1e4137fcdab24bcf9e2d16542aed0b23(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_c64851728a0c4a4ab43f30490540d9a2(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_305c84dc6f2a4caf88f3b3b88fe9285a(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_d3485b33e9f24753954ed060ec11feaf(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return q def func_0721fcae91874610b87cb5b543faab9b(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_3824f09f3d7f49c6ace2d6f242779eb3(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return r def func_15c6602e3a4f4f95a72cd736580e9ffb(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_ddf59852d162421d9f25dcc4b8395052(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return p def func_b4c5e72566744767af688829db3fefce(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_595ac0dec3304cbfbfce23f44d6cc5e1(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return n def func_8d4517fa7e9e49569d98fb1412d62325(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_77d9b4c9da37473bbacfc23a00cfc5b3(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return a def func_4342461c8c55445eb847b28ecbc63cbd(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return aa def func_0c4686a8c80a40cbb43d14321c5a8025(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_6fc6ec10942048b896e3af146c26459a(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return x def func_a0ebd0fde8f04185be8e6788a76e7a4b(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_5205b4d452bf46edac07ba14fc76a37c(ouf, inf): n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_2d295440a44b42f8bb23a5fbb277ca0f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return allv def func_2ab1310fd233438e8e0f82b73c9fa877(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return r def func_4cf343b1fe874cf0aa46a12876785b14(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum1 def func_6a5408b296584550b40c4c7797c19029(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return a def func_b1f53c94e1944e8fa1f3f33064bd2f89(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return ps def func_9f712f0d119f418d9f36543897d4b2af(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return bestAnswer def func_8976925932c646a6a24dd4de9769d0ea(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return x def func_25ce795595d94d8d90162594e57839fa(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return i def func_8a8972aa10a746b2b330f426cbe8b57f(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return sum0 def func_186dec27ed89443dad44ed05c94ad664(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return j def func_86da39926ac944bf86e12d4470097d7c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return aa def func_c8f542871ff74c4b9f1284eeb25419f7(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return v1 def func_48973e69ddf04db4a2fecb64ae4164f6(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return n def func_68956e03c5cf4a0293beccc550bb18c0(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return q def func_28d9e1aba71240f988e4531ae3e7e075(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return answer def func_df345a9276454a40bd65e36750f68fa6(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return p def func_fcd168cae1b54e96929edf213e022473(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return tmp def func_edc55e90e9ff4176b5a27435cbb3d36c(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) return s def func_0ac25132092a4d8ea6a6a7d0de93a5d6(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return allv def func_fd95f1b2e070429692d58d889b0dc122(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return p def func_361867bb8133472f909e8442934ca9cc(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return bestAnswer def func_c660b545cf8249d8b04823ae1f0d821d(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return s def func_6076713b6e684e06a9ebf6575e5c98ef(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return ps def func_9a037582aaf540f7bdbfe8357ed418e3(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return i def func_f19d2ddb59b04276ac2365af266e9d94(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum1 def func_51206e4dc8fb411ea2ed963233170438(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return tmp def func_ae2e61d889e24563a6f5dded0ac99a2a(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return v1 def func_4c2a8d013c614a559b9c22777b7b4bfe(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return r def func_c76e63e8cc0d44d88735c69fc597ce96(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return j def func_238048de3e5245469e86f8992c31aae2(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return sum0 def func_1ba5547614824a0ba85cf6ec3126e4e0(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return q def func_2a233db07507480581a07ede866aa630(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return aa def func_562f6189b99b4406a34ea11315bdef03(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return n def func_97db999c21e543ff946297c0c83b4993(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return x def func_9352579fe62d48e79c5ac9951e082126(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return answer def func_eb859a6d46f64c5c9f5254610a2fdfd5(ouf, inf, tnoc): ouf.write('Case #%d: ' % tnoc)('Case #%d: ' % tnoc) n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv)('%.12lf' % answer) ouf.write('%.12lf\n' % answer) return a def func_1f1a07b3c24148fa96a15f67f7b04c18(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_4cbc3b1f8d5142b9ab4f34c806a6a650(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_08a8e8fc537e42e09931145c81c0cd0b(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_8504801b20904afa880831e2d40f9e5b(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_da20bf307a064051b864dfdbba175c34(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_ea2640c202ca405a8bac0c2c2af826f6(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_8bd8f18e82c94858b239faa401cf93db(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_94705492fc07421ea196f6c582c2bec5(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_ad84729e44284a8193f5ab00e5c42e9b(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_788ba49943c647dd9a4c25237e935739(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_a964c50b251843b2a8fcd0ab1aff5307(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_cf44d815d7324af88e806f7f636c42bd(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_3bc8e6f003f24184bf894457bd9487ee(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_06ec545c9b2041779397bb48c42244c2(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_4ab941dfc4f44034b39ddc019d504851(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_05267a31640d4cccbc1bb16f34806db5(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_c5851245b82e4ee3890e5a4b1c43810d(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_0d63871819cd46e397cfcb4b84293982(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_3e5946c5cb344a2ab3bd1685f43513c4(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_7e986e899f894f8b899af104cfa87330(ouf, inf): noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_50107e24869842e1ab5932a2dd303f94(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' return ofn def func_1cb65c7313b0400085df336ac185f824(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' return ifn def func_efd521eace5e49cbb84f876f1866af76(): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) return ofn def func_6a8b5c66d42d4259a5f237e04f148f66(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_27fde57224e74f398a8b43af657938bb(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_aefb2ea7c2054d7f850f160af7e043d8(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_eb9a05953ba647cb85510f6b6161dbc4(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_30f8ef7d67ba491bb320825ecf5b9070(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_6e3d49135a29435ab3643463395d7804(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_327fd773bab349c78ab05fe9338ee4d3(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_af7716c65ab64f4bbeacda772d88b2eb(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_95dcdec5902b4fc59843460ca0ef3edc(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_2785c1c3553946c5a4a69ca8971031dc(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_0e7f5bbb9f2e4d4a8080754999525ea3(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_6f1f4acedae04db1a3e9ec3f62953eee(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_d93032d232774c369f2f0739799f0c87(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_9855f079ceaa47ad8edc9938b0c6b15b(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_fd907c3bc4e14cb8b17ead4d59687e3d(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_f7d5e4e5a0d1400ca9788ff1c03cf9e4(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_3466191fca1744cfb0e319e3b9eb5e8c(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_928674202e014ac79c8f76a14ed9230c(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_55f2d692aae54e19bcda9d69c9fdf8e2(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_2942d83424574e41bab4c26fcb76f0e9(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_b26f5fb3b794409590738cfac9f37078(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_70cba03f06d44be5a7af4f15831c27a3(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_788eb9a35b0142bbb85690b75408e5b5(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_ebc61867fd3846a0a58758bbd8033205(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_dab8c5009b524f9ba793a57b4961a85e(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_0ee0f8afa8c24befa99a97eb5fa094b5(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_8c7e4492410d417684d8368f893ebaff(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_c79eeb75d48b4d80abafb22bdeeaf41c(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_744b0f76d8d04aec9e24ba9a006b6386(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_c79a55c28f6648a892db41d1db302192(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_4311c9edfcb741b5b97d1062de13c465(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_9e052d57a2c645b2ad0c625691d3ac0f(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_4022b803fbb946338dd9e12f157dba98(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_968be4a8c88a4891a958eab189439b4a(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_b1208544b6fc4fd4a40132ab7372dc43(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_41d06cf49ef74b4a95f672286f59451f(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_8690ce941e2948f7b9edb5d854f1a6ee(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_22cc9453150344ff9adda33020c7eddb(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_70b41dbc6dbf48c29fed546dbb308298(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_2ac4c259180849eabfa7285c0dd0828e(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_6c39015972914056b05a077872356a8b(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_9cd2159c4f9947e5ad62518a8fe5eb21(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_37211748a4a04ee3869f708b313eb5d1(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_fb73cf162c884751b51a75d657845e42(ifn, ofn): with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_e42652c2d5c9427d888974be2e452088(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) return ofn def func_348a31f0f4df458ea3b629265eb1f770(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) return ifn def func_2ba1ab990bee4f8f82c23034281a2132(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_1ec3c9430ea04d439b5e0436c558f2a2(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_555237381c774a019f5add6eabf2175a(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_e46dcb0b943c434d9a64c3b005f3ce24(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_49f5e0c7887c4347a5f89ee421c8162e(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_df6ca0e9c2834205b89deed0eb1e116d(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_c7da98a857394883b45bada9631f6fa7(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ofn def func_f9911c7e6f434f5dbd618207d2240e2d(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_2a62abbb441a4a55b8a46f95afb1629e(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_52d11845241c48e4b61831566e955a6a(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_e688c849d3324c2cb9059272904490d5(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_15ff9a63c4cd4921ba178c4c4d02b535(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_0a43252c255f498b86c85266764dbf4d(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_3a6fabee87eb412eaa85d70e92f82ca4(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_b4be8e4c37ef489a94163ce7f6070408(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_627793ddcdf841a1998e4859c7480829(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_b87f6985e4174ccca3ed148ef5be30f8(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_d7c372c8d85b4335b72453229b6f6783(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_fab09c260e1d471fa34d53e7f686699f(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_1c244e6749fb4e64a52bfb82bd870c61(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_bdd5283ba0ba4d169326f39d3a0a3c33(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_cbfb9564454048fb85cce520a9fb0fc6(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_3052157248c34db3a52e7b5ea71c24f7(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_c47eb8ed200c4550b87c9a2302ba4fe2(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_db8c38a45b924051b507246c2e39568e(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_e4e64cb7e6b242c88facd9c0524a28ff(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_fa92dcb8acfc4c25ad6cd237dad31e9e(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_1501b97c063d42fbafc1bb49bb4135d5(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_367fde62d75643c694a4c8a2e0a076b6(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_72d1beb13884470f86ed7ca5c8364bc4(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_f7407e2ddf814bda98e07442bb4a1845(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_6656a119c76f4e5f809bc2d01f2d1a12(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_15c20a3ec4ac4b56af16c17fc418fc0c(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_9967b903d66d4b33b28c1593d058a973(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_bb1d2cf1bfd94287904263601ec9d899(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_e17467a7e6074d24940ba0da58a1269a(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_eebaa6b5418f4fc59f87746c3f3dc30d(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_819e84878721491eaadd269a9e62b0d1(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_8ba9fef8c8e94af28a3bc91fee473d39(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_d3cdac165ea34367ba63ff84934de5a1(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_47a6e53df8954921a7e70398e9156ad1(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_abe51c7dd8d64db0bfe0afb75a80a620(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_35ab7f37ed0e455aaab671bbeb4449af(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_167552bf7d1c4c4ca2d7e496a8f29d47(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_1e1e6bc8744e4d5e954c0b1524cd537b(ifn, ofn): sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_a1e71228497c4cf1adff18ec1f344d70(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_6cbc4c89406e4ec09262ef1ee2351bc6(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_b691a0dd5f5f45d18dff4b41fb2aa5ad(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_f7249c751685485aa40e7682e24587f1(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_d483c7b8957e45cea43e829954ca89c2(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_f29eec30872b4d77a94147b95b6c3461(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_c28f7808cc5340a98479eff408ff4d21(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_e033430ee58143b98fa684d1635a20f9(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_d701f4f3db6d428da00f104fbc210443(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_2aec5fd32b8f4d9d9f5f171879cc71ad(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_efe0b0a7409649c39c5e175b98b5c433(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ifn def func_82f673c8f45544cd9b6e293fd6caa6b7(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_83740ccbc3ce48b3bb11742bc1967dff(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_0ca5f10099b5405e8a521de89772574b(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_9a36941fe3e74b4aa43d337e9b8fe2e0(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_8f3d17b7afb542f0af9774995108cf62(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_cab326d645e2459d9a0236bcf2d80c77(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_c622b09440084feeabf8315178ad61af(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_e19916faa55f46c08ab087792b4a367e(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_814a786f93924b2a9e400ae6c129a812(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_02456ba0114a4704906819caa082fee4(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ofn def func_2f8834df28444355a0a01b4074986dfd(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_ae838bf256194c8f979d755fc191f419(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_5145d101abd04ee29f3f992a7fa2a5b0(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_247fba30384047338cfbbfec6e0c4efc(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_da6dc6dcaed04123bdbc9bf743832d5f(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_0393286bb9ca49148459150f6e76eaf7(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_83a7e6a895d74c6eb437847188050670(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_bc798ad9fdaf467c90949c7d35013e30(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_551e5058e8e94a3789e084ecb7dffe3d(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_c033f450c97144d59877ea3d45e804cf(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_aa0bf50262094cbe9c429754c42b106c(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_a1b18dd45d4a4c2b9973ed276a23ecb9(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_acff33e08bf646bca48d89c74e099aa6(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_853a2ec9a07e4f53b288e05818f08ccd(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_aaee6decaae646079b60a134b22a28eb(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i def func_6c9e0878781d4ca9a96be97a2e413e2a(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_1a652c6b46c24da9861d711b7da7a0b2(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_87cf44ff64de42ea802dc9fc8181e31b(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_ac220ef64f0545d9b6554e3fcc810ed4(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_f3aabaf3063d462d906fdb46dcad8fb5(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_465aae1f5d8d4af5b482b32403994e29(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ofn def func_9b703fd78ebe44f19ceede166d6beed0(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_47b2551007024031a54ff3d798e64745(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_53aa7cb1c5254da2920d6d8f22ddb52c(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_ea0a166769994d3b8d91c87b886a86ec(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_68baf3a04b4d4ee79138a0cba2198f06(ifn): ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_f3430b5b1a064ad8a90a879188f63947(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tmp def func_166efe02176140ff97063e9c86868905(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return v1 def func_1ac56c73208249038adcebc836afb015(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum1 def func_fa9c4fa86dd640119d4ed715faf456cf(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return bestAnswer def func_1fd57506fd1a4b35acf8bba35025a7e7(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return x def func_60d0f054a28c4a0eb2bbf8a834d7ebba(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ofn def func_1cdfbe489a6f4bdea6792f551f6fc8fc(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ps def func_2468feb4a2c74cecac74a91619e4f929(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return tnoc def func_e92c7f7d481841488bb2207b5e7123b4(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return a def func_f641ed287cb141de946d378888abf6b1(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return inf def func_a0237e9417b44bbc96837f2bcbc834e3(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return q def func_87012c2431104f49b16426e8717b669c(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return r def func_f32ff8fe1c8642aead18eb959e6d54dd(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return allv def func_5bca1d4aeca04fcd9586b9712fb1f4ed(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return noc def func_b194671cd8484e04851254003cf6e38d(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ifn def func_9a9f20c7939a48f1b65461de2b7152ad(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return n def func_efc5751c33e947c194ed32d3df281d88(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return s def func_a5d4b9c668e24e79a4bf56e2cd3a9b8a(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return sum0 def func_6efc6591553c467bbb74d313917fccf6(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return ouf def func_151dc80cc3ee450f936e08b2c69a5deb(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return aa def func_22ad6de36e754983ad1fe58e17e3e27b(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return j def func_0275663c1738495e91ce89a03ca0b68b(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return p def func_11ab8032231d47c8a254f60dac3be02a(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return answer def func_915511527e5444dd99a0fc362fe3aba5(): ifn = 'codejam/test_files/Y14R5P1/A.in' ofn = 'codejam/test_files/Y14R5P1/A.out' sys.setrecursionlimit(2000) with open(ifn) as inf: with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) with open(ofn, 'w') as ouf: noc = int(inf.readline()) for tnoc in xrange(1, noc + 1): ouf.write('Case #%d: ' % tnoc) print 'Case #%d: ' % tnoc n, p, q, r, s = map(int, inf.readline().strip().split(' ')) aa = [((x * p + q) % r + s) for x in xrange(n)] a = [x for x in aa if x != 0] n = len(a) sum0 = [0] * (n + 1) sum1 = [0] * (n + 1) for i in xrange(n): sum0[i + 1] = sum0[i] + a[i] for i in xrange(n - 1, -1, -1): sum1[i] = sum1[i + 1] + a[i] allv = sum0[-1] bestAnswer = allv j = 0 for i in xrange(n + 1): if sum0[i] >= allv: break ps = allv - sum0[i] j = max(j - 1, i) while j <= n: v1 = sum1[j] tmp = max(sum0[i], v1, ps - v1) if tmp < bestAnswer: bestAnswer = tmp if float(v1) > ps / 2.0: j += 1 else: break answer = 1.0 - float(bestAnswer) / float(allv) print '%.12lf' % answer ouf.write('%.12lf\n' % answer) return i
31.27316
86
0.399409
128,132
939,477
2.918615
0.009319
0.056462
0.080285
0.083911
0.903735
0.903735
0.903714
0.903692
0.903508
0.90324
0
0.108419
0.453301
939,477
30,040
87
31.274201
0.619697
0
0
0.959722
0
0
0.022604
0.005159
0
0
0
0
0
0
null
null
0
0.000072
null
null
0.019491
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
8
45ebdaca1fb0ed459128e9b5189dfe0277fb3569
327
py
Python
checkers/staff/chklib/utils.py
amreo/ructfe-2019
19064842acc57243f16143a85c06a5613378ebec
[ "MIT" ]
23
2019-11-23T19:53:10.000Z
2021-02-19T06:13:28.000Z
checkers/staff/chklib/utils.py
amreo/ructfe-2019
19064842acc57243f16143a85c06a5613378ebec
[ "MIT" ]
3
2021-03-31T19:21:51.000Z
2021-06-08T20:31:48.000Z
checkers/staff/chklib/utils.py
amreo/ructfe-2019
19064842acc57243f16143a85c06a5613378ebec
[ "MIT" ]
3
2019-11-24T09:35:43.000Z
2021-02-19T06:13:29.000Z
from random import randint, randrange from string import ascii_uppercase def generate_flag(): return "".join(ascii_uppercase[randint(0, len(ascii_uppercase)-1)] for _ in range(31)) + "=" def generate_random_text(): return "".join(ascii_uppercase[randint(0, len(ascii_uppercase)-1)] for _ in range(randrange(3, 32)))
32.7
104
0.740061
47
327
4.93617
0.489362
0.301724
0.12931
0.206897
0.517241
0.517241
0.517241
0.517241
0.517241
0.517241
0
0.031469
0.125382
327
10
104
32.7
0.77972
0
0
0
1
0
0.003049
0
0
0
0
0
0
1
0.333333
true
0
0.333333
0.333333
1
0
0
0
0
null
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
1
1
0
1
1
1
0
0
8
3408c87f0b0f4ebc68b594f489beba49f4e181eb
12,077
py
Python
plot_cutout_2d.py
pdn4kd/isochoric-expander
56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f
[ "MIT" ]
null
null
null
plot_cutout_2d.py
pdn4kd/isochoric-expander
56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f
[ "MIT" ]
null
null
null
plot_cutout_2d.py
pdn4kd/isochoric-expander
56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f
[ "MIT" ]
null
null
null
'''generates a list of false positives, etc. Also plots along the relevant parameter space.''' import numpy as np import matplotlib.pyplot as plt stars = np.genfromtxt("matched_65p.csv", delimiter=",", names=True, dtype=None) nplanets = [(1,7)] for minplanets, maxplanets in nplanets: f65p_false_per = [star["per"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_K = [star["K"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_per_mid = [star["per_mid_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_K_mid = [star["K_mid_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_per_err_minus = [star["per_err_minus_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_K_err_minus = [star["K_err_minus_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_per_err_plus = [star["per_err_plus_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_false_K_err_plus = [star["K_err_plus_65p"] for star in stars if ((((abs(star["per"]-star["per_mid_65p"])/star["per"] > 0.05) and (((star["per_mid_65p"]-star["per"])/star["per_err_plus_65p"] > 3) or ((star["per"]-star["per_mid_65p"])/star["per_err_minus_65p"] > 3))) or ((abs(star["K"]-star["K_mid_65p"])/star["K"] > 0.05) and (((star["K_mid_65p"]-star["K"])/star["K_err_plus_65p"] > 3) or ((star["K"]-star["K_mid_65p"])/star["K_err_minus_65p"] > 3)))) and (star["num"] <= maxplanets) and (star["num"] >= minplanets) and (star["65p_Favored"] == b"Yes"))] f65p_K = [star["K"] for star in stars if (star["num"] <= maxplanets)] #f65p_fav = [star["65p_Favored"] for star in stars if (star["num"] <= maxplanets)] f65p_per = [star["per"] for star in stars if (star["num"] <= maxplanets)] f65p_yes_per = [star["per"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_K = [star["K"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_per = [star["per"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_K = [star["K"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_per = [star["per"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_K = [star["K"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_per_mid = [star["per_mid_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_K_mid = [star["K_mid_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_per_mid = [star["per_mid_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_K_mid = [star["K_mid_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_per_mid = [star["per_mid_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_K_mid = [star["K_mid_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_per_err_minus = [star["per_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_K_err_minus = [star["K_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_per_err_minus = [star["per_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_K_err_minus = [star["K_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_per_err_minus = [star["per_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_K_err_minus = [star["K_err_minus_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_per_err_plus = [star["per_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_yes_K_err_plus = [star["K_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"Yes") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_per_err_plus = [star["per_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_no_K_err_plus = [star["K_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"No") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_per_err_plus = [star["per_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] f65p_mar_K_err_plus = [star["K_err_plus_65p"] for star in stars if ((star["65p_Favored"] == b"Marginal") and (star["num"] >= minplanets) and (star["num"] <= maxplanets))] fig, f65ppk_fit = plt.subplots() x1s = [1826.25]*10 y1s = np.linspace(8e-4,1e-1,10) x2s = np.linspace(1826,1e5,100) y2s = [5.476e-5*x for x in x2s] f65ppk_fit.plot(x1s, y1s, color="#A0BBFF") f65ppk_fit.plot(x2s, y2s, color="#A0BBFF") #f65ppk_fit.scatter(stars["per"], stars["K"], color="gray", s=1, s=2.5) f65ppk_fit.scatter(f65p_yes_per_mid, f65p_yes_K_mid, label="Recovered", color="blue", s=2.5) f65ppk_fit.errorbar(f65p_yes_per_mid, f65p_yes_K_mid, xerr=[f65p_yes_per_err_minus, f65p_yes_per_err_plus], yerr=[f65p_yes_K_err_minus, f65p_yes_K_err_plus], color="blue", fmt='.') f65ppk_fit.scatter(f65p_mar_per_mid, f65p_mar_K_mid, label="Marginal", color="black", s=2.5) f65ppk_fit.errorbar(f65p_mar_per_mid, f65p_mar_K_mid, xerr=[f65p_mar_per_err_minus, f65p_mar_per_err_plus], yerr=[f65p_mar_K_err_minus, f65p_mar_K_err_plus], color="black", fmt='.') f65ppk_fit.scatter(f65p_no_per_mid, f65p_no_K_mid, label="Excluded", color="gray", s=2.5) f65ppk_fit.errorbar(f65p_no_per_mid, f65p_no_K_mid, xerr=[f65p_no_per_err_minus, f65p_no_per_err_plus], yerr=[f65p_no_K_err_minus, f65p_no_K_err_plus], color="gray", fmt='.') f65ppk_fit.scatter(f65p_false_per_mid, f65p_false_K_mid, label="False Positive", color="red", s=2.5) f65ppk_fit.errorbar(f65p_false_per_mid, f65p_false_K_mid, xerr=[f65p_false_per_err_minus, f65p_false_per_err_plus], yerr=[f65p_false_K_err_minus, f65p_false_K_err_plus], color="red", fmt='.') f65ppk_fit.set_xscale('log') f65ppk_fit.set_yscale('log') f65ppk_fit.set_ylabel("Recovered Semi-Amplitude (m/s)") f65ppk_fit.set_ylim(8e-4,2e2) f65ppk_fit.set_xlabel("Recovered Period (Days)") f65ppk_fit.set_xlim(6,1e5) #f65ppk_fit.set_title("Fitting: Period, K, Time of Conjunction; eccentricity set to 0 ("+str(minplanets)+"-"+str(maxplanets)+" planet systems)") f65ppk_fit.set_title("Earthfinder Untruncated Examples (Fits)") f65ppk_fit.legend(loc=0) #filename = "f65ppk_fit" + str(minplanets) + str(maxplanets) + ".png" filename = "Earthfinder_extras_output.png" #plt.savefig(filename) fig, f65ppk_false = plt.subplots() f65ppk_false.plot(x1s, y1s, color="#A0BBFF") f65ppk_false.plot(x2s, y2s, color="#A0BBFF") #f65ppk_false.scatter(stars["per"], stars["K"], color="gray", s=1, s=2.5) f65ppk_false.scatter(f65p_yes_per, f65p_yes_K, label="Recovered", color="blue", s=2.5) f65ppk_false.scatter(f65p_mar_per, f65p_mar_K, label="Marginal", color="black", s=2.5) f65ppk_false.scatter(f65p_no_per, f65p_no_K, label="Excluded", color="gray", s=2.5) f65ppk_false.scatter(f65p_false_per, f65p_false_K, label="False Positive", color="red", s=2.5) f65ppk_false.set_xscale('log') f65ppk_false.set_yscale('log') f65ppk_false.set_ylabel("Input Semi-Amplitude (m/s)") f65ppk_false.set_ylim(8e-4,2e2) f65ppk_false.set_xlabel("Input Period (Days)") f65ppk_false.set_xlim(6,1e5) #f65ppk_false.set_title("Fitting: Period, K, Time of Conjunction; eccentricity set to 0 ("+str(minplanets)+"-"+str(maxplanets)+" planet systems)") f65ppk_false.set_title("Earthfinder Untruncated Examples (Input)") f65ppk_false.legend(loc=0) #filename = "f65ppk_false" + str(minplanets) + str(maxplanets) + ".png" filename = "Earthfinder_extras_input.png" #plt.savefig(filename) plt.show()
125.802083
565
0.677983
2,080
12,077
3.655288
0.065385
0.081941
0.084177
0.064448
0.888465
0.816257
0.796659
0.782454
0.715507
0.689596
0
0.061675
0.096464
12,077
95
566
127.126316
0.635081
0.064586
0
0
1
0
0.226004
0.005052
0
0
0
0
0
1
0
false
0
0.025
0
0.025
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
340b99c672475b2c9ff183951071d02a783897bc
3,670
py
Python
tools/fileinfo/bugs/mips-64-bit-multiple-relocations-in-one-entry/test.py
xbabka01/retdec-regression-tests
1ac40cca5165740364e6f7fb72b20820eac9bc7c
[ "MIT" ]
8
2017-12-14T14:25:17.000Z
2019-03-09T03:29:12.000Z
tools/fileinfo/bugs/mips-64-bit-multiple-relocations-in-one-entry/test.py
xbabka01/retdec-regression-tests
1ac40cca5165740364e6f7fb72b20820eac9bc7c
[ "MIT" ]
10
2019-06-14T09:12:55.000Z
2021-10-01T12:15:43.000Z
tools/fileinfo/bugs/mips-64-bit-multiple-relocations-in-one-entry/test.py
xbabka01/retdec-regression-tests
1ac40cca5165740364e6f7fb72b20820eac9bc7c
[ "MIT" ]
8
2019-05-10T14:59:48.000Z
2022-03-07T16:34:23.000Z
from regression_tests import * class Test1893MipsRelocations(Test): settings=TestSettings( tool='fileinfo', args='--json --verbose', input=['ioftell-le.o', 'ioftell-be.o'] ) def test_fileinfo_does_correctly_interpet_mips64_relocs(self): assert self.fileinfo.succeeded self.assertEqual(self.fileinfo.output['relocationTables'][0]['numberOfRelocations'], '14'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][0]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][0]['type'], '7'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][0]['offset'], '0xc'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][1]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][1]['type'], '24'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][1]['offset'], '0xc'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][2]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][2]['type'], '5'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][2]['offset'], '0xc'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][3]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][3]['type'], '7'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][3]['offset'], '0x24'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][4]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][4]['type'], '24'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][4]['offset'], '0x24'); self.assertEqual( self.fileinfo.output['relocationTables'][0]['relocations'][5]['symbolName'], '_IO_ftell' ); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][5]['type'], '6'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][5]['offset'], '0x24'); class Test1897DynsymBug(Test): settings=TestSettings( tool='fileinfo', args='--json --verbose', input='dynsym' ) def test_fileinfo_does_correctly_interpet_mips64_relocs(self): assert self.fileinfo.succeeded self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][0]['type'], '3'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][0]['offset'], '0x10ff0'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][1]['type'], '18'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][1]['offset'], '0x10ff0'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][2]['type'], '3'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][2]['offset'], '0x11000'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][3]['type'], '18'); self.assertEqual(self.fileinfo.output['relocationTables'][0]['relocations'][3]['offset'], '0x11000');
54.776119
109
0.638692
360
3,670
6.441667
0.152778
0.150065
0.221216
0.31436
0.934455
0.934455
0.934455
0.934455
0.934455
0.829237
0
0.036748
0.162125
3,670
66
110
55.606061
0.717398
0
0
0.451613
0
0
0.298093
0
0
0
0.013352
0
0.467742
1
0.032258
false
0
0.016129
0
0.112903
0
0
0
0
null
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
1
0
0
0
0
0
0
0
0
0
9
344b1bd36b49b66eaa39053c18e65539dce491af
25,809
py
Python
sub_path.py
mckaymckay/Unsupervised-learning
46d627fc5b24043ebb6f2e3b4388b66be3ece7d5
[ "MIT" ]
null
null
null
sub_path.py
mckaymckay/Unsupervised-learning
46d627fc5b24043ebb6f2e3b4388b66be3ece7d5
[ "MIT" ]
null
null
null
sub_path.py
mckaymckay/Unsupervised-learning
46d627fc5b24043ebb6f2e3b4388b66be3ece7d5
[ "MIT" ]
null
null
null
[['0002/0091.png', '0002/0076.png', '0002/0017.png', '0002/0015.png', '0002/0014.png', '0002/0085.png', '0002/0082.png', '0002/0006.png', '0002/0087.png', '0002/0090.png', '0002/0009.png', '0002/0093.png', '0002/0011.png', '0002/0060.png', '0002/0007.png', '0002/0094.png', '0002/0075.png', '0002/0016.png', '0002/0013.png', '0002/0083.png', '0002/0059.png', '0002/0010.png', '0002/0080.png', '0002/0081.png', '0002/0086.png', '0002/0097.png', '0002/0001.png', '0002/0012.png', '0002/0092.png', '0002/0079.png', '0002/0008.png', '0002/0018.png', '0002/0084.png', '0002/0089.png', '0002/0095.png', '0002/0005.png'], ['0004/20150415_192614.jpg', '0004/20150415_182608.jpg', '0004/20150419_215609.jpg', '0004/20150416_002601.jpg', '0004/20150415_175601.jpg', '0004/20150415_202606.jpg', '0004/20150416_015558.jpg', '0004/20150415_205612.jpg', '0004/20150416_012559.jpg', '0004/20150419_175558.jpg', '0004/20150420_002558.jpg', '0004/20150420_005608.jpg', '0004/20150415_185603.jpg', '0004/20150415_165607.jpg', '0004/20150419_162607.jpg', '0004/20150419_195603.jpg', '0004/20150419_202609.jpg', '0004/20150415_195606.jpg', '0004/20150415_232609.jpg', '0004/20150419_142602.jpg', '0004/20150415_172559.jpg', '0004/20150415_222555.jpg', '0004/20150420_012608.jpg', '0004/20150415_225557.jpg', '0004/20150419_232605.jpg', '0004/20150419_172559.jpg', '0004/20150419_222602.jpg', '0004/20150419_182601.jpg', '0004/20150416_005609.jpg', '0004/20150419_145559.jpg', '0004/20150419_155557.jpg', '0004/20150419_185608.jpg', '0004/20150419_235603.jpg', '0004/20150419_135604.jpg', '0004/20150419_165601.jpg', '0004/20150420_015604.jpg', '0004/20150419_152601.jpg', '0004/20150415_235601.jpg', '0004/20150420_032621.jpg', '0004/20150415_212609.jpg', '0004/20150420_022601.jpg', '0004/20150419_205559.jpg', '0004/20150419_225558.jpg', '0004/20150415_215603.jpg'], ['0018/0126.png', '0018/0455.png', '0018/0392.png', '0018/0245.png', '0018/0350.png', '0018/0406.png', '0018/0084.png', '0018/0546.png', '0018/0098.png', '0018/0175.png', '0018/0483.png', '0018/0329.png', '0018/0238.png', '0018/0112.png', '0018/0308.png', '0018/0259.png', '0018/0553.png', '0018/0427.png', '0018/0532.png', '0018/0413.png', '0018/0217.png', '0018/0497.png', '0018/0385.png', '0018/0294.png', '0018/0462.png', '0018/0378.png', '0018/0441.png', '0018/0133.png', '0018/0420.png', '0018/0476.png', '0018/0161.png', '0018/0357.png', '0018/0266.png', '0018/0371.png', '0018/0364.png', '0018/0189.png', '0018/0490.png', '0018/0343.png', '0018/0203.png', '0018/0469.png', '0018/0448.png', '0018/0525.png', '0018/0287.png', '0018/0399.png', '0018/0182.png', '0018/0231.png', '0018/0315.png', '0018/0434.png', '0018/0336.png', '0018/0273.png', '0018/0196.png', '0018/0301.png', '0018/0252.png', '0018/0147.png', '0018/0539.png', '0018/0518.png', '0018/0280.png', '0018/0322.png', '0018/0224.png'], ['0028/20150510_061634.jpg', '0028/20150502_181633.jpg', '0028/20150521_151631.jpg', '0028/20150510_141627.jpg', '0028/20150518_141626.jpg', '0028/20150510_131622.jpg', '0028/20150510_041621.jpg', '0028/20150521_141622.jpg', '0028/20150521_171627.jpg', '0028/20150521_041621.jpg', '0028/20150502_131621.jpg', '0028/20150521_051625.jpg', '0028/20150521_081623.jpg', '0028/20150521_071628.jpg', '0028/20150510_111629.jpg', '0028/20150510_091624.jpg', '0028/20150521_094619.jpg', '0028/20150521_121630.jpg', '0028/20150521_161633.jpg', '0028/20150510_051629.jpg', '0028/20150510_071632.jpg', '0028/20150502_171637.jpg', '0028/20150521_131635.jpg', '0028/20150521_061622.jpg', '0028/20150502_111629.jpg', '0028/20150502_161630.jpg', '0028/20150521_111629.jpg', '0028/20150510_101629.jpg', '0028/20150518_161631.jpg', '0028/20150510_121635.jpg', '0028/20150502_121625.jpg', '0028/20150518_151629.jpg', '0028/20150502_141625.jpg', '0028/20150521_101630.jpg', '0028/20150510_161630.jpg', '0028/20150521_091626.jpg', '0028/20150510_151641.jpg', '0028/20150510_191630.jpg'], ['0029/20140601_121644.jpg', '0029/20140604_224637.jpg', '0029/20140601_114638.jpg', '0029/20140601_171630.jpg', '0029/20140601_141638.jpg', '0029/20140604_231637.jpg', '0029/20140601_184636.jpg', '0029/20140601_161641.jpg', '0029/20140601_144631.jpg', '0029/20140601_204637.jpg', '0029/20140601_124648.jpg', '0029/20140601_174637.jpg', '0029/20140601_201629.jpg', '0029/20140601_221631.jpg', '0029/20140601_154643.jpg', '0029/20140601_191642.jpg', '0029/20140601_211632.jpg', '0029/20140601_134642.jpg', '0029/20140601_164637.jpg', '0029/20140604_134633.jpg', '0029/20140601_224636.jpg', '0029/20140601_181638.jpg', '0029/20140601_131632.jpg', '0029/20140604_144642.jpg', '0029/20140601_214642.jpg', '0029/20140601_151635.jpg', '0029/20140604_141642.jpg', '0029/20140603_194640.jpg', '0029/20140604_214637.jpg'], ['0047/0041.png', '0047/0004.png', '0047/0031.png', '0047/0018.png', '0047/0033.png', '0047/0001.png', '0047/0025.png', '0047/0015.png', '0047/0038.png', '0047/0030.png', '0047/0020.png', '0047/0017.png', '0047/0014.png', '0047/0035.png', '0047/0012.png', '0047/0011.png', '0047/0028.png', '0047/0023.png', '0047/0036.png', '0047/0003.png', '0047/0009.png', '0047/0034.png', '0047/0022.png', '0047/0019.png', '0047/0002.png', '0047/0026.png', '0047/0042.png', '0047/0029.png', '0047/0010.png', '0047/0039.png', '0047/0007.png', '0047/0008.png', '0047/0021.png', '0047/0027.png', '0047/0037.png', '0047/0024.png', '0047/0013.png', '0047/0032.png', '0047/0016.png', '0047/0005.png'], ['0052/0101.png', '0052/0077.png', '0052/0117.png', '0052/0074.png', '0052/0004.png', '0052/0024.png', '0052/0001.png', '0052/0091.png', '0052/0044.png', '0052/0114.png', '0052/0061.png', '0052/0021.png', '0052/0054.png', '0052/0071.png', '0052/0124.png', '0052/0014.png', '0052/0104.png', '0052/0037.png', '0052/0094.png', '0052/0047.png', '0052/0031.png', '0052/0017.png', '0052/0011.png', '0052/0007.png', '0052/0064.png', '0052/0034.png', '0052/0057.png', '0052/0067.png', '0052/0051.png', '0052/0041.png', '0052/0081.png', '0052/0027.png', '0052/0097.png', '0052/0087.png', '0052/0084.png', '0052/0121.png'], ['0053/0024.png', '0053/0074.png', '0053/0027.png', '0053/0084.png', '0053/0021.png', '0053/0121.png', '0053/0031.png', '0053/0007.png', '0053/0081.png', '0053/0047.png', '0053/0104.png', '0053/0037.png', '0053/0071.png', '0053/0094.png', '0053/0077.png', '0053/0117.png', '0053/0107.png', '0053/0044.png', '0053/0017.png', '0053/0011.png', '0053/0064.png', '0053/0034.png', '0053/0091.png', '0053/0057.png', '0053/0067.png', '0053/0051.png', '0053/0041.png', '0053/0114.png', '0053/0004.png', '0053/0124.png', '0053/0101.png', '0053/0097.png', '0053/0111.png', '0053/0087.png', '0053/0014.png', '0053/0054.png', '0053/0061.png'], ['0059/0016.png', '0059/0096.png', '0059/0031.png', '0059/0051.png', '0059/0036.png', '0059/0033.png', '0059/0101.png', '0059/0056.png', '0059/0003.png', '0059/0021.png', '0059/0086.png', '0059/0071.png', '0059/0041.png', '0059/0011.png', '0059/0061.png', '0059/0063.png', '0059/0046.png', '0059/0081.png', '0059/0106.png', '0059/0026.png', '0059/0043.png', '0059/0006.png', '0059/0001.png', '0059/0076.png', '0059/0111.png', '0059/0023.png', '0059/0091.png', '0059/0053.png', '0059/0066.png', '0059/0013.png'], ['0118/0012.png', '0118/0019.png', '0118/0001.png', '0118/0008.png', '0118/0002.png', '0118/0016.png', '0118/0022.png', '0118/0005.png', '0118/0020.png', '0118/0006.png', '0118/0017.png', '0118/0011.png', '0118/0018.png', '0118/0024.png', '0118/0007.png', '0118/0013.png', '0118/0010.png', '0118/0015.png', '0118/0023.png', '0118/0009.png', '0118/0004.png', '0118/0003.png', '0118/0014.png', '0118/0021.png'], ['0124/0030.png', '0124/0025.png', '0124/0008.png', '0124/0013.png', '0124/0031.png', '0124/0026.png', '0124/0010.png', '0124/0001.png', '0124/0018.png', '0124/0007.png', '0124/0002.png', '0124/0027.png', '0124/0009.png', '0124/0016.png', '0124/0024.png', '0124/0012.png', '0124/0015.png', '0124/0014.png', '0124/0017.png', '0124/0019.png', '0124/0022.png', '0124/0005.png', '0124/0020.png', '0124/0028.png', '0124/0006.png', '0124/0011.png', '0124/0034.png', '0124/0023.png', '0124/0032.png', '0124/0033.png', '0124/0029.png', '0124/0004.png', '0124/0003.png', '0124/0021.png'], ['0125/0098.png', '0125/0054.png', '0125/0034.png', '0125/0071.png', '0125/0081.png', '0125/0058.png', '0125/0061.png', '0125/0104.png', '0125/0118.png', '0125/0078.png', '0125/0091.png', '0125/0088.png', '0125/0044.png', '0125/0051.png', '0125/0014.png', '0125/0008.png', '0125/0111.png', '0125/0001.png', '0125/0041.png', '0125/0074.png', '0125/0011.png', '0125/0004.png', '0125/0148.png', '0125/0094.png', '0125/0108.png', '0125/0028.png', '0125/0068.png', '0125/0031.png', '0125/0018.png', '0125/0024.png', '0125/0064.png', '0125/0141.png', '0125/0128.png', '0125/0114.png', '0125/0124.png', '0125/0101.png', '0125/0134.png', '0125/0084.png', '0125/0038.png', '0125/0154.png', '0125/0048.png', '0125/0021.png', '0125/0121.png'], ['0129/0095.png', '0129/0030.png', '0129/0175.png', '0129/0165.png', '0129/0130.png', '0129/0090.png', '0129/0020.png', '0129/0155.png', '0129/0070.png', '0129/0075.png', '0129/0060.png', '0129/0105.png', '0129/0120.png', '0129/0100.png', '0129/0115.png', '0129/0010.png', '0129/0025.png', '0129/0055.png', '0129/0065.png', '0129/0160.png', '0129/0005.png', '0129/0045.png', '0129/0150.png', '0129/0140.png', '0129/0085.png', '0129/0015.png', '0129/0180.png', '0129/0035.png', '0129/0125.png', '0129/0040.png', '0129/0135.png', '0129/0080.png', '0129/0170.png', '0129/0145.png', '0129/0110.png', '0129/0050.png'], ['0130/20140504_191014.jpg', '0130/20140504_071017.jpg', '0130/20140503_164009.jpg', '0130/20140504_094015.jpg', '0130/20140504_101018.jpg', '0130/20140504_144015.jpg', '0130/20140504_041020.jpg', '0130/20140504_081024.jpg', '0130/20140504_154024.jpg', '0130/20140504_064022.jpg', '0130/20140504_141013.jpg', '0130/20140504_074021.jpg', '0130/20140504_091008.jpg', '0130/20140504_181020.jpg', '0130/20140504_044021.jpg', '0130/20140504_114015.jpg', '0130/20140504_051013.jpg', '0130/20140504_131015.jpg', '0130/20140504_161013.jpg', '0130/20140504_174015.jpg', '0130/20140504_104020.jpg', '0130/20140504_061026.jpg', '0130/20140504_111020.jpg', '0130/20140504_124015.jpg', '0130/20140504_034021.jpg', '0130/20140504_184022.jpg', '0130/20140504_054013.jpg', '0130/20140504_134018.jpg', '0130/20140504_121018.jpg', '0130/20140504_084015.jpg', '0130/20140504_171017.jpg', '0130/20140504_151018.jpg', '0130/20140504_164016.jpg'], ['0134/20130607_093240.jpg', '0134/20130607_080241.jpg', '0134/20130607_100253.jpg', '0134/20130607_123245.jpg', '0134/20130607_143254.jpg', '0134/20130607_130252.jpg', '0134/20130607_153256.jpg', '0134/20130607_173248.jpg', '0134/20130607_070249.jpg', '0134/20130607_120246.jpg', '0134/20130607_083240.jpg', '0134/20130607_163245.jpg', '0134/20130607_150242.jpg', '0134/20130607_140248.jpg', '0134/20130607_183249.jpg', '0134/20130607_170243.jpg', '0134/20130607_180242.jpg', '0134/20130607_110244.jpg', '0134/20130607_103251.jpg', '0134/20130607_073238.jpg', '0134/20130607_113251.jpg', '0134/20130607_133248.jpg', '0134/20130607_160242.jpg', '0134/20130607_090242.jpg'], ['0157/0056.png', '0157/0059.png', '0157/0020.png', '0157/0022.png', '0157/0063.png', '0157/0048.png', '0157/0025.png', '0157/0054.png', '0157/0014.png', '0157/0019.png', '0157/0026.png', '0157/0036.png', '0157/0066.png', '0157/0047.png', '0157/0030.png', '0157/0021.png', '0157/0043.png', '0157/0042.png', '0157/0031.png', '0157/0041.png', '0157/0057.png', '0157/0055.png', '0157/0024.png', '0157/0011.png', '0157/0037.png', '0157/0032.png', '0157/0067.png', '0157/0034.png', '0157/0061.png', '0157/0046.png', '0157/0051.png', '0157/0049.png', '0157/0157.png', '0157/0147.png', '0157/0018.png', '0157/0068.png', '0157/0064.png', '0157/0010.png', '0157/0012.png', '0157/0045.png', '0157/0060.png', '0157/0029.png', '0157/0065.png', '0157/0013.png', '0157/0040.png', '0157/0028.png', '0157/0044.png', '0157/0027.png', '0157/0016.png', '0157/0033.png', '0157/0062.png', '0157/0052.png', '0157/0023.png', '0157/0015.png', '0157/0035.png', '0157/0053.png', '0157/0058.png', '0157/0017.png', '0157/0152.png', '0157/0039.png', '0157/0050.png', '0157/0038.png'], ['0159/056.png', '0159/000.png', '0159/029.png', '0159/027.png', '0159/009.png', '0159/014.png', '0159/042.png', '0159/008.png', '0159/024.png', '0159/041.png', '0159/060.png', '0159/010.png', '0159/047.png', '0159/003.png', '0159/058.png', '0159/022.png', '0159/051.png', '0159/052.png', '0159/025.png', '0159/006.png', '0159/004.png', '0159/050.png', '0159/026.png', '0159/055.png', '0159/030.png', '0159/033.png', '0159/002.png', '0159/049.png', '0159/017.png', '0159/043.png', '0159/053.png', '0159/054.png', '0159/011.png', '0159/016.png', '0159/007.png', '0159/044.png', '0159/005.png', '0159/062.png', '0159/063.png', '0159/032.png', '0159/020.png', '0159/040.png', '0159/059.png', '0159/021.png', '0159/046.png', '0159/001.png', '0159/028.png', '0159/023.png', '0159/035.png', '0159/031.png', '0159/045.png', '0159/061.png', '0159/057.png', '0159/039.png', '0159/037.png', '0159/036.png', '0159/038.png', '0159/013.png', '0159/034.png', '0159/048.png'], ['0300/0054.png', '0300/0014.png', '0300/0076.png', '0300/0055.png', '0300/0049.png', '0300/0008.png', '0300/0028.png', '0300/0061.png', '0300/0050.png', '0300/0060.png', '0300/0065.png', '0300/0053.png', '0300/0015.png', '0300/0011.png', '0300/0006.png', '0300/0074.png', '0300/0024.png', '0300/0019.png', '0300/0063.png', '0300/0016.png', '0300/0010.png', '0300/0075.png', '0300/0058.png', '0300/0056.png', '0300/0073.png', '0300/0023.png', '0300/0069.png', '0300/0046.png', '0300/0059.png', '0300/0078.png', '0300/0026.png', '0300/0051.png', '0300/0018.png', '0300/0048.png', '0300/0071.png', '0300/0064.png', '0300/0068.png', '0300/0021.png', '0300/0025.png', '0300/0020.png', '0300/0066.png', '0300/0070.png'], ['0306/0012.png', '0306/0021.png', '0306/0009.png', '0306/0025.png', '0306/0006.png', '0306/0019.png', '0306/0001.png', '0306/0007.png', '0306/0010.png', '0306/0049.png', '0306/0003.png', '0306/0020.png', '0306/0011.png', '0306/0048.png', '0306/0045.png', '0306/0008.png', '0306/0047.png', '0306/0005.png', '0306/0002.png', '0306/0013.png', '0306/0022.png', '0306/0017.png', '0306/0014.png', '0306/0023.png', '0306/0015.png', '0306/0024.png', '0306/0046.png', '0306/0044.png', '0306/0016.png', '0306/0004.png', '0306/0026.png', '0306/0018.png'], ['0310/0057.png', '0310/0107.png', '0310/0047.png', '0310/0097.png', '0310/0095.png', '0310/0067.png', '0310/0117.png', '0310/0119.png', '0310/0065.png', '0310/0061.png', '0310/0071.png', '0310/0114.png', '0310/0087.png', '0310/0115.png', '0310/0101.png', '0310/0044.png', '0310/0091.png', '0310/0094.png', '0310/0085.png', '0310/0111.png', '0310/0084.png', '0310/0051.png', '0310/0054.png', '0310/0105.png', '0310/0077.png', '0310/0104.png', '0310/0045.png', '0310/0055.png', '0310/0075.png', '0310/0081.png', '0310/0074.png', '0310/0064.png'], ['0356/0232.png', '0356/0202.png', '0356/0242.png', '0356/0122.png', '0356/0272.png', '0356/0262.png', '0356/0033.png', '0356/0052.png', '0356/0224.png', '0356/0112.png', '0356/0002.png', '0356/0192.png', '0356/0282.png', '0356/0132.png', '0356/0102.png', '0356/0092.png', '0356/0082.png', '0356/0012.png', '0356/0062.png', '0356/0072.png', '0356/0310.png', '0356/0042.png', '0356/0292.png', '0356/0022.png', '0356/0252.png'], ['0381/0028.png', '0381/0001.png', '0381/0012.png', '0381/0032.png', '0381/0013.png', '0381/0008.png', '0381/0030.png', '0381/0011.png', '0381/0034.png', '0381/0009.png', '0381/0036.png', '0381/0029.png', '0381/0014.png', '0381/0031.png', '0381/0010.png', '0381/0015.png', '0381/0035.png', '0381/0002.png', '0381/0033.png', '0381/0037.png'], ['0400/0007.png', '0400/0027.png', '0400/0023.png', '0400/0021.png', '0400/0026.png', '0400/0035.png', '0400/0030.png', '0400/0001.png', '0400/0010.png', '0400/0022.png', '0400/0008.png', '0400/0025.png', '0400/0032.png', '0400/0031.png', '0400/0009.png', '0400/0028.png', '0400/0033.png', '0400/0029.png', '0400/0024.png', '0400/0034.png'], ['0419/0107.png', '0419/0104.png', '0419/0117.png', '0419/0095.png', '0419/0123.png', '0419/0075.png', '0419/0098.png', '0419/0101.png', '0419/0112.png', '0419/0102.png', '0419/0108.png', '0419/0094.png', '0419/0092.png', '0419/0109.png', '0419/0085.png', '0419/0111.png', '0419/0078.png', '0419/0074.png', '0419/0122.png', '0419/0073.png', '0419/0089.png', '0419/0128.png', '0419/0127.png', '0419/0099.png', '0419/0116.png', '0419/0106.png', '0419/0115.png', '0419/0084.png', '0419/0080.png', '0419/0086.png', '0419/0096.png', '0419/0130.png', '0419/0079.png', '0419/0124.png', '0419/0121.png', '0419/0076.png', '0419/0126.png', '0419/0118.png', '0419/0087.png', '0419/0119.png', '0419/0114.png', '0419/0091.png', '0419/0093.png', '0419/0072.png', '0419/0110.png', '0419/0088.png', '0419/0090.png', '0419/0113.png', '0419/0120.png', '0419/0082.png', '0419/0070.png', '0419/0081.png', '0419/0100.png', '0419/0105.png', '0419/0083.png', '0419/0097.png', '0419/0071.png', '0419/0077.png', '0419/0125.png', '0419/0103.png'], ['0420/0064.png', '0420/0008.png', '0420/0044.png', '0420/0028.png', '0420/0061.png', '0420/0018.png', '0420/0001.png', '0420/0048.png', '0420/0041.png', '0420/0024.png', '0420/0081.png', '0420/0084.png', '0420/0068.png', '0420/0074.png', '0420/0038.png', '0420/0014.png', '0420/0058.png', '0420/0011.png', '0420/0034.png', '0420/0031.png', '0420/0071.png', '0420/0021.png', '0420/0078.png', '0420/0054.png', '0420/0051.png', '0420/0004.png', '0420/0088.png', '0420/0091.png'], ['0422/0009.png', '0422/0001.png', '0422/0011.png', '0422/0003.png', '0422/0002.png', '0422/0006.png', '0422/0013.png', '0422/0005.png', '0422/0015.png', '0422/0004.png', '0422/0007.png', '0422/0008.png'], ['0424/0010.png', '0424/0026.png', '0424/0017.png', '0424/0023.png', '0424/0022.png', '0424/0019.png', '0424/0013.png', '0424/0025.png', '0424/0018.png', '0424/0009.png', '0424/0020.png', '0424/0016.png', '0424/0008.png', '0424/0015.png', '0424/0012.png', '0424/0032.png', '0424/0007.png', '0424/0014.png', '0424/0004.png', '0424/0005.png', '0424/0003.png', '0424/0021.png', '0424/0006.png', '0424/0002.png', '0424/0011.png', '0424/0001.png'], ['0425/0054.png', '0425/0002.png', '0425/0047.png', '0425/0032.png', '0425/0024.png', '0425/0006.png', '0425/0001.png', '0425/0007.png', '0425/0037.png', '0425/0041.png', '0425/0004.png', '0425/0003.png', '0425/0005.png'], ['0431/0001.png', '0431/0025.png', '0431/0051.png', '0431/0011.png', '0431/0022.png', '0431/0035.png', '0431/0026.png', '0431/0024.png', '0431/0037.png', '0431/0020.png', '0431/0030.png', '0431/0032.png', '0431/0029.png', '0431/0021.png', '0431/0019.png', '0431/0034.png', '0431/0027.png', '0431/0057.png', '0431/0023.png', '0431/0028.png', '0431/0031.png', '0431/0007.png', '0431/0017.png', '0431/0033.png', '0431/0041.png', '0431/0067.png', '0431/0061.png', '0431/0047.png', '0431/0071.png'], ['0433/0046.png', '0433/0031.png', '0433/0006.png', '0433/0044.png', '0433/0016.png', '0433/0021.png', '0433/0061.png', '0433/0033.png', '0433/0056.png', '0433/0042.png', '0433/0026.png', '0433/0045.png', '0433/0001.png', '0433/0038.png', '0433/0048.png', '0433/0047.png', '0433/0035.png', '0433/0040.png', '0433/0041.png', '0433/0011.png', '0433/0034.png', '0433/0039.png', '0433/0037.png', '0433/0051.png', '0433/0036.png', '0433/0043.png'], ['0437/0014.png', '0437/0017.png', '0437/0054.png', '0437/0031.png', '0437/0057.png', '0437/0019.png', '0437/0024.png', '0437/0051.png', '0437/0011.png', '0437/0004.png', '0437/0061.png', '0437/0027.png', '0437/0009.png', '0437/0025.png', '0437/0071.png', '0437/0067.png', '0437/0044.png', '0437/0021.png', '0437/0001.png', '0437/0034.png', '0437/0037.png', '0437/0047.png', '0437/0007.png', '0437/0064.png', '0437/0041.png'], ['0438/0071.png', '0438/0001.png', '0438/0022.png', '0438/0044.png', '0438/0064.png', '0438/0042.png', '0438/0040.png', '0438/0067.png', '0438/0027.png', '0438/0028.png', '0438/0041.png', '0438/0054.png', '0438/0074.png', '0438/0007.png', '0438/0077.png', '0438/0026.png', '0438/0024.png', '0438/0023.png', '0438/0037.png', '0438/0004.png', '0438/0043.png', '0438/0025.png', '0438/0084.png', '0438/0081.png'], ['0439/0017.png', '0439/0007.png', '0439/0021.png', '0439/0057.png', '0439/0051.png', '0439/0011.png', '0439/0074.png', '0439/0061.png', '0439/0027.png', '0439/0037.png', '0439/0034.png', '0439/0084.png', '0439/0031.png', '0439/0047.png', '0439/0044.png', '0439/0064.png', '0439/0010.png', '0439/0091.png', '0439/0028.png', '0439/0071.png', '0439/0008.png', '0439/0024.png', '0439/0014.png', '0439/0081.png', '0439/0012.png', '0439/0009.png', '0439/0026.png', '0439/0094.png', '0439/0067.png', '0439/0001.png', '0439/0054.png', '0439/0041.png', '0439/0004.png'], ['0441/0064.png', '0441/0094.png', '0441/0043.png', '0441/0083.png', '0441/0096.png', '0441/0019.png', '0441/0003.png', '0441/0001.png', '0441/0054.png', '0441/0011.png', '0441/0029.png', '0441/0077.png', '0441/0076.png', '0441/0006.png', '0441/0086.png', '0441/0063.png', '0441/0012.png', '0441/0005.png', '0441/0093.png', '0441/0095.png', '0441/0008.png', '0441/0098.png', '0441/0100.png', '0441/0074.png', '0441/0013.png', '0441/0070.png', '0441/0092.png', '0441/0022.png', '0441/0024.png', '0441/0007.png', '0441/0067.png', '0441/0002.png', '0441/0090.png', '0441/0082.png', '0441/0089.png', '0441/0079.png', '0441/0009.png', '0441/0085.png', '0441/0099.png', '0441/0052.png', '0441/0010.png', '0441/0084.png', '0441/0021.png', '0441/0088.png', '0441/0020.png', '0441/0027.png', '0441/0032.png', '0441/0091.png'], ['0449/0022.png', '0449/0028.png', '0449/0026.png', '0449/0024.png', '0449/0019.png', '0449/0020.png', '0449/0017.png', '0449/0027.png', '0449/0016.png', '0449/0018.png', '0449/0030.png', '0449/0029.png', '0449/0025.png', '0449/0021.png', '0449/0023.png'], ['0450/0032.png', '0450/0035.png', '0450/0033.png', '0450/0043.png', '0450/0046.png', '0450/0034.png', '0450/0041.png', '0450/0040.png', '0450/0048.png', '0450/0038.png', '0450/0037.png', '0450/0045.png', '0450/0047.png', '0450/0039.png', '0450/0042.png', '0450/0031.png', '0450/0044.png', '0450/0036.png'], ['0452/0070.png', '0452/0069.png', '0452/0064.png', '0452/0062.png', '0452/0065.png', '0452/0063.png', '0452/0066.png', '0452/0060.png', '0452/0068.png', '0452/0067.png', '0452/0061.png', '0452/0059.png'], ['0454/0108.png', '0454/0111.png', '0454/0103.png', '0454/0110.png', '0454/0104.png', '0454/0114.png', '0454/0113.png', '0454/0109.png', '0454/0112.png', '0454/0115.png', '0454/0106.png', '0454/0105.png', '0454/0107.png', '0454/0102.png'], ['0460/0055.png', '0460/0042.png', '0460/0044.png', '0460/0035.png', '0460/0034.png', '0460/0023.png', '0460/0011.png', '0460/0043.png', '0460/0036.png', '0460/0010.png', '0460/0001.png', '0460/0038.png'], ['0462/0005.png', '0462/0008.png', '0462/0002.png', '0462/0001.png', '0462/0011.png', '0462/0044.png', '0462/0006.png', '0462/0047.png', '0462/0034.png', '0462/0037.png', '0462/0003.png', '0462/0009.png', '0462/0018.png', '0462/0077.png', '0462/0050.png', '0462/0045.png', '0462/0068.png', '0462/0062.png', '0462/0052.png', '0462/0042.png', '0462/0007.png', '0462/0058.png', '0462/0004.png', '0462/0043.png', '0462/0061.png'], ['0465/0021.png', '0465/0017.png', '0465/0044.png', '0465/0050.png', '0465/0018.png', '0465/0014.png', '0465/0016.png', '0465/0023.png', '0465/0041.png', '0465/0064.png', '0465/0015.png', '0465/0019.png', '0465/0022.png', '0465/0058.png', '0465/0013.png', '0465/0020.png', '0465/0026.png', '0465/0001.png'], ['0468/0020.png', '0468/0001.png', '0468/0049.png', '0468/0044.png', '0468/0030.png', '0468/0021.png', '0468/0026.png', '0468/0018.png', '0468/0047.png', '0468/0070.png'], ['0469/0012.png', '0469/0001.png', '0469/0047.png', '0469/0011.png', '0469/0052.png', '0469/0010.png', '0469/0004.png', '0469/0027.png', '0469/0048.png'], ['0470/0074.png', '0470/0077.png', '0470/0001.png', '0470/0008.png', '0470/0068.png', '0470/0011.png', '0470/0018.png', '0470/0024.png', '0470/0034.png', '0470/0051.png', '0470/0078.png', '0470/0004.png', '0470/0014.png', '0470/0054.png', '0470/0082.png'], ['0471/0058.png', '0471/0001.png', '0471/0044.png', '0471/0031.png', '0471/0011.png', '0471/0043.png', '0471/0042.png', '0471/0035.png', '0471/0039.png', '0471/0051.png', '0471/0041.png', '0471/0040.png', '0471/0036.png', '0471/0046.png', '0471/0045.png', '0471/0038.png', '0471/0061.png', '0471/0021.png'], ['0472/0011.png', '0472/0001.png', '0472/0020.png', '0472/0013.png', '0472/0010.png', '0472/0027.png', '0472/0026.png', '0472/0029.png', '0472/0012.png', '0472/0028.png'], ['0473/0037.png', '0473/0012.png', '0473/0001.png', '0473/0013.png', '0473/0015.png', '0473/0040.png', '0473/0036.png', '0473/0014.png', '0473/0048.png'], ['0474/0030.png', '0474/0037.png', '0474/0019.png', '0474/0001.png', '0474/0016.png', '0474/0020.png', '0474/0028.png', '0474/0044.png', '0474/0031.png', '0474/0017.png', '0474/0018.png', '0474/0064.png', '0474/0043.png', '0474/0042.png', '0474/0035.png', '0474/0039.png', '0474/0041.png', '0474/0040.png', '0474/0036.png', '0474/0033.png', '0474/0029.png', '0474/0055.png', '0474/0027.png', '0474/0046.png', '0474/0056.png', '0474/0054.png', '0474/0038.png'], ['0475/0030.png', '0475/0019.png', '0475/0001.png', '0475/0022.png', '0475/0020.png', '0475/0028.png', '0475/0011.png', '0475/0018.png', '0475/0024.png', '0475/0010.png', '0475/0042.png', '0475/0025.png', '0475/0023.png', '0475/0041.png', '0475/0040.png', '0475/0029.png', '0475/0026.png', '0475/0027.png', '0475/0021.png'], ['0477/0010.png', '0477/0017.png', '0477/0022.png', '0477/0001.png', '0477/0015.png', '0477/0013.png', '0477/0019.png', '0477/0009.png', '0477/0025.png', '0477/0026.png', '0477/0033.png'], ['0483/0012.png', '0483/0028.png', '0483/0011.png', '0483/0024.png', '0483/0033.png']]
25,809
25,809
0.668953
4,389
25,809
3.89542
0.108909
0.024975
0.027198
0.002457
0
0
0
0
0
0
0
0.52764
0.054477
25,809
1
25,809
25,809
0.172971
0
0
0
0
0
0.777954
0.156219
0
0
0
0
0
1
0
true
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
0
0
0
1
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
7
ca9f480d442cc50ec868a762fd97ea48581c0c39
139
py
Python
app/main_page/routes.py
larsertoff/pwp
1f156e3efc7b93345197329425e2928a470d3092
[ "MIT" ]
null
null
null
app/main_page/routes.py
larsertoff/pwp
1f156e3efc7b93345197329425e2928a470d3092
[ "MIT" ]
null
null
null
app/main_page/routes.py
larsertoff/pwp
1f156e3efc7b93345197329425e2928a470d3092
[ "MIT" ]
null
null
null
import flask from app.main_page import main_page @main_page.route('/') def home_page(): return flask.render_template('main_page.html')
23.166667
50
0.769784
22
139
4.590909
0.590909
0.316832
0
0
0
0
0
0
0
0
0
0
0.107914
139
6
50
23.166667
0.814516
0
0
0
0
0
0.107143
0
0
0
0
0
0
1
0.2
true
0
0.4
0.2
0.8
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
1
1
0
0
7
cabd0ef9c18b55894f3df62603f91de2f905c778
5,408
py
Python
notebook/numpy_reshape.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
174
2018-05-30T21:14:50.000Z
2022-03-25T07:59:37.000Z
notebook/numpy_reshape.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
5
2019-08-10T03:22:02.000Z
2021-07-12T20:31:17.000Z
notebook/numpy_reshape.py
vhn0912/python-snippets
80b2e1d6b2b8f12ae30d6dbe86d25bb2b3a02038
[ "MIT" ]
53
2018-04-27T05:26:35.000Z
2022-03-25T07:59:37.000Z
import numpy as np a = np.arange(24) print(a) # [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23] print(a.shape) # (24,) print(a.ndim) # 1 a_4_6 = a.reshape([4, 6]) print(a_4_6) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] print(a_4_6.shape) # (4, 6) print(a_4_6.ndim) # 2 a_2_3_4 = a.reshape([2, 3, 4]) print(a_2_3_4) # [[[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] # # [[12 13 14 15] # [16 17 18 19] # [20 21 22 23]]] print(a_2_3_4.shape) # (2, 3, 4) print(a_2_3_4.ndim) # 3 # a_5_6 = a.reshape([5, 6]) # ValueError: cannot reshape array of size 24 into shape (5,6) print(a.reshape(4, 6)) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] print(a.reshape(2, 3, 4)) # [[[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] # # [[12 13 14 15] # [16 17 18 19] # [20 21 22 23]]] print(np.reshape(a, [4, 6])) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] print(np.reshape(a, [2, 3, 4])) # [[[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] # # [[12 13 14 15] # [16 17 18 19] # [20 21 22 23]]] # print(np.reshape(a, [5, 6])) # ValueError: cannot reshape array of size 24 into shape (5,6) print(a.reshape(4, 6)) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] # print(np.reshape(a, 4, 6)) # ValueError: cannot reshape array of size 24 into shape (4,) print(a.reshape([4, 6], order='C')) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] print(a.reshape([4, 6], order='F')) # [[ 0 4 8 12 16 20] # [ 1 5 9 13 17 21] # [ 2 6 10 14 18 22] # [ 3 7 11 15 19 23]] print(a.reshape([2, 3, 4], order='C')) # [[[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] # # [[12 13 14 15] # [16 17 18 19] # [20 21 22 23]]] print(a.reshape([2, 3, 4], order='F')) # [[[ 0 6 12 18] # [ 2 8 14 20] # [ 4 10 16 22]] # # [[ 1 7 13 19] # [ 3 9 15 21] # [ 5 11 17 23]]] print(np.reshape(a, [4, 6], order='F')) # [[ 0 4 8 12 16 20] # [ 1 5 9 13 17 21] # [ 2 6 10 14 18 22] # [ 3 7 11 15 19 23]] # print(a.reshape([4, 6], 'F')) # TypeError: 'list' object cannot be interpreted as an integer print(np.reshape(a, [4, 6], 'F')) # [[ 0 4 8 12 16 20] # [ 1 5 9 13 17 21] # [ 2 6 10 14 18 22] # [ 3 7 11 15 19 23]] print(a.reshape([4, -1])) # [[ 0 1 2 3 4 5] # [ 6 7 8 9 10 11] # [12 13 14 15 16 17] # [18 19 20 21 22 23]] print(a.reshape([2, -1, 4])) # [[[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] # # [[12 13 14 15] # [16 17 18 19] # [20 21 22 23]]] # print(a.reshape([2, -1, -1])) # ValueError: can only specify one unknown dimension # print(a.reshape([2, -1, 5])) # ValueError: cannot reshape array of size 24 into shape (2,newaxis,5) a = np.arange(8) print(a) # [0 1 2 3 4 5 6 7] a_2_4 = a.reshape([2, 4]) print(a_2_4) # [[0 1 2 3] # [4 5 6 7]] print(np.shares_memory(a, a_2_4)) # True a[0] = 100 print(a) # [100 1 2 3 4 5 6 7] print(a_2_4) # [[100 1 2 3] # [ 4 5 6 7]] a_2_4[0, 0] = 0 print(a_2_4) # [[0 1 2 3] # [4 5 6 7]] print(a) # [0 1 2 3 4 5 6 7] a_2_4_copy = a.reshape([2, 4]).copy() print(a_2_4_copy) # [[0 1 2 3] # [4 5 6 7]] print(np.shares_memory(a, a_2_4_copy)) # False a[0] = 100 print(a) # [100 1 2 3 4 5 6 7] print(a_2_4_copy) # [[0 1 2 3] # [4 5 6 7]] a_2_4_copy[0, 0] = 200 print(a_2_4_copy) # [[200 1 2 3] # [ 4 5 6 7]] print(a) # [100 1 2 3 4 5 6 7] a = np.arange(6).reshape(2, 3) print(a) # [[0 1 2] # [3 4 5]] a_step = a[:, ::2] print(a_step) # [[0 2] # [3 5]] print(a_step.reshape(-1)) # [0 2 3 5] print(np.shares_memory(a_step, a_step.reshape(-1))) # False np.info(a) # class: ndarray # shape: (2, 3) # strides: (24, 8) # itemsize: 8 # aligned: True # contiguous: True # fortran: False # data pointer: 0x7fb49bf71950 # byteorder: little # byteswap: False # type: int64 np.info(a_step) # class: ndarray # shape: (2, 2) # strides: (24, 16) # itemsize: 8 # aligned: True # contiguous: False # fortran: False # data pointer: 0x7fb49bf71950 # byteorder: little # byteswap: False # type: int64 np.info(a_step.reshape(-1)) # class: ndarray # shape: (4,) # strides: (8,) # itemsize: 8 # aligned: True # contiguous: True # fortran: True # data pointer: 0x7fb49e162210 # byteorder: little # byteswap: False # type: int64 a = np.arange(8).reshape(2, 4) print(a) # [[0 1 2 3] # [4 5 6 7]] a_step = a[:, ::2] print(a_step) # [[0 2] # [4 6]] print(a_step.reshape(-1)) # [0 2 4 6] print(np.shares_memory(a_step, a_step.reshape(-1))) # True np.info(a) # class: ndarray # shape: (2, 4) # strides: (32, 8) # itemsize: 8 # aligned: True # contiguous: True # fortran: False # data pointer: 0x7fb49e0e1c40 # byteorder: little # byteswap: False # type: int64 np.info(a_step) # class: ndarray # shape: (2, 2) # strides: (32, 16) # itemsize: 8 # aligned: True # contiguous: False # fortran: False # data pointer: 0x7fb49e0e1c40 # byteorder: little # byteswap: False # type: int64 np.info(a_step.reshape(-1)) # class: ndarray # shape: (4,) # strides: (16,) # itemsize: 8 # aligned: True # contiguous: False # fortran: False # data pointer: 0x7fb49e0e1c40 # byteorder: little # byteswap: False # type: int64
17.059937
75
0.537167
1,087
5,408
2.608096
0.078197
0.027513
0.037037
0.035273
0.86843
0.845503
0.814815
0.777072
0.748148
0.715344
0
0.254037
0.278661
5,408
316
76
17.113924
0.472699
0.655695
0
0.5
0
0
0.003599
0
0
0
0
0
0
1
0
false
0
0.015625
0
0.015625
0.671875
0
0
0
null
0
0
0
1
1
1
1
1
1
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
9
1b147e9d1b6e57f71054a7151e0d2dd17fff320e
16,676
py
Python
models/action.py
z1pti3/jimiPlugin-whoisxmlapi
422b864b96c71750fdbbc475e1def32cb078321a
[ "Apache-2.0" ]
1
2021-07-26T15:02:29.000Z
2021-07-26T15:02:29.000Z
models/action.py
z1pti3/jimiPlugin-whoisxmlapi
422b864b96c71750fdbbc475e1def32cb078321a
[ "Apache-2.0" ]
null
null
null
models/action.py
z1pti3/jimiPlugin-whoisxmlapi
422b864b96c71750fdbbc475e1def32cb078321a
[ "Apache-2.0" ]
null
null
null
from core.models import action from core import auth, db, helpers from plugins.whoisxmlapi.includes import whoisxmlapi class _whoisxmlapiWhois(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).whois(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["whois"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiWhois,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiWhoisHistory(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).whoisHistory(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["whois"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiWhoisHistory,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiGetSubdomains(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).subdomains(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiGetSubdomains,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiReverseIPLookup(action._action): apiToken = str() ip = str() def run(self,data,persistentData,actionResult): ip = helpers.evalString(self.ip,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).reverseIPLookup(ip) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiReverseIPLookup,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiReverseMXLookup(action._action): apiToken = str() mailServerFQDN = str() def run(self,data,persistentData,actionResult): mailServerFQDN = helpers.evalString(self.mailServerFQDN,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).reverseMXLookup(mailServerFQDN) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiReverseMXLookup,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiWebsiteScreenshot(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).websiteScreenshot(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["base64Image"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiWebsiteScreenshot,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiVerifyEmail(action._action): apiToken = str() emailAddress = str() def run(self,data,persistentData,actionResult): emailAddress = helpers.evalString(self.emailAddress,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).verifyEmail(emailAddress) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiVerifyEmail,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiIPGeolocation(action._action): apiToken = str() ip = str() def run(self,data,persistentData,actionResult): ip = helpers.evalString(self.ip,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).ipGeolocation(ip) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiIPGeolocation,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiDNSLookup(action._action): apiToken = str() domainName = str() lookupType = "A" def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) lookupType = helpers.evalString(self.lookupType,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).dnsLookup(domainName,lookupType) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiDNSLookup,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiNetblockLookup(action._action): apiToken = str() ip = str() mask = str() asn = str() def run(self,data,persistentData,actionResult): ip = helpers.evalString(self.ip,{"data" : data}) mask = helpers.evalString(self.mask,{"data" : data}) asn = helpers.evalString(self.asn,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = None if asn: result = whoisxmlapi._whoisxmlapi(apiToken).netblock(asn=asn) elif ip and mask: result = whoisxmlapi._whoisxmlapi(apiToken).netblock(ip=ip,mask=mask) elif ip: result = whoisxmlapi._whoisxmlapi(apiToken).netblock(ip=ip) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["apiResult"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiNetblockLookup,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiDomainReputation(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).domainReputation(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["base64Image"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiDomainReputation,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiDomainCategorization(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).domainCategorization(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["base64Image"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiDomainCategorization,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiDomainContacts(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).websiteContacts(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["base64Image"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiDomainContacts,self).setAttribute(attr,value,sessionData=sessionData) class _whoisxmlapiDomainAvailabilityCheck(action._action): apiToken = str() domainName = str() def run(self,data,persistentData,actionResult): domainName = helpers.evalString(self.domainName,{"data" : data}) apiToken = auth.getPasswordFromENC(self.apiToken) result = whoisxmlapi._whoisxmlapi(apiToken).domainAvailabilityCheck(domainName) if result: actionResult["result"] = True actionResult["rc"] = 0 actionResult["base64Image"] = result else: actionResult["result"] = False actionResult["rc"] = 404 actionResult["msg"] = "Failed to get a valid response from whoisxmlapi API" return actionResult def setAttribute(self,attr,value,sessionData=None): if attr == "apiToken" and not value.startswith("ENC "): if db.fieldACLAccess(sessionData,self.acl,attr,accessType="write"): self.apiToken = "ENC {0}".format(auth.getENCFromPassword(value)) return True return False return super(_whoisxmlapiDomainAvailabilityCheck,self).setAttribute(attr,value,sessionData=sessionData)
40.673171
111
0.64236
1,584
16,676
6.72601
0.058712
0.031537
0.052562
0.054064
0.871598
0.867468
0.857049
0.776704
0.771447
0.771447
0
0.006405
0.250959
16,676
409
112
40.772616
0.84653
0
0
0.818991
0
0
0.090735
0
0
0
0
0
0
1
0.083086
false
0.083086
0.008902
0
0.391691
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
8
1b8679eac57b0f343c1142b3d666c8701d426e9b
4,570
py
Python
demo/config/datasets.py
heurezjusz/Athena
0bdda97b0e06dbb3c1699d4ed7875e4adc96d580
[ "BSD-2-Clause" ]
2
2016-02-02T12:59:39.000Z
2018-03-29T17:17:11.000Z
demo/config/datasets.py
heurezjusz/Athenet
0bdda97b0e06dbb3c1699d4ed7875e4adc96d580
[ "BSD-2-Clause" ]
5
2016-01-10T23:23:57.000Z
2016-03-26T16:29:42.000Z
demo/config/datasets.py
heurezjusz/Athena
0bdda97b0e06dbb3c1699d4ed7875e4adc96d580
[ "BSD-2-Clause" ]
1
2020-02-26T20:19:17.000Z
2020-02-26T20:19:17.000Z
""" Dataset - set (list) of configs given to algorithm as an input. "datasets" is a dictionary from algorithm shortcut to list of available datasets. Do not forget to update help message after changing! """ datasets = { "sender": [[(0.3, 0.75)], [(0.02, 1.0), (0.04, 1.0), (0.06, 1.0), (0.08, 1.0), (0.1, 1.0), (0.12, 1.0), (0.14, 1.0), (0.16, 1.0), (0.18, 1.0), (0.2, 1.0), (0.22, 1.0), (0.24, 1.0), (0.26, 1.0), (0.28, 1.0), (0.3, 1.0), (0.325, 1.0), (0.35, 1.0), (0.375, 1.0), (0.4, 1.0), (0.45, 1.0), (0.5, 1.0), (0.55, 1.0), (0.6, 1.0), (0.7, 1.0), (0.8, 1.0), (0.9, 1.0)], [(0.02, 0.75), (0.04, 0.75), (0.06, 0.75), (0.08, 0.75), (0.1, 0.75), (0.12, 0.75), (0.14, 0.75), (0.16, 0.75), (0.18, 0.75), (0.2, 0.75), (0.22, 0.75), (0.24, 0.75), (0.26, 0.75), (0.28, 0.75), (0.3, 0.75), (0.325, 0.75), (0.35, 0.75), (0.375, 0.75), (0.4, 0.75), (0.45, 0.75), (0.5, 0.75), (0.55, 0.75), (0.6, 0.75), (0.7, 0.75), (0.8, 0.75), (0.9, 0.75)], [(0.02, 0.5), (0.04, 0.5), (0.06, 0.5), (0.08, 0.5), (0.1, 0.5), (0.12, 0.5), (0.14, 0.5), (0.16, 0.5), (0.18, 0.5), (0.2, 0.5), (0.22, 0.5), (0.24, 0.5), (0.26, 0.5), (0.28, 0.5), (0.3, 0.5), (0.325, 0.5), (0.35, 0.5), (0.375, 0.5), (0.4, 0.5), (0.45, 0.5), (0.5, 0.5), (0.55, 0.5), (0.6, 0.5), (0.7, 0.5), (0.8, 0.5), (0.9, 0.5)], [(a / 99., 1.) for a in xrange(100)], [(a / 99., 0.75) for a in xrange(100)]], "sender2": [[(0.3, 0.75)], [(0.02, 1.0), (0.04, 1.0), (0.06, 1.0), (0.08, 1.0), (0.1, 1.0), (0.12, 1.0), (0.14, 1.0), (0.16, 1.0), (0.18, 1.0), (0.2, 1.0), (0.22, 1.0), (0.24, 1.0), (0.26, 1.0), (0.28, 1.0), (0.3, 1.0), (0.325, 1.0), (0.35, 1.0), (0.375, 1.0), (0.4, 1.0), (0.45, 1.0), (0.5, 1.0), (0.55, 1.0), (0.6, 1.0), (0.7, 1.0), (0.8, 1.0), (0.9, 1.0)], [(0.02, 0.75), (0.04, 0.75), (0.06, 0.75), (0.08, 0.75), (0.1, 0.75), (0.12, 0.75), (0.14, 0.75), (0.16, 0.75), (0.18, 0.75), (0.2, 0.75), (0.22, 0.75), (0.24, 0.75), (0.26, 0.75), (0.28, 0.75), (0.3, 0.75), (0.325, 0.75), (0.35, 0.75), (0.375, 0.75), (0.4, 0.75), (0.45, 0.75), (0.5, 0.75), (0.55, 0.75), (0.6, 0.75), (0.7, 0.75), (0.8, 0.75), (0.9, 0.75)], [(0.02, 0.5), (0.04, 0.5), (0.06, 0.5), (0.08, 0.5), (0.1, 0.5), (0.12, 0.5), (0.14, 0.5), (0.16, 0.5), (0.18, 0.5), (0.2, 0.5), (0.22, 0.5), (0.24, 0.5), (0.26, 0.5), (0.28, 0.5), (0.3, 0.5), (0.325, 0.5), (0.35, 0.5), (0.375, 0.5), (0.4, 0.5), (0.45, 0.5), (0.5, 0.5), (0.55, 0.5), (0.6, 0.5), (0.7, 0.5), (0.8, 0.5), (0.9, 0.5)], [(x / 100., 1.) for x in xrange(1, 21)], [(a / 99., 1.) for a in xrange(100)], [(a / 99., 0.75) for a in xrange(100)]], "rat": [[0.5], [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5], [0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.325, 0.35, 0.375, 0.4, 0.45, 0.5, 0.55, 0.6, 0.7, 0.8, 0.9], [x / 50. for x in xrange(1, 30)] + [x / 40. for x in xrange(24, 40)], [x / 100. for x in xrange(1, 21)]], "rat2": [[0.5], [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5], [0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.325, 0.35, 0.375, 0.4, 0.45, 0.5, 0.55, 0.6, 0.7, 0.8, 0.9], [x / 50. for x in xrange(1, 30)] + [x / 40. for x in xrange(24, 40)]], "filters": [[(0.3, 1, (5, 75, 75))], [(x / 10., 1, (5, 75, 75)) for x in xrange(1, 10)], [(x / 20., 1, (5, 75, 75)) for x in xrange(1, 10)]], "derest": [[0.5], [(x / 10.) for x in xrange(1, 10)], [(x / 30.) for x in xrange(1, 20)]] }
56.419753
79
0.332166
986
4,570
1.539554
0.076065
0.088274
0.12253
0.079051
0.848485
0.839921
0.820158
0.808959
0.808959
0.808959
0
0.393845
0.367177
4,570
80
80
57.125
0.131051
0.043326
0
0.416667
0
0
0.007591
0
0
0
0
0
0
1
0
false
0
0
0
0
0
0
0
1
null
0
0
0
1
1
1
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
9
1bda2780957fe0c5300e9a6fe582fcb79fcf8884
5,190
py
Python
api_connect/sampleClient.py
marctuscher/cv_pipeline
b641423e72ea292139a5e35a411e30c1e21c7070
[ "MIT" ]
1
2021-03-28T17:46:45.000Z
2021-03-28T17:46:45.000Z
api_connect/sampleClient.py
jayef0/cv_pipeline
dc3b79062174f583a3a90ac8deea918c498c0dd5
[ "MIT" ]
null
null
null
api_connect/sampleClient.py
jayef0/cv_pipeline
dc3b79062174f583a3a90ac8deea918c498c0dd5
[ "MIT" ]
null
null
null
import requests import json import numpy as np import sys import cv2 import base64 def predictGQCNN_pj(img, d, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False, segmask=None): url = host + '/gqcnnpj' headers = {'content-type': 'application/json'} if encoded: _ ,img_dec = cv2.imencode('.png', img) else: img_dec = memoryview(img) d_dec = memoryview(d) if segmask is not None: s_dec = memoryview(segmask.astype(np.uint8)) req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), 'segmask': base64.b64encode(s_dec).decode("utf-8") ,"encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} else: req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), "encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) return response.json() def predictFCGQCNN_pj(img, d, segmask, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False): url = host + '/fcgqcnnpj' headers = {'content-type': 'application/json'} if encoded: _ ,img_dec = cv2.imencode('.png', img) else: img_dec = memoryview(img) d_dec = memoryview(d) s_dec = memoryview(segmask.astype(np.uint8)) req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), 'segmask': base64.b64encode(s_dec).decode("utf-8") ,"encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) return response.json() def predictGQCNN_suction(img, d, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False ,segmask=None): url = host + '/gqcnnsuction' headers = {'content-type': 'application/json'} if encoded: _ ,img_dec = cv2.imencode('.png', img) else: img_dec = memoryview(img) d_dec = memoryview(d) if segmask is not None: s_dec = memoryview(segmask.astype(np.uint8)) req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), 'segmask': base64.b64encode(s_dec).decode("utf-8") ,"encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} else: req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), "encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) return response.json() def predictFCGQCNN_suction(img, d, segmask, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False): url = host + '/fcgqcnnsuction' headers = {'content-type': 'application/json'} if encoded: _ ,img_dec = cv2.imencode('.png', img) else: img_dec = memoryview(img) d_dec = memoryview(d) s_dec = memoryview(segmask.astype(np.uint8)) req_dict = {'rgb':base64.b64encode(img_dec).decode("utf-8"), 'd': base64.b64encode(d_dec).decode("utf-8"), 'segmask': base64.b64encode(s_dec).decode("utf-8") ,"encoded": encoded, "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) return response.json() def predictMask(d, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False): #img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) url = host + '/mask' headers = {'content-type': 'application/json'} d_dec = memoryview(d.astype(np.float32)) req_dict = {'d': base64.b64encode(d_dec).decode("utf-8"), "intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) res_json = response.json() for key in res_json.keys(): if isinstance(res_json[key], list): res_json[key] = np.array(res_json[key], dtype=np.float32) return res_json def predictRgb(img, fx, fy, cx, cy, host='http://127.0.0.1:5000', width=640, height=480, encoded=False): #img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) url = host + '/maskRgb' headers = {'content-type': 'application/json'} if encoded: _ ,img_dec = cv2.imencode('.png', img) else: img_dec = memoryview(img) req_dict = {'rgb': base64.b64encode(img_dec), "encoded": encoded,"intr": {"fx": fx, "fy": fy, "cx": cx, "cy": cy, "height": height, "width": width,}} response = requests.post(url, json=req_dict, headers=headers) res_json = response.json() for key in res_json.keys(): if isinstance(res_json[key], list): res_json[key] = np.array(res_json[key], dtype=np.float32) if key == "masks": res_json[key] = np.transpose(res_json[key], axes=[2, 0, 1]) return res_json
51.386139
271
0.627746
754
5,190
4.220159
0.114058
0.084852
0.064111
0.069453
0.904148
0.893778
0.893778
0.884035
0.874607
0.874607
0
0.049556
0.175723
5,190
100
272
51.9
0.69425
0.016185
0
0.735632
0
0
0.147393
0
0
0
0
0
0
1
0.068966
false
0
0.068966
0
0.206897
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
8467d9f2ad09d42f2838405e8e5f8b30332f23e8
3,882
py
Python
tests/test_build_ga_flattener_config.py
adswerve/google_analytics_flattener_ga4
c734ea6f18692a62b85803c45f9f6bc2fcaa7839
[ "BSD-3-Clause" ]
10
2021-10-12T07:35:24.000Z
2022-03-15T14:26:15.000Z
tests/test_build_ga_flattener_config.py
adswerve/google_analytics_flattener_ga4
c734ea6f18692a62b85803c45f9f6bc2fcaa7839
[ "BSD-3-Clause" ]
2
2021-10-13T22:04:33.000Z
2022-03-04T19:57:29.000Z
tests/test_build_ga_flattener_config.py
adswerve/google_analytics_flattener_ga4
c734ea6f18692a62b85803c45f9f6bc2fcaa7839
[ "BSD-3-Clause" ]
2
2021-07-30T04:15:52.000Z
2022-02-03T19:35:08.000Z
from tests.test_base import BaseUnitTest from cfconfigbuilder.main import FlattenerDatasetConfig from cfconfigbuilder.main import FlattenerDatasetConfigStorage from cfconfigbuilderps.main import FlattenerDatasetConfig as FlattenerDatasetConfigPS from cfconfigbuilderps.main import FlattenerDatasetConfigStorage as FlattenerDatasetConfigStoragePS # TODO: question: what's the diff between these two unit tests? class TestCFBuildFlattenerGaDatasetConfig(BaseUnitTest): def test_build_flattener_ga_dataset_config(self): # generate config and upload it to GCS config = FlattenerDatasetConfig() store = FlattenerDatasetConfigStorage() json_config = config.get_ga_datasets() json_config = config.add_intraday_info_into_config(json_config) store.upload_config(config=json_config) # check self.assertIsInstance(json_config, dict) if json_config.keys(): for key, value in json_config.items(): self.assertIsInstance(key, str) self.assertIsInstance(value, dict) self.assertEqual(json_config[key]['intraday_schedule'], { "frequency": None, "units": "hours" }) self.assertTrue(True) def test_build_flattener_ga_dataset_config_add_intraday_schedule_minutes(self): # generate config and upload it to GCS config = FlattenerDatasetConfig() store = FlattenerDatasetConfigStorage() json_config = config.get_ga_datasets() json_config = config.add_intraday_info_into_config(json_config, intraday_schedule_frequency=30, intraday_schedule_units="minutes") store.upload_config(config=json_config) # check self.assertIsInstance(json_config, dict) if json_config.keys(): for key, value in json_config.items(): self.assertIsInstance(key, str) self.assertIsInstance(value, dict) # default intraday schedule self.assertEqual(json_config[key]['intraday_schedule'], { "frequency": 30, "units": "minutes" }) self.assertTrue(True) def test_build_flattener_ga_dataset_config_add_intraday_schedule_hours(self): # generate config and upload it to GCS config = FlattenerDatasetConfig() store = FlattenerDatasetConfigStorage() json_config = config.get_ga_datasets() json_config = config.add_intraday_info_into_config(json_config, intraday_schedule_frequency=1, intraday_schedule_units="hours") store.upload_config(config=json_config) # check self.assertIsInstance(json_config, dict) if json_config.keys(): for key, value in json_config.items(): self.assertIsInstance(key, str) self.assertIsInstance(value, dict) self.assertEqual(json_config[key]['intraday_schedule'], { "frequency": 1, "units": "hours" }) self.assertTrue(True) def test_build_flattener_ga_dataset_config_ps(self): # generate config and upload it to GCS config = FlattenerDatasetConfigPS() store = FlattenerDatasetConfigStoragePS() json_config = config.get_ga_datasets() json_config = config.add_intraday_info_into_config(json_config) store.upload_config(config=json_config) # check self.assertIsInstance(json_config, dict) if json_config.keys(): for key, value in json_config.items(): self.assertIsInstance(key, str) self.assertIsInstance(value, dict) self.assertTrue(True)
40.4375
103
0.645028
381
3,882
6.309711
0.186352
0.128952
0.053245
0.034942
0.749168
0.749168
0.749168
0.734193
0.712146
0.695507
0
0.002158
0.283617
3,882
95
104
40.863158
0.86228
0.066718
0
0.705882
0
0
0.033776
0
0
0
0
0.010526
0.279412
1
0.058824
false
0
0.073529
0
0.147059
0
0
0
0
null
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
7
8477e87a14dd4e5bb1c0e4a4b0850e23fc4bf833
138,570
py
Python
pkgs/sdk-pkg/src/genie/libs/sdk/triggers/addremove/bgp/nxos/addremove.py
kecorbin/genielibs
5d3951b8911013691822e73e9c3d0f557ca10f43
[ "Apache-2.0" ]
null
null
null
pkgs/sdk-pkg/src/genie/libs/sdk/triggers/addremove/bgp/nxos/addremove.py
kecorbin/genielibs
5d3951b8911013691822e73e9c3d0f557ca10f43
[ "Apache-2.0" ]
null
null
null
pkgs/sdk-pkg/src/genie/libs/sdk/triggers/addremove/bgp/nxos/addremove.py
kecorbin/genielibs
5d3951b8911013691822e73e9c3d0f557ca10f43
[ "Apache-2.0" ]
null
null
null
'''NXOS Implementation for BGP addremove triggers''' # python import re import logging from functools import partial log = logging.getLogger(__name__) # Genie Libs from genie.libs.sdk.libs.utils.mapping import Mapping from genie.libs.sdk.libs.utils.triggeractions import Configure from genie.libs.sdk.libs.utils.mapping import Mapping, Different from genie.libs.sdk.triggers.addremove.addremove import TriggerAddRemove # ATS from ats import aetest from ats.utils.objects import NotExists ,Not from ipaddress import IPv4Address # ipaddress from ipaddress import IPv4Address, IPv6Address # Which keys to exclude for BGP Ops comparison bgp_exclude = ['maker', 'bgp_session_transport', 'route_refresh', 'bgp_negotiated_capabilities', 'notifications', 'capability', 'keepalives', 'total', 'total_bytes', 'up_time', 'last_reset', 'bgp_negotiated_keepalive_timers', 'updates', 'opens', 'bgp_table_version', 'holdtime', 'keepalive_interval', 'distance_internal_as', 'distance_extern_as', 'totals', 'reset_reason', 'holdtime', 'keepalive_interval'] # Which key to exclude for Interface Ops comparison interface_exclude = ['maker', 'last_change','in_rate','in_rate_pkts', 'out_rate', 'out_rate_pkts', 'in_octets', 'in_pkts', 'in_unicast_pkts', 'out_octets', 'out_pkts', 'out_unicast_pkts', 'out_multicast_pkts', 'in_multicast_pkts', 'last_clear', 'in_broadcast_pkts', 'out_broadcast_pkts', 'bandwidth', 'load_interval', 'port_speed', 'in_crc_errors', 'in_errors', 'in_discards', '(Tunnel.*)', 'accounting'] bgp_exclude_keepalive = ['maker', 'bgp_session_transport', 'route_refresh', 'bgp_negotiated_capabilities', 'notifications', 'last_reset', 'keepalives', 'total', 'total_bytes', 'up_time', 'bgp_negotiated_keepalive_timers', 'updates', 'opens', 'bgp_table_version', 'holdtime', 'keepalive_interval', 'route_reflector_client', 'capability', 'distance_internal_as', 'bgp_neighbor_counters', 'memory_usage', 'total_entries', 'routing_table_version', 'total_memory', 'path', 'prefixes', 'cluster_id'] ospf_exclude = ['maker', 'age', 'checksum', 'seq_num', 'hello_timer', 'dead_timer'] class TriggerAddRemoveBgpNeighborUpdateSource(TriggerAddRemove): """Add update source configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add update source configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add update source configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added update source config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('update_source')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'ops.interface.interface.Interface':{ 'requirements':[\ ['info', '(?P<intf_name>(Loopback|loopback)[0-9]+)', 'vrf', '(?P<vrf>.*)'], ['info', '(?P<intf_name>(Loopback|loopback)[0-9]+)', 'enabled', True], ['info', '(?P<intf_name>(Loopback|loopback)[0-9]+)', 'oper_status', 'up']], 'exclude': interface_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr','(?P<neighbor>.*)', 'nbr_update_source', '(?P<intf_name>(Loopback|loopback)[0-9]+)']], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'update_source', '(?P<intf_name>(Loopback|loopback)[0-9]+)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1, 'intf_name':1}) class TriggerAddRemoveBgpNeighborDescription(TriggerAddRemove): """Add description configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add description configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add description configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added description config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('description')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr','(?P<neighbor>.*)', 'nbr_description', 'test']], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'description', 'test']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborDisableConnectedCheck(TriggerAddRemove): """Add connected-check configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add connected-check configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add connected-check configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added connected-check config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('disable_connected_check')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'ebgp_multihop', True], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr','(?P<neighbor>.*)', 'nbr_disable_connected_check', True]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'disable_connected_check', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborBfd(TriggerAddRemove): """Add bfd configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add bfd configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add bfd configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added bfd config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('fall_over_bfd')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'nbr_fall_over_bfd', True]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'fall_over_bfd', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborMaximumPrefix(TriggerAddRemove): """Add maximum-prefix configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add maximum-prefix configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add maximum-prefix configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added maximum-prefix config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', NotExists('maximum_prefix_max_prefix_no')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>.*)', 'nbr_af_maximum_prefix_max_prefix_no', 163]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', 'maximum_prefix_max_prefix_no', 163], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborNextHopSelf(TriggerAddRemove): """Add next-hop self configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add next-hop self configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add next-hop self configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added next-hop self config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>^(?!l2vpn|vpnv|.*mvpn).*)', '(?P<af>.*)'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', NotExists('next_hop_self')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>.*)', 'nbr_af_next_hop_self', True]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', 'next_hop_self', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1, 'address_family':1}) class TriggerAddRemoveBgpNeighborDefaultOriginate(TriggerAddRemove): """Add default originate configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add default originate configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add default originate configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added default originate config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>^(?!l2vpn|vpnv|.*mvpn).*)', '(?P<af>.*)'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', NotExists('default_originate')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>.*)', 'nbr_af_default_originate', True]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', 'default_originate', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1, 'address_family':1}) class TriggerAddRemoveBgpNeighborPassword(TriggerAddRemove): """Add password configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add password configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add password configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added password config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ @aetest.test def add_configuration(self, uut, abstract, steps): super().add_configuration(uut, abstract, steps) # Flap neighbor for config change to take effect cmd = "router bgp (?P<bgp_id>.*)\n"\ " vrf (?P<vrf>.*)\n"\ " neighbor (?P<neighbor>.*)\n"\ " shutdown\n"\ " no shutdown" x = re.findall(r'\S+|\n', cmd) req = self.mapping._path_population([x], uut) req_str = [] for item in req[0]: req_str.append(str(item)) # combine command cmd = ' '.join(req_str) cmd = cmd.replace('vrf default \n', '') try: uut.configure(cmd) except Exception as e: self.failed("Unable to configure: '{c}'".format(c=cmd), from_exception=e) mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('password_text')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'nbr_password_text', 'asgrocks']], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'idle'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'password_text', 'set (disabled)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborTransportConnectionModePassive(TriggerAddRemove): """Add transport connection mode configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add transport connection mode configuration under a BGP neighor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add transport connection mode configuration under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly added transport connection mode config under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'bgp_session_transport', 'connection', NotExists('mode')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'nbr_transport_connection_mode', 'passive']], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'bgp_session_transport', 'connection', 'mode', 'passive']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1}) class TriggerAddRemoveBgpNeighborRoutemap(TriggerAddRemove): """Add route-map configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add route-map configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add route-map in and route-map out configuration under a BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly route-maps under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={\ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', NotExists('route_map_name_in')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', NotExists('route_map_name_out')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}, 'ops.route_policy.route_policy.RoutePolicy': { 'requirements': [ \ ['info', '(?P<policy>.*)', 'statements', '(?P<statements>.*)']], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude} }, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr','(?P<af>.*)','nbr_af_route_map_name_in','(?P<policy>.*)'], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<af>.*)', 'nbr_af_route_map_name_out', '(?P<policy>.*)'] ], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family','(?P<af>.*)','route_map_name_in','(?P<policy>.*)'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', 'route_map_name_out', '(?P<policy>.*)'] ], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1,'statements':1,'policy':1 }) class TriggerAddRemoveBgpNeighborCapabilitySuppress4ByteAs(TriggerAddRemove): """Add capability suppress 4-byte-as configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add capability suppress 4-byte-as under a BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add capability suppress 4-byte-as under a BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly capability suppress 4-byte-as under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('suppress_four_byte_as_capability')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'nbr_suppress_four_byte_as_capability', True]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'suppress_four_byte_as_capability', True]], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1}) class TriggerAddRemoveBgpNeighborSendCommunity(TriggerAddRemove): """Add send-community configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add send-community under a BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add send-community under a BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly send-community under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)',NotExists('send_community')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<af>.*)','nbr_af_send_community', 'standard']], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', 'send_community', 'standard']], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1, 'af':1}) class TriggerAddRemoveBgpNeighborSendCommunityExtended(TriggerAddRemove): """Add send-community extended configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add send-community extended under a BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add send-community extended under a BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly send-community extended under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)',NotExists('send_community')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<af>.*)','nbr_af_send_community', 'extended']], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', 'send_community', 'extended']], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1 , 'af':1}) class TriggerAddRemoveBgpNeighborSoftReconfiguration(TriggerAddRemove): """Add soft-reconfiguration inbound under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add soft-reconfiguration inbound under BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add soft-reconfiguration inbound under BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly soft-reconfiguration inbound under BGP neighbor is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', NotExists('soft_configuration')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<af>.*)', 'nbr_af_soft_reconfiguration', True]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<af>.*)', 'soft_configuration', True]], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1 ,'af':1}) class TriggerAddRemoveBgpNeighborRemovePrivateAs(TriggerAddRemove): """Add remove-private-as configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add remove-private-as configuration under a BGP neighbor and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add remove-private-as configuration under a BGP neighbor of BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly remove-private-as under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', NotExists('remove_private_as')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'remote_as',Not(100)], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'nbr_remove_private_as', True]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'remove_private_as', True]], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1}) class TriggerAddRemoveBgpAggregateAddressIpv4(TriggerAddRemove): """Add aggregate-address configuration for ipv4 under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add aggregate-address configuration for ipv4 under a BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add aggregate-address configuration for ipv4 under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly aggregate-address under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family','(?P<af>^(ipv4)[\w ]+)', NotExists('aggregate_address_ipv4_address')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family', '(?P<af>^(ipv4)[\w ]+)', NotExists('aggregate_address_ipv4_mask')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<af>^(ipv4)[\w ]+)', 'af_aggregate_address_ipv4_address', '83.0.0.0'], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<af>^(ipv4)[\w ]+)', 'af_aggregate_address_ipv4_mask', '16'] ], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [ \ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family', '(?P<af>^(ipv4)[\w ]+)', 'aggregate_address_ipv4_address', '83.0.0.0'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family', '(?P<af>^(ipv4)[\w ]+)', 'aggregate_address_ipv4_mask', '16'], ], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1 ,'af':1}) class TriggerAddRemoveBgpAggregateAddressIpv6(TriggerAddRemove): """Add aggregate-address configuration for ipv6 under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add aggregate-address configuration for ipv6 under a BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add aggregate-address configuration for ipv6 under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly aggregate-address under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={ \ 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family', '(?P<af>(ipv6 u).*)', NotExists('v6_aggregate_address_ipv6_address')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<af>.*)', 'af_v6_aggregate_address_ipv6_address', '2000::/8']], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'address_family', '(?P<af>.*)', 'v6_aggregate_address_ipv6_address', '2000::/8']], 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude}}, num_values={'instance': 1, 'vrf': 1, 'neighbor': 1, 'af': 1}) class TriggerAddRemoveBgpKeepaliveHoldtime(TriggerAddRemove): """Add keepalive interval and holdtime configuration under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add keepalive interval and holdtime under BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add keepalive interval and holdtime under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly keepalive interval and holdtime under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'conf.bgp.Bgp': { 'requirements': [\ [['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', NotExists('keepalive_interval')]], [['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', NotExists('holdtime')]]], 'exclude': bgp_exclude_keepalive}, 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude_keepalive}}, config_info={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'keepalive_interval', 10], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'holdtime', 30]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', 'keepalive_interval',10], ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', 'holdtime', 30]], 'exclude': bgp_exclude_keepalive}}, num_values={'device': 1, 'bgp_id': 1, 'vrf': 1, 'instance': 1, 'neighbor':1}) class TriggerAddRemoveBgpNetworkIPv4(TriggerAddRemove): """Add network ip configuration under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add network ip under a BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add network ip configuration under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly network ip under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<af>^(ipv4)[\w ]+)', NotExists('af_network_number')]], 'exclude': bgp_exclude_keepalive}, 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude_keepalive}}, config_info={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr','(?P<af>.*)', 'af_network_number', IPv4Address('34.34.34.0')], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr','(?P<af>.*)', 'af_network_mask', 24]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<af>.*)', 'af_network_number', '34.34.34.0'], ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<af>.*)', 'af_network_mask', 24]], 'exclude': bgp_exclude_keepalive}}, num_values={'device': 1, 'bgp_id': 1, 'vrf': 1, 'instance': 1, 'af': 1}) class TriggerAddRemoveBgpNetworkIPv6(TriggerAddRemove): """Add network ipv6 configuration under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add network ipv6 under a BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add network ipv6 configuration under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly network ipv6 under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<af>(AddressFamily.)(ipv6|ipv6[\S]+)(.*))', NotExists('af_v6_network_number')]], 'exclude': bgp_exclude_keepalive}, 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude_keepalive}}, config_info={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr','(?P<af>.*)', 'af_v6_network_number', '2000::/8']], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<af>.*)', 'af_v6_network_number', '2000::/8']], 'exclude': bgp_exclude_keepalive}}, num_values={'device': 1, 'bgp_id': 1, 'vrf': 1, 'instance': 1, 'af': 1}) class TriggerAddRemoveBgpMaximumPathsEbgp(TriggerAddRemove): """Add maximum ebgp paths configuration under a BGP and then restore the configuration by reapplying the whole running configuration""" __description__ = """Add maximum ebgp paths under a BGP and then restore the configuration by reapplying the whole running configuration trigger_datafile: Mandatory Arguments: timeout: max_time (`int`): Maximum wait time for the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 method (`str`): Method to recover the device configuration. Supported methods: 'checkpoint': Rollback the configuration using checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional Arguments: tgn_timeout (`int`): Maximum wait time for all traffic streams to be restored to the reference rate in seconds. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed in seconds. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger in seconds. Default: 180 interval (`int`): Wait time between iteration when looping is needed in seconds. Default: 15 Steps: 1. Learn BGP Ops configured on device. SKIP the trigger if there is no BGP configured on the device. 2. Save the current device configurations using "method" specified. 3. Add maximum ebgp paths configuration under BGP pid learned in step 1 using Genie BGP Conf. 4. Verify the newly maximum ebgp paths under BGP is reflected in device configuration. 5. Restore the device configuration to the original configuration saved in step 2. 6. Learn BGP Ops again and verify it is the same as the Ops in step 1. """ mapping = Mapping(\ requirements={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)','_address_family_attr', '(?P<af>(AddressFamily.)(.*))', NotExists('af_maximum_paths_ebgp')]], 'exclude': bgp_exclude_keepalive}, 'ops.bgp.bgp.Bgp': { 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs': {'attributes': ['info']}, 'exclude': bgp_exclude_keepalive}}, config_info={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)','address_family_attr','(?P<af>.*)', 'af_maximum_paths_ebgp', 8]], 'verify_conf': False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'conf.bgp.Bgp': { 'requirements': [\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)','_address_family_attr', '(?P<af>.*)', 'af_maximum_paths_ebgp', 8]], 'exclude': bgp_exclude_keepalive}}, num_values={'device': 1, 'bgp_id': 1, 'vrf': 1, 'instance': 1, 'af': 1}) class TriggerAddRemoveBgpNeighborAsOverride(TriggerAddRemove): """Apply the "as-override" to the dynamically learned BGP neighbor(s) which does not have "as-override" enabled, and remove the""" __description__ = """Apply the "as-override" to the dynamically learned BGP neighbor(s) which does not have "as-override" enabled, and remove the added "as-override" configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP neighbor(s) if it does not have "as-override" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "as-override" to learned BGP neighbor(s) from step 1 with BGP Conf object 4. Verify the BGP neighbor(s) from step 3 has "as-override" configured 5. Remove the "as-override" configurations from the learned BGP neighbor(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(requirements={'ops.bgp.bgp.Bgp':{ 'requirements':[['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', NotExists('as_override')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>^(?!default).*)', 'neighbor', '(?P<neighbor>.*)', 'remote_as', Different('(?P<bgp_id>.*)')]], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>^(?!vpnv).*)', 'nbr_af_as_override', True] ], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={'ops.bgp.bgp.Bgp':{ 'requirements': [['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', 'as_override', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'vrf': 1, 'instance': 1, 'neighbor': 1, 'address_family': 1}) class TriggerAddRemoveBgpNeighborRouteReflectorClient(TriggerAddRemove): """Apply the "route-reflector-client" to the dynamically learned BGP neighbor(s) which does not have "route-reflector-client" enabled, and remove the""" __description__ = """Apply the "route-reflector-client" to the dynamically learned BGP neighbor(s) which does not have "route-reflector-client" enabled, and remove the added "route-reflector-client" configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP neighbor(s) if it does not have "route-reflector-client" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "route-reflector-client" to learned BGP neighbor(s) from step 1 with BGP Conf object 4. Verify the BGP neighbor(s) from step 3 has "route-reflector-client" configured 5. Remove the "route-reflector-client" configurations from the learned BGP neighbor(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(requirements={'ops.bgp.bgp.Bgp':{ 'requirements':[['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', NotExists('route_reflector_client')], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'remote_as', '(?P<bgp_id>.*)'], ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)'], ['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'session_state', 'established']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>.*)', 'nbr_af_route_reflector_client', True] ], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={'ops.bgp.bgp.Bgp':{ 'requirements': [['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>.*)', 'route_reflector_client', True]], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, num_values={'vrf': 1, 'instance': 1, 'neighbor': 1, 'address_family': 1, 'bgp_id': 1}) class TriggerAddRemoveBgpRedistributeConnected(TriggerAddRemove): """Apply the "redistribute direct " to the dynamically learned BGP vrf(s) which does not have "redistribute direct " enabled, and remove the added "redistribute direct " configurations.""" __description__ = """Apply the "redistribute direct " to the dynamically learned BGP vrf(s) which does not have "redistribute direct " enabled, and remove the added "redistribute direct " configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP vrf(s) if it does not have "redistribute direct" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "redistribute direct" to learned BGP vrf(s) from step 1 with BGP Conf object 4. Verify the BGP vrf(s) from step 3 has "redistribute direct" configured 5. Remove the "redistribute direct" configurations from the learned BGP vrf(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(requirements={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>^(?!vpnv).*)', NotExists('af_redist_connected')]], 'exclude': bgp_exclude}, 'ops.bgp.bgp.Bgp':{ 'requirements':[['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'ops.route_policy.route_policy.RoutePolicy':{ 'requirements':[['info', '(?P<route_policy>.*)', '(?P<route_policy_info>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>^(?!vpnv).*)', 'af_redist_connected', True], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>^(?!vpnv).*)', 'af_redist_connected_route_policy', '(?P<route_policy>.*)'] ], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={'ops.bgp.bgp.Bgp':{ 'requirements': [['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>.*)', 'af_redist_connected', True], ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>.*)', 'af_redist_connected_route_policy', '(?P<route_policy>.*)']], 'exclude': bgp_exclude},}, num_values={'vrf': 1, 'instance': 'all', 'address_family': 'all', 'route_policy': 1}) class TriggerAddRemoveBgpRedistributeStatic(TriggerAddRemove): """Apply the "redistribute static" to the dynamically learned BGP vrf(s) which does not have "redistribute static" enabled, and remove the added "redistribute static" configurations.""" __description__ = """Apply the "redistribute static" to the dynamically learned BGP vrf(s) which does not have "redistribute static" enabled, and remove the added "redistribute static" configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP vrf(s) if it does not have "redistribute static" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "redistribute static" to learned BGP vrf(s) from step 1 with BGP Conf object 4. Verify the BGP vrf(s) from step 3 has "redistribute static" configured 5. Remove the "redistribute static" configurations from the learned BGP vrf(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(requirements={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>^(?!vpnv).*)', NotExists('af_redist_static')]], 'exclude': bgp_exclude}, 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'ops.route_policy.route_policy.RoutePolicy':{ 'requirements':[['info', '(?P<route_policy>.*)', '(?P<route_policy_info>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}}, config_info={'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>^(?!vpnv).*)', 'af_redist_static', True], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>^(?!vpnv).*)', 'af_redist_static_route_policy', '(?P<route_policy>.*)'] ], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={'ops.bgp.bgp.Bgp':{ 'requirements': [['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'conf.bgp.Bgp':{ 'requirements':[['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>.*)', 'af_redist_static', True], ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>.*)', 'af_redist_static_route_policy', '(?P<route_policy>.*)']], 'exclude': bgp_exclude},}, num_values={'vrf': 1, 'instance': 'all', 'address_family': 'all', 'route_policy': 1}) class TriggerAddRemoveBgpRedistributeOspf(TriggerAddRemove): """Apply the "redistribute ospf opsf_pid" to the dynamically learned BGP vrf(s) which does not have "redistribute ospf opsf_pid" enabled, and remove the added "redistribute ospf opsf_pid" configurations.""" __description__ = """Apply the "redistribute ospf opsf_pid" to the dynamically learned BGP vrf(s) which does not have "redistribute ospf opsf_pid" enabled, and remove the added "redistribute ospf opsf_pid" configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP vrf(s) if it does not have "redistribute ospf opsf_pid" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "redistribute ospf opsf_pid" to learned BGP vrf(s) from step 1 with BGP Conf object 4. Verify the BGP vrf(s) from step 3 has "redistribute ospf opsf_pid" configured 5. Remove the "redistribute ospf opsf_pid" configurations from the learned BGP vrf(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(\ requirements={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>(ipv4 unicast))', NotExists('af_redist_ospf')]], 'exclude': bgp_exclude}, 'ops.bgp.bgp.Bgp':{ 'requirements':[\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'all_keys':True, 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'ops.route_policy.route_policy.RoutePolicy':{ 'requirements':[\ ['info', '(?P<route_policy>.*)', '(?P<route_policy_info>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'ops.ospf.ospf.Ospf':{ 'requirements':[\ ['info', 'vrf', '(?P<vrf_ospf>.*)', 'address_family', '(?P<address_family_ospf>(ipv4 unicast))', 'instance', '(?P<ospf_instance>.*)', '(?P<ospf_info>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': ospf_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>(ipv4 unicast))', 'af_redist_ospf', '(?P<ospf_instance>.*)'], ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'address_family_attr', '(?P<address_family>(ipv4 unicast))', 'af_redist_ospf_route_policy', '(?P<route_policy>.*)']], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={\ 'ops.bgp.bgp.Bgp':{ 'requirements': [\ ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': bgp_exclude}, 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>(ipv4 unicast))', 'af_redist_ospf', '(?P<ospf_instance>.*)'], ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_address_family_attr', '(?P<address_family>(ipv4 unicast))', 'af_redist_ospf_route_policy', '(?P<route_policy>.*)']], 'exclude': bgp_exclude}, 'ops.ospf.ospf.Ospf':{ 'requirements':[\ ['info', 'vrf', '(?P<vrf_ospf>.*)', 'address_family', '(?P<address_family_ospf>(ipv4 unicast))', 'instance', '(?P<ospf_instance>.*)', '(?P<ospf_info>.*)']], 'kwargs':{'attributes':['info']}, 'exclude': ospf_exclude}}, num_values={'vrf': 1, 'instance': 1, 'ospf_instance': 1, 'address_family': 1, 'route_policy': 1}) class TriggerAddRemoveBgpAfL2vpnEvpnRewriteEvpnRtAsn(TriggerAddRemove): """Apply the "rewrite-evpn-rt-asn" to the dynamically learned BGP vrf(s) which does not have "rewrite-evpn-rt-asn" enabled, and remove the added "rewrite-evpn-rt-asn" configurations.""" __description__ = """Apply the "rewrite-evpn-rt-asn" to the dynamically learned BGP vrf(s) which does not have "rewrite-evpn-rt-asn" enabled, and remove the added "rewrite-evpn-rt-asn" configurations. trigger_datafile: Mandatory: timeout: max_time (`int`): Maximum wait time for the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 method (`str`): Method to recover the device configuration, Support methods: 'checkpoint': Rollback the configuration by checkpoint (nxos), archive file (iosxe), load the saved running-config file on disk (iosxr) Optional: tgn_timeout (`int`): Maximum wait time for all traffic threads to be restored to the reference rate, in second. Default: 60 tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed, in second. Default: 10 timeout_recovery: Buffer recovery timeout make sure devices are recovered at the end of the trigger execution. Used when previous timeouts have been exhausted. max_time (`int`): Maximum wait time for the last step of the trigger, in second. Default: 180 interval (`int`): Wait time between iterations when looping is needed, in second. Default: 15 steps: 1. Learn BGP Ops object and store the BGP vrf(s) if it does not have "rewrite-evpn-rt-asn" enabled, otherwise, SKIP the trigger. 2. Save the current device configurations through "method" which user uses 3. Add the configuration of the "rewrite-evpn-rt-asn" to learned BGP vrf(s) from step 1 with BGP Conf object 4. Verify the BGP vrf(s) from step 3 has "rewrite-evpn-rt-asn" configured 5. Remove the "rewrite-evpn-rt-asn" configurations from the learned BGP vrf(s) from step 1 6. Recover the device configurations to the one in step 2 7. Learn BGP Ops again and verify it is the same as the Ops in step 1 """ mapping = Mapping(\ requirements={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_neighbor_attr', '(?P<neighbor>.*)', '_address_family_attr', '(?P<af>.*)', NotExists('nbr_af_rewrite_evpn_rt_asn')]], 'exclude': bgp_exclude}, 'ops.bgp.bgp.Bgp':{ 'requirements':[\ [['info', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)', 'address_family', '(?P<address_family>^l2vpn +evpn$)', 'session_state', 'established']], [['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']], [['info', 'instance', '(?P<instance>.*)', 'vrf',\ '(?P<vrf>.*)', 'neighbor','(?P<neighbor>.*)', 'remote_as', Different('(?P<bgp_id>.*)')]]], 'all_keys': True, 'kwargs':{'attributes':['info[instance][(.*)][bgp_id]', 'info[list_of_vrfs]', 'info[instance][(.*)][vrf][(.*)][neighbor]' '[(.*)][address_family][(.*)][session_state]', 'info[instance][(.*)][vrf][(.*)][neighbor]' '[(.*)][remote_as]']}, 'exclude': bgp_exclude}}, config_info={\ 'conf.bgp.Bgp':{ 'requirements':[\ ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)', 'neighbor_attr', '(?P<neighbor>.*)', 'address_family_attr', '(?P<address_family>.*)',\ 'nbr_af_rewrite_evpn_rt_asn', True]], 'verify_conf':False, 'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}}, verify_ops={ \ 'conf.bgp.Bgp': { 'requirements': [ \ ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)', '_neighbor_attr', '(?P<neighbor>.*)', '_address_family_attr', '(?P<af>.*)', 'nbr_af_rewrite_evpn_rt_asn', True]], 'exclude': bgp_exclude}}, num_values={'instance':1, 'vrf':1, 'neighbor':1 , 'address_family': 1})
60.749671
211
0.474287
12,851
138,570
5.00607
0.031048
0.020145
0.031337
0.036886
0.929974
0.923383
0.916
0.911756
0.907466
0.904621
0
0.010814
0.410731
138,570
2,280
212
60.776316
0.77705
0.029436
0
0.840059
0
0.001476
0.714346
0.025605
0
0
0
0
0
1
0.000492
false
0.004921
0.005413
0
0.045768
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
8
847df8dd6516b71d9bdbf9e25cb6384f4f489a67
2,994
py
Python
terrascript/openstack/d.py
hugovk/python-terrascript
08fe185904a70246822f5cfbdc9e64e9769ec494
[ "BSD-2-Clause" ]
507
2017-07-26T02:58:38.000Z
2022-01-21T12:35:13.000Z
terrascript/openstack/d.py
hugovk/python-terrascript
08fe185904a70246822f5cfbdc9e64e9769ec494
[ "BSD-2-Clause" ]
135
2017-07-20T12:01:59.000Z
2021-10-04T22:25:40.000Z
terrascript/openstack/d.py
hugovk/python-terrascript
08fe185904a70246822f5cfbdc9e64e9769ec494
[ "BSD-2-Clause" ]
81
2018-02-20T17:55:28.000Z
2022-01-31T07:08:40.000Z
# terrascript/openstack/d.py import terrascript class openstack_blockstorage_availability_zones_v3(terrascript.Data): pass class openstack_blockstorage_snapshot_v2(terrascript.Data): pass class openstack_blockstorage_snapshot_v3(terrascript.Data): pass class openstack_blockstorage_volume_v2(terrascript.Data): pass class openstack_blockstorage_volume_v3(terrascript.Data): pass class openstack_compute_availability_zones_v2(terrascript.Data): pass class openstack_compute_instance_v2(terrascript.Data): pass class openstack_compute_flavor_v2(terrascript.Data): pass class openstack_compute_keypair_v2(terrascript.Data): pass class openstack_containerinfra_clustertemplate_v1(terrascript.Data): pass class openstack_containerinfra_cluster_v1(terrascript.Data): pass class openstack_dns_zone_v2(terrascript.Data): pass class openstack_fw_policy_v1(terrascript.Data): pass class openstack_identity_role_v3(terrascript.Data): pass class openstack_identity_project_v3(terrascript.Data): pass class openstack_identity_user_v3(terrascript.Data): pass class openstack_identity_auth_scope_v3(terrascript.Data): pass class openstack_identity_endpoint_v3(terrascript.Data): pass class openstack_identity_service_v3(terrascript.Data): pass class openstack_identity_group_v3(terrascript.Data): pass class openstack_images_image_v2(terrascript.Data): pass class openstack_images_image_ids_v2(terrascript.Data): pass class openstack_networking_addressscope_v2(terrascript.Data): pass class openstack_networking_network_v2(terrascript.Data): pass class openstack_networking_qos_bandwidth_limit_rule_v2(terrascript.Data): pass class openstack_networking_qos_dscp_marking_rule_v2(terrascript.Data): pass class openstack_networking_qos_minimum_bandwidth_rule_v2(terrascript.Data): pass class openstack_networking_qos_policy_v2(terrascript.Data): pass class openstack_networking_subnet_v2(terrascript.Data): pass class openstack_networking_secgroup_v2(terrascript.Data): pass class openstack_networking_subnetpool_v2(terrascript.Data): pass class openstack_networking_floatingip_v2(terrascript.Data): pass class openstack_networking_router_v2(terrascript.Data): pass class openstack_networking_port_v2(terrascript.Data): pass class openstack_networking_port_ids_v2(terrascript.Data): pass class openstack_networking_trunk_v2(terrascript.Data): pass class openstack_sharedfilesystem_availability_zones_v2(terrascript.Data): pass class openstack_sharedfilesystem_sharenetwork_v2(terrascript.Data): pass class openstack_sharedfilesystem_share_v2(terrascript.Data): pass class openstack_sharedfilesystem_snapshot_v2(terrascript.Data): pass class openstack_keymanager_secret_v1(terrascript.Data): pass class openstack_keymanager_container_v1(terrascript.Data): pass
17.508772
75
0.814963
358
2,994
6.418994
0.173184
0.255875
0.347258
0.428198
0.848129
0.848129
0.712359
0.218451
0.067885
0
0
0.01608
0.127589
2,994
170
76
17.611765
0.863706
0.008684
0
0.494118
0
0
0
0
0
0
0
0
0
1
0
true
0.494118
0.011765
0
0.505882
0
0
0
0
null
1
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
1
1
0
0
1
0
0
9
84c24fc553669171e2bf8ac39ff01200719091df
44
py
Python
NAAL-fpga_pynq/NAAL-fpga/utils/__init__.py
neurom-iot/naal
2644cd289c16fec283443f2d33c8f7173f3e455c
[ "MIT" ]
12
2019-03-15T17:21:06.000Z
2021-12-29T07:00:53.000Z
NAAL-pynq/NAAL_pynq/utils/__init__.py
neurom-iot/naal
2644cd289c16fec283443f2d33c8f7173f3e455c
[ "MIT" ]
1
2019-03-15T16:05:17.000Z
2019-09-06T04:57:04.000Z
NAAL-pynq/NAAL_pynq/utils/__init__.py
neurom-iot/naal
2644cd289c16fec283443f2d33c8f7173f3e455c
[ "MIT" ]
4
2019-03-15T17:24:56.000Z
2020-05-29T00:42:02.000Z
from . import paths from . import functions
14.666667
23
0.772727
6
44
5.666667
0.666667
0.588235
0
0
0
0
0
0
0
0
0
0
0.181818
44
2
24
22
0.944444
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
1
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
7
84e25edd8f0378c55a84c11e31f62269b7092ea8
19,201
py
Python
lims/users/tests.py
LeafLIMS/LIMS-Backend
472ccbf71f20b9ecd50508aa0f9ca80d3a3df79a
[ "MIT" ]
12
2017-03-01T10:39:36.000Z
2022-01-04T06:17:19.000Z
lims/users/tests.py
GETLIMS/LIMS-Backend
472ccbf71f20b9ecd50508aa0f9ca80d3a3df79a
[ "MIT" ]
29
2017-04-25T14:05:08.000Z
2021-06-21T14:41:53.000Z
lims/users/tests.py
GETLIMS/LIMS-Backend
472ccbf71f20b9ecd50508aa0f9ca80d3a3df79a
[ "MIT" ]
4
2017-10-11T16:22:53.000Z
2021-02-23T15:45:21.000Z
from django.contrib.auth.models import User, Group, Permission from django.test import override_settings from lims.addressbook.models import Address from lims.shared.loggedintestcase import LoggedInTestCase from django.contrib.auth.hashers import check_password from rest_framework import status class UserTestCase(LoggedInTestCase): def setUp(self): super(UserTestCase, self).setUp() # No need to define any other users as we have them from LoggedInTestCase already # Add extra details to one existing user self._joeBloggs.first_name = "Joe" self._joeBloggs.last_name = "Bloggs" self._joeBloggsAddress = Address.objects.create(institution_name="Beetroot Institute", address_1="12 Muddy Field", address_2="Long Lane", city="Norwich", postcode="NR1 1AA", country="UK", user=self._joeBloggs) self._joeBloggs.addresses.add(self._joeBloggsAddress) self._joeBloggs.save() def test_presets(self): self.assertIs(User.objects.filter(username="Joe Bloggs").exists(), True) user1 = User.objects.get(username="Joe Bloggs") self.assertEqual(user1.email, "joe@tgac.com") self.assertEqual(user1.first_name, "Joe") self.assertEqual(user1.last_name, "Bloggs") self.assertEqual(user1.addresses.count(), 1) self.assertEqual(user1.addresses.all()[0], self._joeBloggsAddress) self.assertEqual(user1.groups.count(), 1) self.assertEqual(user1.groups.all()[0], Group.objects.get(name="joe_group")) self.assertIs(User.objects.filter(username="Jane Doe").exists(), True) user1 = User.objects.get(username="Jane Doe") self.assertEqual(user1.email, "jane@tgac.com") self.assertEqual(User.objects.count(), 5) # 4 presets plus default Anonymous user def test_access_anonymous(self): self._asAnonymous() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) response = self._client.get('/users/%d/' % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_access_invalid(self): self._asInvalid() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) response = self._client.get('/users/%d/' % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_user_list(self): # Others not permitted self._asJoeBloggs() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_200_OK) users = response.data self.assertEqual(len(users["results"]), 1) user1 = users["results"][0] self.assertEqual(user1["username"], "Joe Bloggs") def test_user_view_own(self): self._asJoeBloggs() response = self._client.get('/users/%d/' % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = response.data self.assertEqual(user1["username"], "Joe Bloggs") self.assertEqual(user1["email"], "joe@tgac.com") self.assertEqual(user1["first_name"], "Joe") self.assertEqual(user1["last_name"], "Bloggs") addresses = user1["addresses"] self.assertEqual(len(addresses), 1) self.assertEqual(addresses[0]["institution_name"], "Beetroot Institute") groups = user1["groups"] self.assertEqual(len(groups), 1) self.assertEqual(groups[0], "joe_group") def test_user_view_other(self): # Others not permitted self._asJaneDoe() response = self._client.get('/users/%d/' % self._janeDoe.id) self.assertEqual(response.status_code, status.HTTP_200_OK) response = self._client.get('/users/%d/' % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) def test_admin_list(self): self._asAdmin() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_200_OK) users = response.data self.assertEqual(len(users["results"]), 4) def test_admin_view_any(self): self._asAdmin() response = self._client.get('/users/%d/' % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = response.data self.assertEqual(user1["username"], "Joe Bloggs") self.assertEqual(user1["email"], "joe@tgac.com") self.assertEqual(user1["first_name"], "Joe") self.assertEqual(user1["last_name"], "Bloggs") addresses = user1["addresses"] self.assertEqual(len(addresses), 1) self.assertEqual(addresses[0]["institution_name"], "Beetroot Institute") groups = user1["groups"] self.assertEqual(len(groups), 1) self.assertEqual(groups[0], "joe_group") def test_user_create(self): self._asJaneDoe() new_user = {"username": "Test_User", "email": "Silly@silly.com", "password": "worms"} response = self._client.post("/users/", new_user, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertIs(User.objects.filter(username="Test_User").exists(), False) self.assertEqual(User.objects.count(), 5) @override_settings(ENABLE_CRM=False) def test_admin_create(self): self._asAdmin() new_user = {"username": "Test_User", "email": "Silly@silly.com", "password": "worms", "first_name": "Test", "last_name": "User", "groups": ["joe_group"]} response = self._client.post("/users/", new_user, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertIs(User.objects.filter(username="Test_User").exists(), True) self.assertEqual(User.objects.count(), 6) user1 = User.objects.get(username="Test_User") self.assertEqual(user1.email, "Silly@silly.com") self.assertEqual(user1.first_name, "Test") self.assertEqual(user1.last_name, "User") self.assertEqual(user1.groups.count(), 2) self.assertEqual(set(user1.groups.all()), set([Group.objects.get(name="user"), Group.objects.get(name="joe_group")])) # Other user still sees just theirs but we see both our old and new ones self._asJoeBloggs() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_200_OK) users = response.data self.assertEqual(len(users["results"]), 1) self._asAdmin() response = self._client.get('/users/') self.assertEqual(response.status_code, status.HTTP_200_OK) users = response.data self.assertEqual(len(users["results"]), 5) def test_user_edit_own(self): self._asJaneDoe() updated_user = {"email": "onion@apple.com"} response = self._client.patch("/users/%d/" % self._janeDoe.id, updated_user, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = User.objects.get(username="Jane Doe") self.assertEqual(user1.email, "onion@apple.com") def test_user_edit_other(self): # Others not permitted self._asJoeBloggs() updated_user = {"email": "onion@apple.com"} response = self._client.patch("/users/%d/" % self._janeDoe.id, updated_user, format='json') # Users cannot see other user so this is a 404 self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) user1 = User.objects.get(username="Jane Doe") self.assertEqual(user1.email, "jane@tgac.com") def test_admin_edit_any(self): self._asAdmin() updated_user = {"email": "onion@apple.com"} response = self._client.patch("/users/%d/" % self._janeDoe.id, updated_user, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = User.objects.get(username="Jane Doe") self.assertEqual(user1.email, "onion@apple.com") def test_user_change_own_password(self): self._asJaneDoe() new_password = {'new_password': 'super duper password'} response = self._client.patch("/users/%d/change_password/" % self._janeDoe.id, new_password, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = User.objects.get(username="Jane Doe") self.assertIs(check_password('super duper password', user1.password), True) def test_user_change_other_password(self): self._asJoeBloggs() new_password = {'new_password': 'super duper password'} response = self._client.patch("/users/%d/change_password/" % self._janeDoe.id, new_password, format='json') self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) user1 = User.objects.get(username="Joe Bloggs") self.assertIs(check_password('super duper password', user1.password), False) def test_admin_change_any_password(self): self._asAdmin() new_password = {'new_password': 'super duper password'} response = self._client.patch("/users/%d/change_password/" % self._joeBloggs.id, new_password, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) user1 = User.objects.get(username="Joe Bloggs") self.assertIs(check_password('super duper password', user1.password), True) def test_user_delete_own(self): self._asJoeBloggs() response = self._client.delete("/users/%d/" % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertIs(User.objects.filter(username="Joe Bloggs").exists(), False) def test_user_delete_other(self): # Others not permitted self._asJaneDoe() response = self._client.delete("/users/%d/" % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertIs(User.objects.filter(username="Joe Bloggs").exists(), True) def test_admin_delete_any(self): self._asAdmin() response = self._client.delete("/users/%d/" % self._joeBloggs.id) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertIs(User.objects.filter(username="Joe Bloggs").exists(), False) @override_settings(ENABLE_CRM=False) def test_anonymous_register(self): self._asAnonymous() new_user = {"username": "Test_User", "email": "Silly@silly.com", "password": "worms", "first_name": "Test", "last_name": "User", "institution_name": "Unseen University", "address_1": "1 Test Street", "address_2": "Testwood", "city": "Testington", "postcode": "T1 1TS", "country": "United Kingdom", "groups": ["joe_group"]} response = self._client.post("/users/register/", new_user, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertIs(User.objects.filter(username="Test_User").exists(), True) self.assertEqual(User.objects.count(), 6) user1 = User.objects.get(username="Test_User") self.assertEqual(user1.email, "Silly@silly.com") self.assertEqual(user1.first_name, "Test") self.assertEqual(user1.last_name, "User") self.assertIs(user1.groups.filter(name='user').exists(), True) self.assertEqual(user1.groups.count(), 2) self.assertEqual(set(user1.groups.all()), set([Group.objects.get(name="user"), Group.objects.get(name="joe_group")])) def test_anonymous_invalid_list_staff(self): self._asAnonymous() response = self._client.get("/users/staff/", format='json') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) self._asInvalid() response = self._client.get("/users/staff/", format='json') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_user_list_staff(self): self._asJoeBloggs() response = self._client.get("/users/staff/", format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data), 2) def test_admin_list_staff(self): self._asAdmin() response = self._client.get("/users/staff/", format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) # The admin user is staff as well self.assertEqual(len(response.data), 2) class GroupTestCase(LoggedInTestCase): def setUp(self): super(GroupTestCase, self).setUp() # No need to define any other groups as we have them from LoggedInTestCase already self._janeGroup = Group.objects.get(name="jane_group") self._joeGroup = Group.objects.get(name="joe_group") def test_presets(self): self.assertIs(Group.objects.filter(name="joe_group").exists(), True) self.assertIs(Group.objects.filter(name="jane_group").exists(), True) self.assertEqual(Group.objects.count(), 5) # joe, jane, user, admin, staff self._joeGroup = Group.objects.get(name="joe_group") self._janeGroup = Group.objects.get(name="jane_group") def test_access_anonymous(self): self._asAnonymous() response = self._client.get('/groups/') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) response = self._client.get('/groups/%d/' % self._joeGroup.id) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_access_invalid(self): self._asInvalid() response = self._client.get('/groups/') self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) response = self._client.get('/groups/%d/' % self._joeGroup.id) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_user_list(self): self._asJoeBloggs() response = self._client.get('/groups/') self.assertEqual(response.status_code, status.HTTP_200_OK) groups = response.data self.assertEqual(len(groups["results"]), 1) def test_user_view_any(self): self._asJoeBloggs() response = self._client.get('/groups/%d/' % self._janeGroup.id) # Not part of the group so shouldn't be able to see it self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) def test_user_view_part_of(self): self._asJoeBloggs() response = self._client.get('/groups/%d/' % self._joeGroup.id) # Not part of the group so shouldn't be able to see it self.assertEqual(response.status_code, status.HTTP_200_OK) group1 = response.data self.assertEqual(group1["name"], "joe_group") def test_admin_list(self): self._asAdmin() response = self._client.get('/groups/') self.assertEqual(response.status_code, status.HTTP_200_OK) groups = response.data self.assertEqual(len(groups["results"]), 5) def test_admin_view_any(self): self._asAdmin() response = self._client.get('/groups/%d/' % self._janeGroup.id) self.assertEqual(response.status_code, status.HTTP_200_OK) group1 = response.data self.assertEqual(group1["name"], "jane_group") def test_user_create(self): self._asJaneDoe() new_group = {"name": "Test_Group", "permissions": ["Can change equipment"]} response = self._client.post("/groups/", new_group, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertIs(Group.objects.filter(name="Test_Group").exists(), False) self.assertEqual(Group.objects.count(), 5) def test_admin_create(self): self._asAdmin() new_group = {"name": "Test_Group", "permissions": ["Can change equipment"]} response = self._client.post("/groups/", new_group, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertIs(Group.objects.filter(name="Test_Group").exists(), True) self.assertEqual(Group.objects.count(), 6) group = Group.objects.get(name="Test_Group") self.assertEqual(set(group.permissions.all()), set([Permission.objects.get(name="Can change equipment")])) # Other user should not see the new one as it does not have the group associated self._asJoeBloggs() response = self._client.get('/groups/') self.assertEqual(response.status_code, status.HTTP_200_OK) groups = response.data self.assertEqual(len(groups["results"]), 1) def test_user_edit_any(self): self._asJaneDoe() updated_group = {"permissions": ["Can change equipment"]} response = self._client.patch("/groups/%d/" % self._joeGroup.id, updated_group, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) group1 = Group.objects.get(name="joe_group") self.assertEqual(len(group1.permissions.all()), 0) def test_admin_edit_any(self): self._asAdmin() updated_group = {"permissions": ["Can change equipment"]} response = self._client.patch("/groups/%d/" % self._joeGroup.id, updated_group, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) group1 = Group.objects.get(name="joe_group") self.assertEqual(set(group1.permissions.all()), set([Permission.objects.get(name="Can change equipment")])) def test_user_delete_any(self): self._asJoeBloggs() response = self._client.delete("/groups/%d/" % self._joeGroup.id) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertIs(Group.objects.filter(name="joe_group").exists(), True) def test_admin_delete_any(self): # Others not permitted self._asAdmin() response = self._client.delete("/groups/%d/" % self._joeGroup.id) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertIs(Group.objects.filter(name="joe_group").exists(), False)
48.243719
100
0.638456
2,234
19,201
5.283348
0.08863
0.130899
0.067102
0.108108
0.866305
0.849784
0.818944
0.795815
0.74659
0.714056
0
0.016141
0.232071
19,201
397
101
48.365239
0.784334
0.036717
0
0.782353
0
0
0.11716
0.004221
0
0
0
0
0.355882
1
0.114706
false
0.055882
0.017647
0
0.138235
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
8
84e5c7cc9ae6968dcca695de9c9d11a043d2754d
48,662
py
Python
notebook/benchmark.py
Chibikuri/qwopt
e65549db83142af4c6b63cce9f55050ee87fb27a
[ "Apache-2.0" ]
4
2020-05-25T15:07:02.000Z
2021-02-17T07:38:06.000Z
notebook/benchmark.py
Chibikuri/qwopt
e65549db83142af4c6b63cce9f55050ee87fb27a
[ "Apache-2.0" ]
2
2020-01-05T07:31:41.000Z
2022-02-11T03:47:49.000Z
notebook/benchmark.py
Chibikuri/qwopt
e65549db83142af4c6b63cce9f55050ee87fb27a
[ "Apache-2.0" ]
1
2020-12-21T14:22:36.000Z
2020-12-21T14:22:36.000Z
# -*- coding: utf-8 -*- # --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.3.1 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # Optimization benchmarking # Plotting benchmark result. # + import sys import numpy as np import matplotlib.pyplot as plt import seaborn as sns import copy sys.path.append('../') from qwopt.compiler import composer from qwopt.benchmark import fidelity as fid from numpy import pi from qiskit import transpile from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister from qiskit import Aer, execute from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors import depolarizing_error from tqdm import tqdm, trange from mpl_toolkits.mplot3d import Axes3D import warnings warnings.simplefilter('ignore') # - # ## 1. Multi step of 4 node graph with one partition # ## Target graph and probability transition matrix # + alpha = 0.85 target_graph = np.array([[0, 1, 0, 1], [0, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]) E = np.array([[1/4, 1/2, 0, 1/2], [1/4, 0, 1/2, 0], [1/4, 1/2, 0, 1/2], [1/4, 0, 1/2, 0]]) # use google matrix prob_dist = alpha*E + ((1-alpha)/4)*np.ones((4, 4)) init_state = 1/2*np.array([np.sqrt(prob_dist[j][i]) for i in range(4) for j in range(4)]) # - # ### Check points # - How to decrease the fidelity over the number of steps # - The number of operations # ### Count operations # #### Without any optimizations # + # Circuit def four_node(opt, step): rotation = np.radians(31.788) cq = QuantumRegister(2, 'control') tq = QuantumRegister(2, 'target') c = ClassicalRegister(2, 'classical') if opt: anc = QuantumRegister(2, 'ancilla') qc = QuantumCircuit(cq, tq, anc, c) else: qc = QuantumCircuit(cq, tq, c) # initialize with probability distribution matrix initial = 1/2*np.array([np.sqrt(prob_dist[j][i]) for i in range(4) for j in range(4)]) qc.initialize(initial, [*cq, *tq]) for t in range(step): # Ti operation qc.x(cq[1]) qc.ccx(cq[0], cq[1], tq[1]) qc.x(cq[1]) qc.barrier() # Kdg operation if opt: qc.x(cq) qc.rccx(cq[0], cq[1], anc[0]) qc.barrier() qc.ch(anc[0], tq[0]) qc.ch(anc[0], tq[1]) qc.x(anc[0]) qc.cry(-rotation, anc[0], tq[1]) qc.ch(anc[0], tq[0]) qc.barrier() else: qc.x(cq) qc.mcry(-pi/2, cq, tq[0], None) qc.mcry(-pi/2, cq, tq[1], None) qc.x(cq) qc.barrier() # qc.x(cq[1]) # qc.mcry(-pi/2, cq, tq[0], None) # qc.mcry(-rotation, cq, tq[1], None) # qc.x(cq[1]) # qc.barrier() qc.x(cq[0]) qc.mcry(-pi/2, cq, tq[0], None) qc.mcry(-rotation, cq, tq[1], None) qc.x(cq[0]) qc.barrier() qc.cry(-pi/2, cq[0], tq[0]) qc.cry(-rotation, cq[0], tq[1]) qc.barrier() # qc.mcry(-pi/2, cq, tq[0], None) # qc.mcry(-rotation, cq, tq[1], None) # qc.barrier() # D operation qc.x(tq) qc.cz(tq[0], tq[1]) qc.x(tq) qc.barrier() # K operation if opt: qc.ch(anc[0], tq[0]) qc.cry(rotation, anc[0], tq[1]) qc.x(anc[0]) qc.ch(anc[0], tq[1]) qc.ch(anc[0], tq[0]) qc.rccx(cq[0], cq[1], anc[0]) qc.x(cq) qc.barrier() else: # previous, and naive imple # qc.mcry(pi/2, cq, tq[0], None) # qc.mcry(rotation, cq, tq[1], None) # qc.barrier() qc.cry(pi/2, cq[0], tq[0]) qc.cry(rotation, cq[0], tq[1]) qc.barrier() qc.x(cq[0]) qc.mcry(pi/2, cq, tq[0], None) qc.mcry(rotation, cq, tq[1], None) qc.x(cq[0]) qc.barrier() # qc.x(cq[1]) # qc.mcry(pi/2, cq, tq[0], None) # qc.mcry(rotation, cq, tq[1], None) # qc.x(cq[1]) # qc.barrier() qc.x(cq) qc.mcry(pi/2, cq, tq[0], None) qc.mcry(pi/2, cq, tq[1], None) qc.x(cq) qc.barrier() # Tidg operation qc.x(cq[1]) qc.ccx(cq[0], cq[1], tq[1]) qc.x(cq[1]) qc.barrier() # swap qc.swap(tq[0], cq[0]) qc.swap(tq[1], cq[1]) qc.measure(tq, c) return qc # - qc = four_node(True, 1) backend = Aer.get_backend('qasm_simulator') job = execute(qc, backend=backend, shots=10000) count = job.result().get_counts(qc) print(count) qc.draw(output='mpl') # ### The number of operations in steps # + ex1_cx = [] ex1_u3 = [] ex2_cx = [] ex2_u3 = [] ex3_cx = [] ex3_u3 = [] ex4_cx = [] ex4_u3 = [] for step in trange(1, 11): opt_qc = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=0) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex1_cx.append(ncx) ex1_u3.append(nu3) # ex2 opt_qc = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex2_cx.append(ncx) ex2_u3.append(nu3) # ex3 opt_qc = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex3_cx.append(ncx) ex3_u3.append(nu3) # ex4 nopt_qc = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=0) ncx = nopt_qc.count_ops().get('cx', 0) nu3 = nopt_qc.count_ops().get('u3', 0) + nopt_qc.count_ops().get('u2', 0) + nopt_qc.count_ops().get('u1', 0) ex4_cx.append(ncx) ex4_u3.append(nu3) # - cx = [ex1_cx, ex2_cx, ex3_cx, ex4_cx] u3 = [ex1_u3, ex2_u3, ex3_u3, ex4_u3] # color = ['#C23685', '#E38692', '#6BBED5', '#3EBA2B'] # labels = ['with my optimizations', 'with my and qiskit optimizations', 'with qiskit optimizations', 'without optimizations'] steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.xticks([i for i in range(11)]) plt.ylabel('the number of operations', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) plt.plot(steps, ex4_cx, color='#3EBA2B', label='# of CX without optimizations', linewidth=3) plt.plot(steps, ex4_u3, color='#6BBED5', label='# of single qubit operations without optimizations', linewidth=3) plt.legend(fontsize=25) cx = [ex1_cx, ex2_cx, ex3_cx, ex4_cx] u3 = [ex1_u3, ex2_u3, ex3_u3, ex4_u3] color = ['#C23685', '#E38692', '#6BBED5', '#3EBA2B'] labels = ['with my optimizations', 'with my and qiskit optimizations', 'with qiskit optimizations', 'without optimizations'] steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.xticks([i for i in range(11)]) plt.ylabel('the number of cx', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) print(list(steps)) for cs, col, lab in zip(cx, color, labels): plt.plot(steps, cs, color=col, label=lab, linewidth=3) plt.legend(fontsize=25) # ## Error rate transition import warnings warnings.simplefilter('ignore') # + qasm_sim = Aer.get_backend('qasm_simulator') def KL_divergence(p, q, torelance=10e-9): ''' p: np.array or list q: np.array or list ''' parray = np.array(p) + torelance qarray = np.array(q) + torelance divergence = np.sum(parray*np.log(parray/qarray)) return divergence def get_error(qc, ideal, err_model, nq, type='KL', shots=10000): bins = [format(i, '0%db'%nq) for i in range(2**nq)] job = execute(qc, backend=qasm_sim, shots=shots, noise_model=err_model) counts = job.result().get_counts(qc) prob = np.array([counts.get(b, 0)/shots for b in bins]) id_prob = np.array(ideal) # l2_error = np.sum([(i-j)**2 for i, j in zip(id_prob, prob)]) KL_error = KL_divergence(id_prob, prob) return KL_error def theoretical_prob(initial, step, ptran, nq): Pi_op = Pi_operator(ptran) swap = swap_operator(nq) operator = (2*Pi_op) - np.identity(len(Pi_op)) Szegedy = np.dot(operator, swap) Szegedy_n = copy.deepcopy(Szegedy) if step == 0: init_prob = np.array([abs(i)**2 for i in initial], dtype=np.float) return init_prob elif step == 1: prob = np.array([abs(i)**2 for i in np.dot(Szegedy, initial)], dtype=np.float) return prob else: for n in range(step-1): Szegedy_n = np.dot(Szegedy_n, Szegedy) probs = np.array([abs(i)**2 for i in np.dot(Szegedy_n, initial)], dtype=np.float) return probs def swap_operator(n_qubit): q1 = QuantumRegister(n_qubit//2) q2 = QuantumRegister(n_qubit//2) qc = QuantumCircuit(q1, q2) for c, t in zip(q1, q2): qc.swap(c, t) # FIXME backend = Aer.get_backend('unitary_simulator') job = execute(qc, backend=backend) swap = job.result().get_unitary(qc) return swap def Pi_operator(ptran): ''' This is not a quantum operation, just returning matrix ''' lg = len(ptran) psi_op = [] count = 0 for i in range(lg): psi_vec = [0 for _ in range(lg**2)] for j in range(lg): psi_vec[count] = np.sqrt(ptran[j][i]) count += 1 psi_op.append(np.kron(np.array(psi_vec).T, np.conjugate(psi_vec)).reshape((lg**2, lg**2))) Pi = psi_op[0] for i in psi_op[1:]: Pi = np.add(Pi, i) return Pi # + # circuit verifications # for step in range(1, 11): # opt_qc1 = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=0) # opt_qc2 = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=3) # opt_qc3 = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=3) # nopt_qc = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=0) # job1 = execute(opt_qc1, backend=qasm_sim, shots=10000) # job2 = execute(opt_qc2, backend=qasm_sim, shots=10000) # job3 = execute(opt_qc3, backend=qasm_sim, shots=10000) # job4 = execute(nopt_qc, backend=qasm_sim, shots=10000) # count1 = job1.result().get_counts() # count2 = job2.result().get_counts() # count3 = job3.result().get_counts() # count4 = job4.result().get_counts() # print(count1.get('00'), count2.get('00'), count3.get('00'), count4.get('00')) # + ex1_mean = [] ex1_std = [] ex2_mean = [] ex2_std = [] ex3_mean = [] ex3_std = [] ex4_mean = [] ex4_std = [] extime = 10 u3_error = depolarizing_error(0.001, 1) qw_step = range(1, 11) gate_error = np.arange(0, 0.03, 0.001) # errors, steps= np.meshgrid(gate_error, qw_step) bins = [format(i, '02b') for i in range(2**2)] step = 5 opt_qc = four_node(True, step) job = execute(opt_qc, backend=qasm_sim, shots=100000) count = job.result().get_counts(opt_qc) ideal_prob = [count.get(i, 0)/100000 for i in bins] for cxerr in tqdm(gate_error): # noise model error_model = NoiseModel() cx_error = depolarizing_error(cxerr, 2) error_model.add_all_qubit_quantum_error(u3_error, ['u3', 'u2']) error_model.add_all_qubit_quantum_error(cx_error, ['cx']) # ex1 errors = [] for i in range(extime): opt_qc = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=0) error = get_error(opt_qc, ideal_prob, error_model, 2) errors.append(error) ex1_mean.append(np.mean(errors)) ex1_std.append(np.std(errors)) # ex2 errors = [] for i in range(extime): opt_qc = transpile(four_node(True, step), basis_gates=['cx', 'u3'], optimization_level=3) error = get_error(opt_qc, ideal_prob, error_model, 2) errors.append(error) ex2_mean.append(np.mean(errors)) ex2_std.append(np.std(errors)) # ex3 errors = [] for i in range(extime): opt_qc = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=3) error = get_error(opt_qc, ideal_prob, error_model, 2) errors.append(error) ex3_mean.append(np.mean(errors)) ex3_std.append(np.std(errors)) # ex4 errors=[] for i in range(extime): nopt_qc = transpile(four_node(False, step), basis_gates=['cx', 'u3'], optimization_level=0) error = get_error(nopt_qc, ideal_prob, error_model, 2) errors.append(error) ex4_mean.append(np.mean(errors)) ex4_std.append(np.std(errors)) # + fig = plt.figure(figsize=(20, 10)) # plt.errorbar(gate_error, ex1_mean, yerr=ex1_std, label='With my optimizations') # # plt.errorbar(gate_error, ex2_mean, yerr=ex2_std, label='With my and qiskit optimizations') # # plt.errorbar(gate_error, ex3_mean, yerr=ex3_std, label='With qiskit optimizations') plt.errorbar(gate_error, ex4_mean, yerr=ex4_std, label='Without optimizations') plt.title('error investigation of %dstep Quantum Walk'%step, fontsize=30) plt.xlabel('cx error rate', fontsize=30) plt.ylabel('KL divergence', fontsize=30) plt.tick_params(labelsize=20) plt.legend(fontsize=20) plt.show() # + # ex1_mean = [] # ex1_std = [] # ex2_mean = [] # ex2_std = [] # ex3_mean = [] # ex3_std = [] # ex4_mean = [] # ex4_std = [] # extime = 10 # u3_error = depolarizing_error(0, 1) # qw_step = range(1,6) # gate_error = np.arange(0, 0.1, 0.01) # errors, steps= np.meshgrid(gate_error, qw_step) # bins = [format(i, '02b') for i in range(2**2)] # for ce, st in tqdm(zip(errors, steps)): # opt_qc = four_node(True, st[0]) # job = execute(opt_qc, backend=qasm_sim, shots=100000) # count = job.result().get_counts(opt_qc) # ideal_prob = [count.get(i, 0)/100000 for i in bins] # for cxerr, step in zip(ce, st): # # noise model # error_model = NoiseModel() # cx_error = depolarizing_error(cxerr, 2) # error_model.add_all_qubit_quantum_error(u3_error, ['u3', 'u2']) # error_model.add_all_qubit_quantum_error(cx_error, ['cx']) # # ex1 # qcs1 = [four_node(True, step) for i in range(extime)] # opt_qc1 = transpile(qcs1, basis_gates=['cx', 'u3'], optimization_level=0) # errors = get_error(opt_qc1, ideal_prob, error_model, 2) # ex1_mean.append(np.mean(errors)) # ex1_std.append(np.std(errors)) # # ex2 # qcs2 = [four_node(True, step) for i in range(extime)] # opt_qc2 = transpile(qcs2, basis_gates=['cx', 'u3'], optimization_level=3) # errors = get_error(opt_qc2, ideal_prob, error_model, 2) # ex2_mean.append(np.mean(errors)) # ex2_std.append(np.std(errors)) # # ex3 # qcs3 = [four_node(False, step) for i in range(extime)] # opt_qc3 = transpile(qcs3, basis_gates=['cx', 'u3'], optimization_level=3) # errors = get_error(opt_qc, ideal_prob, error_model, 2) # ex3_mean.append(np.mean(errors)) # ex3_std.append(np.std(errors)) # # ex4 # qcs4 = [four_node(False, step) for i in range(extime)] # nopt_qc = transpile(qcs4, basis_gates=['cx', 'u3'], optimization_level=0) # error = get_error(nopt_qc, ideal_prob, error_model, 2) # ex4_mean.append(np.mean(errors)) # ex4_std.append(np.std(errors)) # - # ### plot 3d res1 = np.array(ex1_mean).reshape(10, 10) res2 = np.array(ex2_mean).reshape(10, 10) res3 = np.array(ex3_mean).reshape(10, 10) res4 = np.array(ex4_mean).reshape(10, 10) # + # fig = plt.figure(figsize=(20, 10)) # ax = Axes3D(fig) # ax.plot_wireframe(errors, steps, res1, color='#E6855E', linewidth=2, label='With my optimization') # ax.plot_wireframe(errors, steps, res2, color='#F9DB57', linewidth=2, label='With my and qiskit optimizations') # ax.plot_wireframe(errors, steps, res3, color='#3DB680', linewidth=2, label='With qiskit optimizations') # ax.plot_wireframe(errors, steps, res4, color='#6A8CC7', linewidth=2, label='Without optimizations') # ax.set_xlabel('Cx error rate', labelpad=30, fontsize=30) # ax.set_ylabel('The number of steps', labelpad=30, fontsize=30) # ax.set_zlabel('Error', labelpad=30, fontsize=30) # plt.tick_params(labelsize=20) # plt.legend(fontsize=20) # plt.show() # - # ## 2. Multi step of 8 node graph with one partition # ## Target graph and probability transition matrix # + # In this case, we're gonna investigate matrix that has just one partition alpha = 0.85 target_graph = np.array([[0, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0]]) E = np.array([[1/8, 1/2, 0, 0, 0, 0, 0, 1/2], [1/8, 0, 1/2, 0, 0, 0, 0, 0], [1/8, 1/2, 0, 1/2, 0, 0, 0, 0], [1/8, 0, 1/2, 0, 1/2, 0, 0, 0], [1/8, 0, 0, 1/2, 0, 1/2, 0, 0], [1/8, 0, 0, 0, 1/2, 0, 1/2, 0], [1/8, 0, 0, 0, 0, 1/2, 0, 1/2], [1/8, 0, 0, 0, 0, 0, 1/2, 0]]) # use google matrix lt = len(target_graph) prob_dist = alpha*E + ((1-alpha)/lt)*np.ones((lt, lt)) init_state_eight = 1/np.sqrt(8)*np.array([np.sqrt(prob_dist[j][i]) for i in range(lt) for j in range(lt)]) # + # Circuit def eight_node(opt, step, initial, hardopt=False): rotation1 = np.radians(31.788) rotation2 = np.radians(90) rotation3 = np.radians(23.232) cq = QuantumRegister(3, 'control') tq = QuantumRegister(3, 'target') # ancilla for mct gates anc = QuantumRegister(3, 'mct anc') c = ClassicalRegister(3, 'classical') if opt: opt_anc = QuantumRegister(2, 'ancilla') qc = QuantumCircuit(cq, tq, anc, opt_anc, c) else: qc = QuantumCircuit(cq, tq, anc, c) # initialize with probability distribution matrix if initial is not None: qc.initialize(initial, [*cq, *tq]) for t in range(step): # Ti operation # T1 qc.x(cq[0]) qc.x(cq[2]) qc.mct(cq, tq[2], anc) qc.x(cq[0]) qc.x(cq[2]) qc.barrier() # T2 qc.x(cq[0]) qc.mct(cq, tq[1], anc) qc.x(cq[0]) qc.barrier() # T3 qc.x(cq[1:]) qc.mct(cq, tq[1], anc) qc.mct(cq, tq[2], anc) qc.x(cq[1:]) qc.barrier() # T4 qc.x(cq[1]) qc.mct(cq, tq[0], anc) qc.x(cq[1]) qc.barrier() # T5 qc.x(cq[2]) qc.mct(cq, tq[0], anc) qc.mct(cq, tq[2], anc) qc.x(cq[2]) qc.barrier() # T6 qc.x(tq[2]) qc.mct([*cq, *tq[1:]], tq[0], anc) qc.x(tq[2]) qc.barrier() # # Kdg operation if opt: qc.x(cq[:]) # qc.rcccx(cq[0], cq[1], cq[2], opt_anc[0]) qc.mct(cq, opt_anc[0], anc) qc.x(cq[:]) for ryq in tq: qc.cry(-pi/2, opt_anc[0], ryq) if hardopt: raise Exception('under_construction') else: qc.x(opt_anc[0]) qc.x(tq[0]) qc.mcry(-rotation3, [opt_anc[0], tq[0]], tq[2], anc) qc.x(tq[0]) qc.mcry(3/2*pi, [opt_anc[0], tq[0]], tq[1], anc) qc.mcry(3/2*pi, [opt_anc[0], tq[0]], tq[2], anc) qc.x(tq[0]) qc.mcry(-rotation2, [opt_anc[0], tq[0]], tq[1], anc) qc.x(tq[0]) qc.cry(-rotation1, opt_anc[0], tq[0]) qc.x(opt_anc[0]) else: qc.x(cq[:]) for ryq in tq: qc.mcry(-pi/2, cq, ryq, anc) qc.barrier() qc.x(cq[:]) for i in range(1, 8): bins = list(format(i, '03b')) for ib, b in enumerate(bins): if b == '0': qc.x(cq[ib]) qc.x(tq[0]) qc.mcry(-rotation3, [*cq, tq[0]], tq[2], anc) qc.x(tq[0]) qc.mcry(3/2*pi, [*cq, tq[0]], tq[1], anc) qc.mcry(3/2*pi, [*cq, tq[0]], tq[2], anc) qc.x(tq[0]) qc.mcry(-rotation2, [*cq, tq[0]], tq[1], anc) qc.x(tq[0]) qc.mcry(-rotation1, cq, tq[0], anc) for ib, b in enumerate(bins): if b == '0': qc.x(cq[ib]) # D operation qc.x(tq) qc.h(tq[2]) qc.ccx(tq[0], tq[1], tq[2]) qc.h(tq[2]) qc.x(tq) qc.barrier() # # K operation if opt: if hardopt: raise Exception('under...') else: qc.x(opt_anc[0]) qc.cry(rotation1, opt_anc[0], tq[0]) qc.x(tq[0]) qc.mcry(rotation2, [opt_anc[0], tq[0]], tq[1], anc) qc.x(tq[0]) qc.mcry(3/2*pi, [opt_anc[0], tq[0]], tq[1], anc) qc.mcry(3/2*pi, [opt_anc[0], tq[0]], tq[2], anc) qc.x(tq[0]) qc.mcry(rotation3, [opt_anc[0], tq[0]], tq[2], anc) qc.x(tq[0]) qc.x(opt_anc[0]) for anq in tq: qc.cry(pi/2, opt_anc[0], anq) qc.barrier() qc.x(cq[:]) qc.mct(cq, opt_anc[0], anc) qc.x(cq[:]) else: for i in range(1, 8): bins = list(format(i, '03b')) for ib, b in enumerate(bins): if b == '0': qc.x(cq[ib]) qc.mcry(rotation1, cq, tq[0], anc) qc.x(tq[0]) qc.mcry(rotation2, [*cq, tq[0]], tq[1], anc) qc.x(tq[0]) qc.mcry(3/2*pi, [*cq, tq[0]], tq[2], anc) qc.mcry(3/2*pi, [*cq, tq[0]], tq[1], anc) qc.x(tq[0]) qc.mcry(rotation3, [*cq, tq[0]], tq[2], anc) qc.x(tq[0]) for ib, b in enumerate(bins): if b == '0': qc.x(cq[ib]) qc.x(cq[:]) for anq in tq: qc.mcry(pi/2, cq, anq, anc) qc.x(cq[:]) # # Tidg operation # T6 qc.x(tq[2]) qc.mct([*cq, *tq[1:]], tq[0], anc) qc.x(tq[2]) qc.barrier() # T5 qc.x(cq[2]) qc.mct(cq, tq[0], anc) qc.mct(cq, tq[2], anc) qc.x(cq[2]) qc.barrier() # T4 qc.x(cq[1]) qc.mct(cq, tq[0], anc) qc.x(cq[1]) qc.barrier() # T3 qc.x(cq[1:]) qc.mct(cq, tq[1], anc) qc.mct(cq, tq[2], anc) qc.x(cq[1:]) qc.barrier() # T2 qc.x(cq[0]) qc.mct(cq, tq[1], anc) qc.x(cq[0]) qc.barrier() # T1 qc.x(cq[0]) qc.x(cq[2]) qc.mct(cq, tq[2], anc) qc.x(cq[0]) qc.x(cq[2]) qc.barrier() # swap for cont, targ in zip(cq, tq): qc.swap(cont, targ) qc.measure(cq, c) return qc # - # circuit verifications qasm_sim = Aer.get_backend("qasm_simulator") for step in range(1, 11): opt_qc1 = transpile(eight_node(True, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) opt_qc2 = transpile(eight_node(True, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=3) opt_qc3 = transpile(eight_node(False, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=3) nopt_qc = transpile(eight_node(False, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) job1 = execute(opt_qc1, backend=qasm_sim, shots=10000) job2 = execute(opt_qc2, backend=qasm_sim, shots=10000) job3 = execute(opt_qc3, backend=qasm_sim, shots=10000) job4 = execute(nopt_qc, backend=qasm_sim, shots=10000) count1 = job1.result().get_counts() count2 = job2.result().get_counts() count3 = job3.result().get_counts() count4 = job4.result().get_counts() print(count1.get('000'), count2.get('000'), count3.get('000'), count4.get('000')) # + ex1_cx = [] ex1_u3 = [] ex2_cx = [] ex2_u3 = [] ex3_cx = [] ex3_u3 = [] ex4_cx = [] ex4_u3 = [] for step in trange(1, 11): opt_qc = transpile(eight_node(True, step, None), basis_gates=['cx', 'u3'], optimization_level=0) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex1_cx.append(ncx) ex1_u3.append(nu3) # ex2 opt_qc = transpile(eight_node(True, step, None), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex2_cx.append(ncx) ex2_u3.append(nu3) # ex3 opt_qc = transpile(eight_node(False, step, None), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex3_cx.append(ncx) ex3_u3.append(nu3) # ex4 nopt_qc = transpile(eight_node(False, step, None), basis_gates=['cx', 'u3'], optimization_level=0) ncx = nopt_qc.count_ops().get('cx', 0) nu3 = nopt_qc.count_ops().get('u3', 0) + nopt_qc.count_ops().get('u2', 0) + nopt_qc.count_ops().get('u1', 0) ex4_cx.append(ncx) ex4_u3.append(nu3) # - steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.ylabel('the number of cx', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) plt.xticks([i for i in range(11)]) # for cs, col, lab in zip(cx, color, labels): plt.plot(steps, ex4_cx, color= '#3EBA2B', label= '# of CX without optimizations', linewidth=3) plt.plot(steps, ex4_u3, color= '#6BBED5', label= '# of single qubit operations without optimizations', linewidth=3) plt.legend(fontsize=25) cx = [ex1_cx, ex2_cx, ex3_cx, ex4_cx] u3 = [ex1_u3, ex2_u3, ex3_u3, ex4_u3] color = ['#C23685', '#E38692', '#6BBED5', '#3EBA2B'] labels = ['with my optimizations', 'with my and qiskit optimizations', 'with qiskit optimizations', 'without optimizations'] steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.ylabel('the number of cx', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) for cs, col, lab in zip(cx, color, labels): plt.plot(steps, cs, color=col, label=lab, linewidth=3) plt.legend(fontsize=25) # + ex1_mean = [] ex1_std = [] ex2_mean = [] ex2_std = [] ex3_mean = [] ex3_std = [] ex4_mean = [] ex4_std = [] extime = 100 u3_error = depolarizing_error(0, 1) qw_step = range(1, 11) gate_error = np.arange(0, 0.03, 0.001) # errors, steps= np.meshgrid(gate_error, qw_step) bins = [format(i, '03b') for i in range(2**3)] step = 3 opt_qc = eight_node(True, step, init_state_eight) job = execute(opt_qc, backend=qasm_sim, shots=100000) count = job.result().get_counts(opt_qc) ideal_prob = [count.get(i, 0)/100000 for i in bins] for cxerr in tqdm(gate_error, desc="error"): # noise model error_model = NoiseModel() cx_error = depolarizing_error(cxerr, 2) error_model.add_all_qubit_quantum_error(u3_error, ['u3', 'u2']) error_model.add_all_qubit_quantum_error(cx_error, ['cx']) # ex1 # opt_qc = [transpile(eight_node(True, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) for i in range(extime)] # errors = [] # for eqc in opt_qc: # errors.append(get_error(eqc, ideal_prob, error_model, 3)) # ex1_mean.append(np.mean(errors)) # ex1_std.append(np.std(errors)) # # ex2 # errors = [] # opt_qc = [transpile(eight_node(True, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=3) for i in range(extime)] # for eqc in opt_qc: # errors.append(get_error(eqc, ideal_prob, error_model, 3)) # ex2_mean.append(np.mean(errors)) # ex2_std.append(np.std(errors)) # # ex3 # errors = [] # opt_qc = [transpile(eight_node(False, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=3)for i in range(extime)] # for eqc in opt_qc: # errors.append(get_error(eqc, ideal_prob, error_model, 3)) # ex3_mean.append(np.mean(errors)) # ex3_std.append(np.std(errors)) # ex4 errors = [] nopt_qc = [transpile(eight_node(False, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) for i in range(extime)] for eqc in nopt_qc: errors.append(get_error(eqc, ideal_prob, error_model, 3)) ex4_mean.append(np.mean(errors)) ex4_std.append(np.std(errors)) # - fig = plt.figure(figsize=(20, 10)) sns.set() # plt.errorbar(gate_error, ex1_mean, yerr=ex1_std, label='With my optimizations') # # plt.errorbar(gate_error, ex2_mean, yerr=ex2_std, label='With my and qiskit optimizations') # # plt.errorbar(gate_error, ex3_mean, yerr=ex3_std, label='With qiskit optimizations') plt.errorbar(gate_error, ex4_mean, yerr=ex4_std, label='Without optimizations') plt.title('error investigation of %dstep Quantum Walk'%step, fontsize=30) plt.xlabel('cx error rate', fontsize=30) plt.ylabel('KL divergence', fontsize=30) plt.tick_params(labelsize=20) plt.legend(fontsize=20) plt.show() # + # 1step fig = plt.figure(figsize=(20, 10)) plt.plot(gate_error, ex1_mean, label='ex1') plt.plot(gate_error, ex2_mean, label='ex2') plt.plot(gate_error, ex3_mean, label='ex3') plt.plot(gate_error, ex4_mean, label='ex4') plt.tick_params(labelsize=20) plt.legend(fontsize=20) plt.show() # + # res1 = np.array(ex1_mean).reshape(10, 10) # res2 = np.array(ex2_mean).reshape(10, 10) # res3 = np.array(ex3_mean).reshape(10, 10) # res4 = np.array(ex4_mean).reshape(10, 10) # + # fig = plt.figure(figsize=(20, 10)) # ax = Axes3D(fig) # ax.plot_wireframe(errors, steps, res1, color='#E6855E', linewidth=2, label='With my optimization') # ax.plot_wireframe(errors, steps, res2, color='#F9DB57', linewidth=2, label='With my and qiskit optimizations') # ax.plot_wireframe(errors, steps, res3, color='#3DB680', linewidth=2, label='With qiskit optimizations') # ax.plot_wireframe(errors, steps, res4, color='#6A8CC7', linewidth=2, label='Without optimizations') # ax.set_xlabel('Cx error rate', labelpad=30, fontsize=30) # ax.set_ylabel('The number of steps', labelpad=30, fontsize=30) # ax.set_zlabel('Error', labelpad=30, fontsize=30) # plt.tick_params(labelsize=20) # plt.legend(fontsize=20) # plt.show() # - # ## 3. Multi step of 8 node graph with multi partition # + code_folding=[] alpha = 0.85 target_graph = np.array([[0, 0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]]) E = np.array([[0, 0, 0, 1, 1/2, 0, 0, 0], [1, 0, 0, 0, 1/2, 0, 0, 0], [0, 1, 0, 0, 0, 1/2, 0, 0], [0, 0, 1, 0, 0, 1/2, 0, 0], [0, 0, 0, 0, 0, 0, 1/4, 1/4], [0, 0, 0, 0, 0, 0, 1/4, 1/4], [0, 0, 0, 0, 0, 0, 1/4, 1/4], [0, 0, 0, 0, 0, 0, 1/4, 1/4]]) # use google matrix prob_dist = alpha*E + ((1-alpha)/8)*np.ones((8, 8)) init_state_eight = 1/np.sqrt(8)*np.array([np.sqrt(prob_dist[j][i]) for i in range(8) for j in range(8)]) # - def mch(qc, controls, target, anc, tganc): # multi control hadamard gate if len(controls) == 1: qc.ch(*controls, target) elif len(controls) == 2: qc.ccx(controls[0], controls[1], tganc[0]) qc.ch(tganc[0], target) qc.ccx(controls[0], controls[1], tganc[0]) elif len(controls) > 2: qc.mct(controls, tganc[0], anc) for tg in target: qc.ch(tganc[0], tg) qc.mct(controls, tganc[0], anc) return qc qasm_sim = Aer.get_backend("qasm_simulator") q = QuantumRegister(6) anc = QuantumRegister(3) tganc = QuantumRegister(1) c = ClassicalRegister(10) qc = QuantumCircuit(q, anc, tganc, c) mch(qc, [q[0], q[3]], [q[4], q[5]], anc, tganc) qc.barrier() qc.draw(output='mpl') qc.measure(q, c[:6]) qc.measure(anc, c[6:9]) qc.measure(tganc, c[9]) job = execute(qc, backend=qasm_sim, shots=1024) count = job.result().get_counts(qc) print(count) qc.draw(output='mpl') # + # Circuit def eight_node_multi(opt, step, initial, hardopt=False): rotation11 = np.radians(31.788) rotation12 = np.radians(23.231) rotation13 = np.radians(163.285) rotation21 = np.radians(31.788) rotation22 = np.radians(23.231) rotation31 = np.radians(148.212) # for multi qubit hadamrd gate hs = QuantumCircuit.ch cq = QuantumRegister(3, 'control') tq = QuantumRegister(3, 'target') # ancilla for mct gates anc = QuantumRegister(3, 'mct anc') tganc = QuantumRegister(1, 'tgancila') c = ClassicalRegister(3, 'classical') if opt: opt_anc = QuantumRegister(2, 'ancilla') qc = QuantumCircuit(cq, tq, anc, opt_anc, tganc, c) else: qc = QuantumCircuit(cq, tq, anc,tganc, c) # initialize with probability distribution matrix if initial is not None: qc.initialize(initial, [*cq, *tq]) for t in range(step): # Ti operation(opt) # T11 qc.x(cq[1]) qc.ccx(cq[1], cq[2], tq[1]) qc.x(cq[1]) qc.barrier() # T12 qc.x(cq[0]) qc.x(cq[2]) qc.mct(cq, tq[1], anc) qc.x(cq[0]) qc.x(cq[2]) qc.barrier() # T21 qc.x(cq[0]) qc.ccx(cq[0], cq[2], tq[2]) qc.x(cq[0]) qc.barrier() # # Kdg operation if opt: if hardopt: raise Exception('under const') else: # K1dg qc.x(cq[0]) # s1 qc.x(tq[0]) # s2 mch(qc, [cq[0], tq[0], tq[1]], [tq[2]], anc, tganc) qc.x(tq[1]) # s3 qc.mcry(-rotation13, [cq[0], tq[0], tq[1]], tq[2], anc) qc.x(tq[1]) # e3 qc.x(tq[0]) # e2 mch(qc, [cq[0], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) # s4 qc.mcry(-rotation12, [cq[0], tq[0]], tq[1], anc) qc.x(tq[0]) # e4 qc.cry(-rotation11, cq[0], tq[0]) qc.x(cq[0]) # e1 qc.barrier # K2dg # map qc.x(cq[1]) qc.ccx(cq[1], cq[0], opt_anc[0]) qc.x(cq[1]) # op qc.ch(opt_anc[0], tq[2]) mch(qc, [opt_anc[0], tq[0]], tq[1], anc, tganc) qc.x(tq[0])# s1 qc.mcry(-rotation22, [opt_anc[0], tq[0]], tq[1], anc) qc.x(tq[0]) # e1 qc.cry(-rotation21, opt_anc[0], tq[0]) qc.barrier # K3dg #map qc.ccx(cq[1], cq[0], opt_anc[1]) # op qc.ch(opt_anc[1], tq[2]) qc.ch(opt_anc[1], tq[1]) qc.cry(-rotation31, opt_anc[1], tq[0]) qc.barrier else: # K1dg qc.x(cq[0]) # s1 qc.x(tq[0]) # s2 mch(qc, [cq[0], tq[0], tq[1]], [tq[2]], anc, tganc) qc.x(tq[1]) # s3 qc.mcry(-rotation13, [cq[0], tq[0], tq[1]], tq[2], anc) # rotation 3 dg qc.x(tq[1]) # e3 qc.x(tq[0]) # e2 mch(qc, [cq[0], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) # s4 qc.mcry(-rotation12, [cq[0], tq[0]], tq[1], anc) qc.x(tq[0]) # e4 qc.cry(-rotation11, cq[0], tq[0]) qc.x(cq[0]) # e1 # K2dg qc.x(cq[1]) # s1 qc.x(tq[0]) # s2 mch(qc, [cq[0], cq[1], tq[0]], [tq[2]], anc, tganc) qc.x(tq[0]) # e2 mch(qc, [cq[0], cq[1], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) # s3 qc.mcry(-rotation22, [cq[0], cq[1], tq[0]], tq[1], anc) qc.x(tq[0]) # e3 qc.mcry(-rotation21, [cq[0], cq[1]], tq[0], anc) qc.x(cq[1]) # K3dg mch(qc, [cq[0], cq[1]], [tq[1], tq[2]], anc, tganc) qc.mcry(-rotation31, [cq[0], cq[1]], tq[0], anc) # D operation qc.x(tq) qc.h(tq[2]) qc.ccx(tq[0], tq[1], tq[2]) qc.h(tq[2]) qc.x(tq) qc.barrier() # # K operation if opt: if hardopt: raise Exception('under') else: # K3 qc.cry(rotation31, opt_anc[1], tq[0]) qc.ch(opt_anc[1], tq[1]) qc.ch(opt_anc[1], tq[2]) #unmap qc.ccx(cq[1], cq[0], opt_anc[1]) qc.barrier() # K2 qc.cry(rotation21, opt_anc[0], tq[0]) qc.x(tq[0]) # s1 qc.mcry(rotation22, [opt_anc[0], tq[0]], tq[1], anc) qc.x(tq[0]) mch(qc, [opt_anc[0], tq[0]], tq[1], anc, tganc) qc.ch(opt_anc[0], tq[2]) # unmap qc.x(cq[1]) qc.ccx(cq[1], cq[0], opt_anc[0]) qc.x(cq[1]) # op qc.barrier # K1 qc.x(cq[0]) # s1 qc.cry(rotation11, cq[0], tq[0]) qc.x(tq[0]) # s2 qc.mcry(rotation12, [cq[0], tq[0]], tq[1], anc) qc.x(tq[0]) # e2 mch(qc, [cq[0], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) #s3 qc.x(tq[1]) # s4 qc.mcry(rotation13, [cq[0], tq[0], tq[1]], tq[2], anc) qc.x(tq[1]) # 4 mch(qc, [cq[0], tq[0], tq[1]], [tq[2]], anc, tganc) qc.x(tq[0]) # e3 qc.x(cq[0]) # e1 qc.barrier else: # K3 qc.mcry(rotation31, [cq[0], cq[1]], tq[0], anc) mch(qc, [cq[0], cq[1]], [tq[1], tq[2]], anc, tganc) # K2 qc.x(cq[1]) qc.mcry(rotation21, [cq[0], cq[1]], tq[0], anc) qc.x(tq[0]) # e3 qc.mcry(rotation22, [cq[0], cq[1], tq[0]], tq[1], anc) qc.x(tq[0]) # s3 mch(qc, [cq[0], cq[1], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) # e2 mch(qc, [cq[0], cq[1], tq[0]], [tq[2]], anc, tganc) qc.x(tq[0]) # s2 qc.x(cq[0]) qc.x(cq[1]) # s1 # K1 qc.cry(rotation11, cq[0], tq[0]) qc.x(tq[0]) # e4 qc.mcry(rotation12, [cq[0], tq[0]], tq[1], anc) qc.x(tq[0]) # s4 mch(qc, [cq[0], tq[0]], [tq[1], tq[2]], anc, tganc) qc.x(tq[0]) # e2 qc.x(tq[1]) # e3 qc.mcry(rotation13, [cq[0], tq[0], tq[1]], tq[2], anc) # rotation 3 dg qc.x(tq[1]) # s3 mch(qc, [cq[0], tq[0], tq[1]], [tq[2]], anc, tganc) qc.x(tq[0]) # s2 qc.x(cq[0]) # s1 # T21 dg qc.x(cq[0]) qc.ccx(cq[0], cq[2], tq[2]) qc.x(cq[0]) qc.barrier() # T12dg qc.x(cq[0]) qc.x(cq[2]) qc.mct(cq, tq[1], anc) qc.x(cq[0]) qc.x(cq[2]) qc.barrier() # T11 dg qc.x(cq[1]) qc.ccx(cq[0], cq[1], tq[1]) qc.x(cq[1]) # swap for cont, targ in zip(cq, tq): qc.swap(cont, targ) qc.measure(cq, c) return qc # - qc = eight_node_multi(True, 1, None) qc.draw(output='mpl') # circuit verifications qasm_sim = Aer.get_backend('qasm_simulator') init_state = [np.sqrt(1/64) for i in range(64)] for step in range(1, 11): opt_qc1 = transpile(eight_node_multi(True, step, init_state), basis_gates=['cx', 'u3'], optimization_level=0) opt_qc2 = transpile(eight_node_multi(True, step, init_state), basis_gates=['cx', 'u3'], optimization_level=3) opt_qc3 = transpile(eight_node_multi(False, step, init_state), basis_gates=['cx', 'u3'], optimization_level=3) nopt_qc = transpile(eight_node_multi(False, step, init_state), basis_gates=['cx', 'u3'], optimization_level=0) job1 = execute(opt_qc1, backend=qasm_sim, shots=10000) job2 = execute(opt_qc2, backend=qasm_sim, shots=10000) job3 = execute(opt_qc3, backend=qasm_sim, shots=10000) job4 = execute(nopt_qc, backend=qasm_sim, shots=10000) count1 = job1.result().get_counts() count2 = job2.result().get_counts() count3 = job3.result().get_counts() count4 = job4.result().get_counts() print(count1.get('000'), count2.get('000'), count3.get('000'), count4.get('000')) # + ex1_cx = [] ex1_u3 = [] ex2_cx = [] ex2_u3 = [] ex3_cx = [] ex3_u3 = [] ex4_cx = [] ex4_u3 = [] for step in trange(1, 11): opt_qc = transpile(eight_node_multi(True, step, None), basis_gates=['cx', 'u3'], optimization_level=0) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex1_cx.append(ncx) ex1_u3.append(nu3) # ex2 opt_qc = transpile(eight_node_multi(True, step, None), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex2_cx.append(ncx) ex2_u3.append(nu3) # ex3 opt_qc = transpile(eight_node_multi(False, step, None), basis_gates=['cx', 'u3'], optimization_level=3) ncx = opt_qc.count_ops().get('cx', 0) nu3 = opt_qc.count_ops().get('u3', 0) + opt_qc.count_ops().get('u2', 0) + opt_qc.count_ops().get('u1', 0) ex3_cx.append(ncx) ex3_u3.append(nu3) # ex4 nopt_qc = transpile(eight_node_multi(False, step, None), basis_gates=['cx', 'u3'], optimization_level=0) ncx = nopt_qc.count_ops().get('cx', 0) nu3 = nopt_qc.count_ops().get('u3', 0) + nopt_qc.count_ops().get('u2', 0) + nopt_qc.count_ops().get('u1', 0) ex4_cx.append(ncx) ex4_u3.append(nu3) # - qc = eight_node_multi(False, 1, None) print(qc.depth()) qc = eight_node_multi(False, 2, None) print(qc.depth()) cx = [ex1_cx, ex4_cx] u3 = [ex1_u3, ex4_u3] color = ['#C23685', '#6BBED5', '#3EBA2B'] labels = ['with my optimizations', 'related works[6]'] steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.yticks(range(0, 9000, 500)) plt.xticks(range(0, 11, 1)) plt.ylabel('the number of cx', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) plt.plot(steps, ex4_cx, color= '#3EBA2B', label="# of CX paper circuit", linewidth=3) plt.plot(steps, ex4_u3, color= '#6BBED5', label="# of single qubit gates of paper circuit", linewidth=3) plt.legend(fontsize=25) cx = [ex1_cx, ex4_cx] u3 = [ex1_u3, ex4_u3] color = ['#C23685', '#6BBED5', '#3EBA2B'] labels = ['with my optimizations', 'related works[6]'] steps = range(1, 11) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) sns.set() plt.xlabel('the number of steps', fontsize=30) plt.yticks(range(0, 4600, 200)) plt.xticks(range(0, 11, 1)) plt.ylabel('the number of cx', fontsize=30) plt.title('the nuber of operations over steps', fontsize=30) plt.tick_params(labelsize=20) for cs, col, lab in zip(cx, color, labels): plt.plot(steps, cs, color=col, label=lab, linewidth=3) plt.legend(fontsize=25) # + ex1_mean = [] ex1_std = [] ex4_mean = [] ex4_std = [] extime = 10 u3_error = depolarizing_error(0, 1) gate_error = np.arange(0, 0.03, 0.001) # errors, steps= np.meshgrid(gate_error, qw_step) bins = [format(i, '03b') for i in range(2**3)] step = 5 opt_qc = eight_node_multi(False, step, init_state_eight) job = execute(opt_qc, backend=qasm_sim, shots=100000) count = job.result().get_counts(opt_qc) ideal_prob = [count.get(i, 0)/100000 for i in bins] for cxerr in tqdm(gate_error): # noise model error_model = NoiseModel() cx_error = depolarizing_error(cxerr, 2) error_model.add_all_qubit_quantum_error(u3_error, ['u3', 'u2']) error_model.add_all_qubit_quantum_error(cx_error, ['cx']) # ex1 opt_qc = transpile(eight_node_multi(True, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) errors = [] for i in range(extime): error = get_error(opt_qc, ideal_prob, error_model, 3) errors.append(error) ex1_mean.append(np.mean(errors)) ex1_std.append(np.std(errors)) # ex4 nopt_qc = transpile(eight_node_multi(False, step, init_state_eight), basis_gates=['cx', 'u3'], optimization_level=0) for i in range(extime): error = get_error(nopt_qc, ideal_prob, error_model, 3) errors.append(error) ex4_mean.append(np.mean(errors)) ex4_std.append(np.std(errors)) # - fig = plt.figure(figsize=(20, 10)) sns.set() # plt.errorbar(gate_error, ex1_mean, yerr=ex1_std, label='With my optimizations') plt.errorbar(gate_error, ex4_mean, yerr=ex4_std, label='Without optimizations') plt.title('error investigation of %dstep Quantum Walk'%step, fontsize=30) plt.xlabel('cx error rate', fontsize=30) plt.ylabel('KL divergence', fontsize=30) plt.tick_params(labelsize=20) plt.legend(fontsize=20) plt.show() # Play ground q = QuantumRegister(1) qc = QuantumCircuit(q) rotation12 = np.radians(23.231) qc.u3(pi/2+rotation12, 0, pi, q[0]) unit = Aer.get_backend('unitary_simulator') job = execute(qc, backend=unit) uni = job.result().get_unitary() print(uni) q = QuantumRegister(1) qc = QuantumCircuit(q) rotation12 = np.radians(23.231) qc.u3(pi/2, 0, pi, q[0]) qc.ry(rotation12, q[0]) unit = Aer.get_backend('unitary_simulator') job = execute(qc, backend=unit) uni = job.result().get_unitary() print(uni) q = QuantumRegister(3,'qr') anc = QuantumRegister(2, 'anc') qc = QuantumCircuit(q, anc) qc.mcmt([q[0], q[1]], anc, QuantumCircuit.ch, [q[2]]) qc.draw(output='mpl') q = QuantumRegister(6) qc = QuantumCircuit(q) qc.initialize(init_state, q) nqc = transpile(qc, basis_gates=['cx', 'h', 'x', 'u3']) nqc.draw(output='mpl') # ## 4. Multi step of 512 node graph with multi partition
32.247846
139
0.546546
7,462
48,662
3.449075
0.058697
0.017951
0.010957
0.009325
0.854295
0.826903
0.816801
0.796247
0.778646
0.748028
0
0.068721
0.281123
48,662
1,508
140
32.269231
0.667
0.191628
0
0.728205
0
0
0.049473
0
0
0
0
0.000663
0
1
0.009231
false
0
0.017436
0
0.037949
0.009231
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
04932bd5cd2e696bd1220ff69a4411afedbdf4d7
29,809
py
Python
pandadoc_client/api/folders_api_api.py
dyakutkin/pandadoc-api-python-client
f72b59dc69b4df2ef8decd3cbc69c9466859bedc
[ "MIT" ]
null
null
null
pandadoc_client/api/folders_api_api.py
dyakutkin/pandadoc-api-python-client
f72b59dc69b4df2ef8decd3cbc69c9466859bedc
[ "MIT" ]
null
null
null
pandadoc_client/api/folders_api_api.py
dyakutkin/pandadoc-api-python-client
f72b59dc69b4df2ef8decd3cbc69c9466859bedc
[ "MIT" ]
null
null
null
""" PandaDoc Public API PandaDoc Public API documentation # noqa: E501 Generated by: https://openapi-generator.tech """ import re # noqa: F401 import sys # noqa: F401 from pandadoc_client.api_client import ApiClient, Endpoint as _Endpoint from pandadoc_client.model_utils import ( # noqa: F401 check_allowed_values, check_validations, date, datetime, file_type, none_type, validate_and_convert_types ) from pandadoc_client.model.documents_folder_create_request import DocumentsFolderCreateRequest from pandadoc_client.model.documents_folder_create_response import DocumentsFolderCreateResponse from pandadoc_client.model.documents_folder_list_response import DocumentsFolderListResponse from pandadoc_client.model.documents_folder_rename_request import DocumentsFolderRenameRequest from pandadoc_client.model.documents_folder_rename_response import DocumentsFolderRenameResponse from pandadoc_client.model.templates_folder_create_request import TemplatesFolderCreateRequest from pandadoc_client.model.templates_folder_create_response import TemplatesFolderCreateResponse from pandadoc_client.model.templates_folder_list_response import TemplatesFolderListResponse from pandadoc_client.model.templates_folder_rename_request import TemplatesFolderRenameRequest from pandadoc_client.model.templates_folder_rename_response import TemplatesFolderRenameResponse class FoldersAPIApi(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.create_document_folder_endpoint = _Endpoint( settings={ 'response_type': (DocumentsFolderCreateResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/documents/folders', 'operation_id': 'create_document_folder', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'documents_folder_create_request', ], 'required': [ 'documents_folder_create_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'documents_folder_create_request': (DocumentsFolderCreateRequest,), }, 'attribute_map': { }, 'location_map': { 'documents_folder_create_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.create_template_folder_endpoint = _Endpoint( settings={ 'response_type': (TemplatesFolderCreateResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/templates/folders', 'operation_id': 'create_template_folder', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'templates_folder_create_request', ], 'required': [ 'templates_folder_create_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'templates_folder_create_request': (TemplatesFolderCreateRequest,), }, 'attribute_map': { }, 'location_map': { 'templates_folder_create_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.list_document_folders_endpoint = _Endpoint( settings={ 'response_type': (DocumentsFolderListResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/documents/folders', 'operation_id': 'list_document_folders', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'parent_uuid', 'count', 'page', ], 'required': [], 'nullable': [ ], 'enum': [ ], 'validation': [ 'count', 'page', ] }, root_map={ 'validations': { ('count',): { 'inclusive_minimum': 1, }, ('page',): { 'inclusive_minimum': 1, }, }, 'allowed_values': { }, 'openapi_types': { 'parent_uuid': (str,), 'count': (int,), 'page': (int,), }, 'attribute_map': { 'parent_uuid': 'parent_uuid', 'count': 'count', 'page': 'page', }, 'location_map': { 'parent_uuid': 'query', 'count': 'query', 'page': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [], }, api_client=api_client ) self.list_template_folders_endpoint = _Endpoint( settings={ 'response_type': (TemplatesFolderListResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/templates/folders', 'operation_id': 'list_template_folders', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'parent_uuid', 'count', 'page', ], 'required': [], 'nullable': [ ], 'enum': [ ], 'validation': [ 'count', 'page', ] }, root_map={ 'validations': { ('count',): { 'inclusive_minimum': 1, }, ('page',): { 'inclusive_minimum': 1, }, }, 'allowed_values': { }, 'openapi_types': { 'parent_uuid': (str,), 'count': (int,), 'page': (int,), }, 'attribute_map': { 'parent_uuid': 'parent_uuid', 'count': 'count', 'page': 'page', }, 'location_map': { 'parent_uuid': 'query', 'count': 'query', 'page': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [], }, api_client=api_client ) self.rename_document_folder_endpoint = _Endpoint( settings={ 'response_type': (DocumentsFolderRenameResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/documents/folders/{id}', 'operation_id': 'rename_document_folder', 'http_method': 'PUT', 'servers': None, }, params_map={ 'all': [ 'id', 'documents_folder_rename_request', ], 'required': [ 'id', 'documents_folder_rename_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'id': (str,), 'documents_folder_rename_request': (DocumentsFolderRenameRequest,), }, 'attribute_map': { 'id': 'id', }, 'location_map': { 'id': 'path', 'documents_folder_rename_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.rename_template_folder_endpoint = _Endpoint( settings={ 'response_type': (TemplatesFolderRenameResponse,), 'auth': [ 'apiKey', 'oauth2' ], 'endpoint_path': '/public/v1/templates/folders/{id}', 'operation_id': 'rename_template_folder', 'http_method': 'PUT', 'servers': None, }, params_map={ 'all': [ 'id', 'templates_folder_rename_request', ], 'required': [ 'id', 'templates_folder_rename_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'id': (str,), 'templates_folder_rename_request': (TemplatesFolderRenameRequest,), }, 'attribute_map': { 'id': 'id', }, 'location_map': { 'id': 'path', 'templates_folder_rename_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) def create_document_folder( self, documents_folder_create_request, **kwargs ): """Create Documents Folder # noqa: E501 Create a new folder to store your documents. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_document_folder(documents_folder_create_request, async_req=True) >>> result = thread.get() Args: documents_folder_create_request (DocumentsFolderCreateRequest): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: DocumentsFolderCreateResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['documents_folder_create_request'] = \ documents_folder_create_request return self.create_document_folder_endpoint.call_with_http_info(**kwargs) def create_template_folder( self, templates_folder_create_request, **kwargs ): """Create Templates Folder # noqa: E501 Create a new folder to store your templates. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_template_folder(templates_folder_create_request, async_req=True) >>> result = thread.get() Args: templates_folder_create_request (TemplatesFolderCreateRequest): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: TemplatesFolderCreateResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['templates_folder_create_request'] = \ templates_folder_create_request return self.create_template_folder_endpoint.call_with_http_info(**kwargs) def list_document_folders( self, **kwargs ): """List Documents Folders # noqa: E501 Get the list of folders that contain Documents in your account. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_document_folders(async_req=True) >>> result = thread.get() Keyword Args: parent_uuid (str): The UUID of the folder containing folders. To list the folders located in the root folder, remove this parameter in the request.. [optional] count (int): Optionally, specify how many folders to return. Default is 50 folders, maximum is 100 folders.. [optional] page (int): Optionally, specify which page of the dataset to return.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: DocumentsFolderListResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.list_document_folders_endpoint.call_with_http_info(**kwargs) def list_template_folders( self, **kwargs ): """List Templates Folders # noqa: E501 Get the list of folders that contain Templates in your account. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_template_folders(async_req=True) >>> result = thread.get() Keyword Args: parent_uuid (str): The UUID of the folder containing folders. To list the folders located in the root folder, remove this parameter in the request.. [optional] count (int): Optionally, specify how many folders to return. Default is 50 folders, maximum is 100 folders.. [optional] page (int): Optionally, specify which page of the dataset to return.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: TemplatesFolderListResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.list_template_folders_endpoint.call_with_http_info(**kwargs) def rename_document_folder( self, id, documents_folder_rename_request, **kwargs ): """Rename Documents Folder # noqa: E501 Rename Documents Folder. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.rename_document_folder(id, documents_folder_rename_request, async_req=True) >>> result = thread.get() Args: id (str): The UUID of the folder that you are renaming. documents_folder_rename_request (DocumentsFolderRenameRequest): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: DocumentsFolderRenameResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['id'] = \ id kwargs['documents_folder_rename_request'] = \ documents_folder_rename_request return self.rename_document_folder_endpoint.call_with_http_info(**kwargs) def rename_template_folder( self, id, templates_folder_rename_request, **kwargs ): """Rename Templates Folder # noqa: E501 Rename a templates folder. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.rename_template_folder(id, templates_folder_rename_request, async_req=True) >>> result = thread.get() Args: id (str): The UUID of the folder which you are renaming. templates_folder_rename_request (TemplatesFolderRenameRequest): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: TemplatesFolderRenameResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['id'] = \ id kwargs['templates_folder_rename_request'] = \ templates_folder_rename_request return self.rename_template_folder_endpoint.call_with_http_info(**kwargs)
36.755857
171
0.510349
2,641
29,809
5.496782
0.080651
0.026038
0.021492
0.022319
0.858648
0.802301
0.777778
0.739753
0.72205
0.702487
0
0.004539
0.408702
29,809
810
172
36.801235
0.819074
0.340434
0
0.637523
1
0
0.224467
0.073157
0
0
0
0
0
1
0.01275
false
0
0.025501
0
0.051002
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
04940fb929e2bf393f11a40996649e12eac1f7f6
1,950
py
Python
test/classes/class8.py
Setonas/MagicSetonas
ef76da5f27a0506b194c58072b81424e3ce985d7
[ "MIT" ]
5
2017-02-22T10:17:39.000Z
2021-04-06T16:36:13.000Z
test/classes/class8.py
Setonas/MagicSetonas
ef76da5f27a0506b194c58072b81424e3ce985d7
[ "MIT" ]
null
null
null
test/classes/class8.py
Setonas/MagicSetonas
ef76da5f27a0506b194c58072b81424e3ce985d7
[ "MIT" ]
1
2020-08-29T02:30:52.000Z
2020-08-29T02:30:52.000Z
rūšis Joks: pereiti rūšis Tiesa(Netikras): pereiti rūšis Netikras(objektas): pereiti rūšis : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python Joks : keyword.illegal.name.python, meta.class.python, source.python : : meta.class.python, punctuation.section.class.begin.python, source.python : source.python pereiti : keyword.control.flow.python, source.python rūšis : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python Tiesa : keyword.illegal.name.python, meta.class.python, source.python ( : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.begin.python, source.python Netikras : constant.language.python, meta.class.inheritance.python, meta.class.python, source.python ) : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.end.python, source.python : : meta.class.python, punctuation.section.class.begin.python, source.python : source.python pereiti : keyword.control.flow.python, source.python rūšis : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python Netikras : keyword.illegal.name.python, meta.class.python, source.python ( : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.begin.python, source.python objektas : meta.class.inheritance.python, meta.class.python, source.python, support.type.python ) : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.end.python, source.python : : meta.class.python, punctuation.section.class.begin.python, source.python : source.python pereiti : keyword.control.flow.python, source.python
62.903226
128
0.703077
225
1,950
6.093333
0.115556
0.157549
0.315098
0.229759
0.905908
0.905908
0.905908
0.905908
0.901532
0.848286
0
0
0.185641
1,950
30
129
65
0.86335
0
0
0.703704
0
0
0
0
0
0
0
0
0
0
null
null
0
0
null
null
0
0
0
0
null
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
10
b6dca2dd128e8ef5b9ef1f817b69d742f7f4a92a
2,293
py
Python
src/genie/libs/parser/iosxe/tests/ShowIpAccessLists/cli/equal/golden_output_customer_expected.py
balmasea/genieparser
d1e71a96dfb081e0a8591707b9d4872decd5d9d3
[ "Apache-2.0" ]
204
2018-06-27T00:55:27.000Z
2022-03-06T21:12:18.000Z
src/genie/libs/parser/iosxe/tests/ShowIpAccessLists/cli/equal/golden_output_customer_expected.py
balmasea/genieparser
d1e71a96dfb081e0a8591707b9d4872decd5d9d3
[ "Apache-2.0" ]
468
2018-06-19T00:33:18.000Z
2022-03-31T23:23:35.000Z
src/genie/libs/parser/iosxe/tests/ShowIpAccessLists/cli/equal/golden_output_customer_expected.py
balmasea/genieparser
d1e71a96dfb081e0a8591707b9d4872decd5d9d3
[ "Apache-2.0" ]
309
2019-01-16T20:21:07.000Z
2022-03-30T12:56:41.000Z
expected_output = { "43":{ "name":"43", "type":"ipv4-acl-type", "acl_type": "standard", "aces":{ "10":{ "name":"10", "actions":{ "forwarding":"permit" }, "matches":{ "l3":{ "ipv4":{ "protocol":"ipv4", "source_network":{ "10.1.0.2 0.0.0.0":{ "source_network":"10.1.0.2 0.0.0.0" } } } } }, "statistics":{ "matched_packets":"1168716" } }, "20":{ "name":"20", "actions":{ "forwarding":"permit" }, "matches":{ "l3":{ "ipv4":{ "protocol":"ipv4", "source_network":{ "10.144.0.9 0.0.0.0":{ "source_network":"10.144.0.9 0.0.0.0" } } } } } }, "30":{ "name":"30", "actions":{ "forwarding":"permit" }, "matches":{ "l3":{ "ipv4":{ "protocol":"ipv4", "source_network":{ "10.70.10.0 0.0.10.255":{ "source_network":"10.70.10.0 0.0.10.255" } } } } } }, "40":{ "name":"40", "actions":{ "forwarding":"permit" }, "matches":{ "l3":{ "ipv4":{ "protocol":"ipv4", "source_network":{ "10.196.0.0 0.0.255.255":{ "source_network":"10.196.0.0 0.0.255.255" } } } } }, "statistics":{ "matched_packets":"8353358" } } } } }
26.356322
68
0.242477
145
2,293
3.751724
0.234483
0.080882
0.077206
0.044118
0.724265
0.724265
0.724265
0.724265
0.724265
0.724265
0
0.162192
0.610118
2,293
87
69
26.356322
0.446309
0
0
0.344828
0
0
0.261116
0
0
0
0
0
0
1
0
false
0
0
0
0
0
0
0
0
null
0
0
0
0
1
1
1
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
f3e3eeff3cacc265ae4091db332558cb80686cf5
146
py
Python
catalyst/contrib/dl/__init__.py
Inkln/catalyst
37ff273a223df3bc70411cd79a79d1b038ba8f9b
[ "Apache-2.0" ]
null
null
null
catalyst/contrib/dl/__init__.py
Inkln/catalyst
37ff273a223df3bc70411cd79a79d1b038ba8f9b
[ "Apache-2.0" ]
null
null
null
catalyst/contrib/dl/__init__.py
Inkln/catalyst
37ff273a223df3bc70411cd79a79d1b038ba8f9b
[ "Apache-2.0" ]
1
2020-12-02T18:42:31.000Z
2020-12-02T18:42:31.000Z
# flake8: noqa from catalyst.contrib.dl.experiment import * from catalyst.contrib.dl.runner import * from catalyst.contrib.dl.callbacks import *
24.333333
44
0.794521
20
146
5.8
0.5
0.310345
0.491379
0.543103
0.465517
0
0
0
0
0
0
0.007692
0.109589
146
5
45
29.2
0.884615
0.082192
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
7
6d0e14d6fb6db7f0ba31ef15f2ad17daeda5e7e5
14,029
py
Python
experience2/profile_call.py
AvaPunksmash/samWorkTask1
3a6302528cd65db69186b59db9af717399e640e1
[ "MIT" ]
null
null
null
experience2/profile_call.py
AvaPunksmash/samWorkTask1
3a6302528cd65db69186b59db9af717399e640e1
[ "MIT" ]
3
2020-03-24T16:58:16.000Z
2021-02-02T22:07:29.000Z
experience2/profile_call.py
GTimothee/samActivities
3a6302528cd65db69186b59db9af717399e640e1
[ "MIT" ]
null
null
null
import timeit, os, csv, time, random nb_repeats = 8 tmpfs_path="/dev/shm/book.txt" ssd_path="./book.txt" hdd_path="/mnt/hdd/book.txt" def setup(filename): """ Setup for rand_python_time """ os.system('sync; echo 3 | sudo tee /proc/sys/vm/drop_caches') file = open(filename, "r") filesize = os.stat(filename).st_size random.seed(0) return file, filesize def rand_python_time_run(number, path): """ Using python's time function and making individual calls """ times=list() for i in range(nb_repeats): file,filesize = setup(path) total_time = 0.0 for j in range(number): seek_dist = random.randint(0, filesize); t=time.time() file.seek(seek_dist) t=time.time()-t total_time+=t total_time/=number times.append(total_time) file.close() return times def rand_python_time(number): """ Using python's time function and making individual calls """ print("tmpfs") times = rand_python_time_run(number, tmpfs_path) for i, t in enumerate(times): out_writer.writerow(["ram", "tmpfs", "rand_python_time", str(i), str(number), "", str(t)]) print("ssd") times = rand_python_time_run(number, ssd_path) for i, t in enumerate(times): out_writer.writerow(["ssd", "ext4", "rand_python_time", str(i), str(number), "", str(t)]) print("hdd") times = rand_python_time_run(number, hdd_path) for i, t in enumerate(times): out_writer.writerow(["hdd", "ext4", "rand_python_time", str(i), str(number), "", str(t)]) def timeit_seeks_run(seek_dist, number, path): """ Run a given number of seek syscall for a given seek distance """ setup = '''import os; \ filename = "''' + path + '''"; \ os.system('sync; echo 3 | sudo tee /proc/sys/vm/drop_caches'); \ file = open(filename, "r")''' stmt = "file.seek( " + str(seek_dist) + " )" return timeit.repeat(setup=setup, stmt=stmt, number=number, repeat=nb_repeats) def timeit_seeks_(seek_dist, number): print("tmpfs") times = timeit_seeks_run(seek_dist, number, tmpfs_path) for i, t in enumerate(times): out_writer.writerow(["ram", "tmpfs", "timeit_seeks_", str(i), str(number), str(seek_dist), str(t)]) print("ssd") times = timeit_seeks_run(seek_dist, number, ssd_path) for i, t in enumerate(times): out_writer.writerow(["ssd", "ext4", "timeit_seeks_", str(i), str(number), str(seek_dist), str(t)]) print("hdd") times = timeit_seeks_run(seek_dist, number, hdd_path) for i, t in enumerate(times): out_writer.writerow(["hdd", "ext4", "timeit_seeks_", str(i), str(number), str(seek_dist), str(t)]) def timeit_random_(number): setup = '''import os, random; \ filename = "''' + tmpfs_path + '''"; \ filesize = os.stat(filename).st_size; \ random.seed(0)''' stmt = '''seek_dist = random.randint(0, filesize)''' times=timeit.repeat(setup=setup, stmt=stmt, number=number, repeat=nb_repeats) print("random") for i, t in enumerate(times): out_writer.writerow(["","", "timeit_random_", str(i), str(number), "", str(t)]) def timeit_seeks_random_run(number,path): setup = '''import os, random; \ filename = "''' + path + '''"; \ os.system('sync; echo 3 | sudo tee /proc/sys/vm/drop_caches'); \ file = open(filename, "r"); \ filesize = os.stat(filename).st_size; \ random.seed(0)''' stmt = '''seek_dist = random.randint(0, filesize); \ file.seek(seek_dist)''' return timeit.repeat(setup=setup, stmt=stmt, number=number, repeat=nb_repeats) def timeit_seeks_random(number): print("tmpfs") times = timeit_seeks_random_run(number, tmpfs_path) for i, t in enumerate(times): out_writer.writerow(["ram", "tmpfs", "timeit_seeks_random", str(i), str(number), "", str(t)]) print("ssd") times = timeit_seeks_random_run(number, ssd_path) for i, t in enumerate(times): out_writer.writerow(["ssd", "ext4", "timeit_seeks_random", str(i), str(number), "", str(t)]) print("hdd") times = timeit_seeks_random_run(number, hdd_path) for i, t in enumerate(times): out_writer.writerow(["hdd", "ext4", "timeit_seeks_random", str(i), str(number), "", str(t)]) def timeit_seek_and_run(seek_dist, number, isread, path): function = 'write("Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet,Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velitNeque porro quisquam est qui dolorem ipsum quia dolor sit amet.")' mode="w" func_name = "write" if isread: function = 'read(10000)' mode="r" func_name = "read" setup = "import os; \ filename ='" + path + "'; \ os.system('sync; echo 3 | sudo tee /proc/sys/vm/drop_caches'); \ file = open(filename, '" + mode + "')" stmt = "file.seek( " + str(seek_dist) + " ); \ file." + function + ";\ file.seek(0);" return timeit.repeat(setup=setup, stmt=stmt, number=number, repeat=nb_repeats) def timeit_seek_and_(seek_dist, number, isread): func_name="write" if isread: func_name="read" print("tmpfs") times = timeit_seek_and_run(seek_dist, number, isread, tmpfs_path) for i, t in enumerate(times): out_writer.writerow(["ram", "tmpfs", "timeit_seek_and_"+func_name, str(i), str(number), str(seek_dist), str(t)]) print("ssd") times = timeit_seek_and_run(seek_dist, number, isread, ssd_path) for i, t in enumerate(times): out_writer.writerow(["ssd", "ext4", "timeit_seek_and_"+func_name, str(i), str(number), str(seek_dist), str(t)]) print("hdd") times = timeit_seek_and_run(seek_dist, number, isread, hdd_path) for i, t in enumerate(times): out_writer.writerow(["hdd", "ext4", "timeit_seek_and_"+func_name, str(i), str(number), str(seek_dist), str(t)]) def bench_read_speed_run(number, nb_bytes, path): function = 'read(' + str(nb_bytes) +')' mode="rb" filesize = os.stat(path).st_size; \ setup = "import os, random; \ filename ='" + path + "'; \ os.system('sync; echo 3 | sudo tee /proc/sys/vm/drop_caches'); \ file = open(filename, '" + mode + "')" stmt = '''seek_dist = random.randint(0, ''' + str(filesize-nb_bytes) + '''); \ file.seek(seek_dist); \ file.''' + function + ''';\ file.seek(0);''' return timeit.repeat(setup=setup, stmt=stmt, number=number, repeat=5) def bench_read_speed(): for nb_bytes in [10000]: print(nb_bytes) for number in [500000, 1000000, 5000000, 10000000]: print(number) print("ssd") times = bench_read_speed_run(number, nb_bytes, '/home/tim/data/bigbrain_40microns.nii.gz') for i, t in enumerate(times): out_writer.writerow(["ssd", "ext4", "bench_read_speed"+str(nb_bytes), str(i), str(number), "", str(t)]) print("hdd") times = bench_read_speed_run(number, nb_bytes, '/mnt/hdd/bigbrain.nii.gz') for i, t in enumerate(times): out_writer.writerow(["hdd", "ext4", "bench_read_speed"+str(nb_bytes), str(i), str(number), "", str(t)]) def run_bench(number): """ Run all functions the one after the other """ print("PYTHON RAND TIME") rand_python_time(number) print("RANDOM") timeit_random_(number) print("RANDOM SEEKS") timeit_seeks_random(number) print("READ") for seek_dist in [5000, 50000, 500000]: print('seek dist :', seek_dist) timeit_seek_and_(seek_dist, number, True) print("WRITE") for seek_dist in [5000, 50000, 500000]: print('seek dist :', seek_dist) timeit_seek_and_(seek_dist, number, False) print("SEEKS") for seek_dist in [0, 5000, 50000, 500000]: print('seek dist :', seek_dist) timeit_seeks_(seek_dist, number) if __name__ == "__main__": csv_file = open("profile_call_py_benchreadspeed_out.csv", "w+") out_writer = csv.writer(csv_file) out_writer.writerow(["hardware_type", "file_system", "function", "iteration", "nb_runs", "seek_distance", "time"]) """print("PYTHON RAND TIME") rand_python_time(1) print("PYTHON RAND TIME") rand_python_time(10) print("PYTHON RAND TIME") rand_python_time(100) run_bench(1000000) run_bench(10000000)""" bench_read_speed()
54.166023
5,521
0.692352
1,986
14,029
4.766365
0.072508
0.09476
0.116628
0.138496
0.878618
0.86087
0.836679
0.810691
0.800655
0.7603
0
0.01209
0.204077
14,029
258
5,522
54.375969
0.835662
0.017321
0
0.391534
0
0.026455
0.527197
0.022306
0
0
0
0
0
1
0.068783
false
0
0.031746
0
0.132275
0.137566
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
6d375d14c44ca7ae3b952cd7ef33b0a721a8a4c7
143
py
Python
estimation/unidimensional/polytomous/__init__.py
eribean/GIRTH
daf22773aa9cd1c819bf732e1061ebf5cc4dc40e
[ "MIT" ]
null
null
null
estimation/unidimensional/polytomous/__init__.py
eribean/GIRTH
daf22773aa9cd1c819bf732e1061ebf5cc4dc40e
[ "MIT" ]
null
null
null
estimation/unidimensional/polytomous/__init__.py
eribean/GIRTH
daf22773aa9cd1c819bf732e1061ebf5cc4dc40e
[ "MIT" ]
null
null
null
from .grm_mml import * from .grm_mml_eap import * from .pcm_mml import * from .gum_mml import * from .grm_jml import * from .pcm_jml import *
20.428571
27
0.741259
25
143
3.96
0.32
0.505051
0.393939
0.323232
0
0
0
0
0
0
0
0
0.174825
143
7
28
20.428571
0.838983
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
611bb5dca0d8dadb245cae3fa20520e68c7f8922
92
py
Python
parameters_8000.py
relidaning/myWeb2py
2dd7d70131a46585bcae29c46b9d5feccd55ad21
[ "BSD-3-Clause" ]
null
null
null
parameters_8000.py
relidaning/myWeb2py
2dd7d70131a46585bcae29c46b9d5feccd55ad21
[ "BSD-3-Clause" ]
null
null
null
parameters_8000.py
relidaning/myWeb2py
2dd7d70131a46585bcae29c46b9d5feccd55ad21
[ "BSD-3-Clause" ]
null
null
null
password="pbkdf2(1000,20,sha512)$919fd9760cde77d0$566dce80dc68eb38dcc6dd93c4e06342dab0af4d"
46
91
0.891304
7
92
11.714286
1
0
0
0
0
0
0
0
0
0
0
0.43956
0.01087
92
1
92
92
0.461538
0
0
0
0
0
0.869565
0.869565
0
0
0
0
0
1
0
false
1
0
0
0
0
1
0
1
null
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
1
1
null
0
0
0
0
0
0
0
1
0
0
0
0
0
8
611efd0810e22bcb5d2a6579514fa4280f622256
3,855
py
Python
decode-encode/base64-tiff-png-jpg-html/main-tiff.py
whitmans-max/python-examples
881a8f23f0eebc76816a0078e19951893f0daaaa
[ "MIT" ]
140
2017-02-21T22:49:04.000Z
2022-03-22T17:51:58.000Z
decode-encode/base64-tiff-png-jpg-html/main-tiff.py
whitmans-max/python-examples
881a8f23f0eebc76816a0078e19951893f0daaaa
[ "MIT" ]
5
2017-12-02T19:55:00.000Z
2021-09-22T23:18:39.000Z
decode-encode/base64-tiff-png-jpg-html/main-tiff.py
whitmans-max/python-examples
881a8f23f0eebc76816a0078e19951893f0daaaa
[ "MIT" ]
79
2017-01-25T10:53:33.000Z
2022-03-11T16:13:57.000Z
#------------------------------------------------------------------------------ # decode from base64 to tiff #------------------------------------------------------------------------------ import base64 html = '<img src="data:image/tiff;base64,SUkqAAgAAAASAP4ABAABAAAAAAAAAAABAwABAAAACgAAAAEBAwABAAAACgAAAAIBAwADAAAA5gAAAAMBAwABAAAAsoAAAAYBAwABAAAAAgAAABEBBAABAAAAgAMAABIBCQABAAAAAQAAABUBAwABAAAAAwAAABYBAwABAAAAKAAAABcBBAABAAAAPwAAABoBBQABAAAA7AAAABsBBQABAAAA9AAAABwBAwABAAAAAQAAACgBAwABAAAAAgAAADIBAgAUAAAA/AAAAD0BAwABAAAAAgAAAGmHBAABAAAAEAEAAF4BAAAIAAgACABIAAAAAQAAAEgAAAABAAAAMjAxOTowNzoyMyAyMTozNDoxOQAGAACQBwAEAAAAMDIyMQGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgCQABAAAAAQAAAAKgCQABAAAACgAAAAOgCQABAAAACgAAAAAAAAAGAAMBAwABAAAABgAAABoBCQABAAAASAAAABsBCQABAAAASAAAACgBCQABAAAAAgAAAAECBAABAAAArAEAAAICBAABAAAA1AEAAAAAAAD/2P/gABBKRklGAAEBAAABAAEAAP/bAEMABQMEBAQDBQQEBAUFBQYHDAgHBwcHDwsLCQwRDxISEQ8RERMWHBcTFBoVEREYIRgaHR0fHx8TFyIkIh4kHB4fHv/bAEMBBQUFBwYHDggIDh4UERQeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHv/AABEIAAoACgMBIgACEQEDEQH/xAAXAAADAQAAAAAAAAAAAAAAAAAABwgJ/8QAIBAAAgICAgMBAQAAAAAAAAAAAgMBBAUGBxEACCETEv/EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwBi60fFuU1XB5beI0a3tWVxGMv2RzeECzk77nALXymDn9LIsE4UkEjIrMJWMH/H4hOfJXsNzHq3Iuy6xhd0cnF4jL2qFJbqVawwEpcS1wTWrJjCgRjszIiKfszMzM+Htlu+6at7CbVhdY2/YMHi1NQ5dLHZJ1ZAG2sprThYFAwRsMzKeuyIyKe5mZ80MoVKtCjXo0ayatSsoUoQlcAtQDHQgIx8EYiIiIj5ER4H/9l4nPv//z8DAwMjIyMDKvgPFgeSQCkIGxnABTGl4ArgsnDFyAwi9eKRRXMYhItmL5p34Gpw+QhTI7J2AOTAPvUA">' data_base64 = html.split('base64,')[1] # remove text before encoded data data_base64 = data_base64[:-2] # remove text after encoded data #data_base64 = 'SUkqAAgAAAASAP4ABAABAAAAAAAAAAABAwABAAAACgAAAAEBAwABAAAACgAAAAIBAwADAAAA5gAAAAMBAwABAAAAsoAAAAYBAwABAAAAAgAAABEBBAABAAAAgAMAABIBCQABAAAAAQAAABUBAwABAAAAAwAAABYBAwABAAAAKAAAABcBBAABAAAAPwAAABoBBQABAAAA7AAAABsBBQABAAAA9AAAABwBAwABAAAAAQAAACgBAwABAAAAAgAAADIBAgAUAAAA/AAAAD0BAwABAAAAAgAAAGmHBAABAAAAEAEAAF4BAAAIAAgACABIAAAAAQAAAEgAAAABAAAAMjAxOTowNzoyMyAyMTozNDoxOQAGAACQBwAEAAAAMDIyMQGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgCQABAAAAAQAAAAKgCQABAAAACgAAAAOgCQABAAAACgAAAAAAAAAGAAMBAwABAAAABgAAABoBCQABAAAASAAAABsBCQABAAAASAAAACgBCQABAAAAAgAAAAECBAABAAAArAEAAAICBAABAAAA1AEAAAAAAAD/2P/gABBKRklGAAEBAAABAAEAAP/bAEMABQMEBAQDBQQEBAUFBQYHDAgHBwcHDwsLCQwRDxISEQ8RERMWHBcTFBoVEREYIRgaHR0fHx8TFyIkIh4kHB4fHv/bAEMBBQUFBwYHDggIDh4UERQeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHv/AABEIAAoACgMBIgACEQEDEQH/xAAXAAADAQAAAAAAAAAAAAAAAAAABwgJ/8QAIBAAAgICAgMBAQAAAAAAAAAAAgMBBAUGBxEACCETEv/EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwBi60fFuU1XB5beI0a3tWVxGMv2RzeECzk77nALXymDn9LIsE4UkEjIrMJWMH/H4hOfJXsNzHq3Iuy6xhd0cnF4jL2qFJbqVawwEpcS1wTWrJjCgRjszIiKfszMzM+Htlu+6at7CbVhdY2/YMHi1NQ5dLHZJ1ZAG2sprThYFAwRsMzKeuyIyKe5mZ80MoVKtCjXo0ayatSsoUoQlcAtQDHQgIx8EYiIiIj5ER4H/9l4nPv//z8DAwMjIyMDKvgPFgeSQCkIGxnABTGl4ArgsnDFyAwi9eKRRXMYhItmL5p34Gpw+QhTI7J2AOTAPvUA' data_base64 = data_base64.encode() # convert string to bytes data = base64.b64decode(data_base64) # decode from base64 (bytes) open('output-image.tiff', 'wb').write(data) # write bytes to file #------------------------------------------------------------------------------ # encode tiff to base64 and embed in html #------------------------------------------------------------------------------ import base64 data = open('image.tiff', 'rb').read() # read bytes from file data_base64 = base64.b64encode(data) # encode to base64 (bytes) data_base64 = data_base64.decode() # convert bytes to string print(data_base64) html = '<img src="data:image/tiff;base64,' + data_base64 + '">' # embed in html open('output-tiff.html', 'w').write(html) # browsers don't display tiff so html can show broken image. # you have to save from page to file and then you can see tiff.
101.447368
1,324
0.833722
189
3,855
16.941799
0.37037
0.0406
0.019988
0.018738
0.817614
0.817614
0.817614
0.817614
0.797626
0.797626
0
0.05423
0.04332
3,855
37
1,325
104.189189
0.813991
0.522438
0
0.142857
0
0.071429
0.771131
0.734358
0
1
0
0
0
1
0
false
0
0.142857
0
0.142857
0.071429
0
0
1
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
1
1
null
1
0
0
0
0
0
0
0
0
0
0
0
0
12
612987e6764f92e72ec790a491cb8f111b6d3e01
12,461
py
Python
tests/test_regular_decorating.py
britodfbr/recursive_decorator
bfbf9c4c3c5af322e16444643bbdc8196f9291b6
[ "MIT" ]
null
null
null
tests/test_regular_decorating.py
britodfbr/recursive_decorator
bfbf9c4c3c5af322e16444643bbdc8196f9291b6
[ "MIT" ]
null
null
null
tests/test_regular_decorating.py
britodfbr/recursive_decorator
bfbf9c4c3c5af322e16444643bbdc8196f9291b6
[ "MIT" ]
null
null
null
"""Validating recursive_decorator doesn't break normal usage of decorator.""" import mock import pytest from recursive_decorator import recursive_decorator from recursive_decorator.utils import DECORATOR_LIST_FIELD_NAME @pytest.fixture() def mock_decorator(): decorator = mock.MagicMock() decorator.__name__ = 'mock_decorator' return decorator @pytest.fixture() def mock_wrapper(): # Set mocking decorator wrapper = mock.MagicMock() wrapper.__name__ = 'wrapper' # Identity function wrapper.side_effect = lambda func: func return wrapper def test_applying_decorator(mock_decorator): mock_decorator.side_effect = lambda func: func @recursive_decorator(mock_decorator) def func_to_decorate(): func_to_decorate.has_been_called = True mock_decorator.assert_called_once() func_to_decorate() assert func_to_decorate.has_been_called is True def test_applying_decorator_with_default_kwargs(mock_decorator): mock_decorator.side_effect = lambda func: func kwdefaults_value = 3 @recursive_decorator(mock_decorator) def func_to_decorate(*, k=kwdefaults_value): func_to_decorate.kwdefaults = k mock_decorator.assert_called_once() func_to_decorate() assert func_to_decorate.kwdefaults == kwdefaults_value def test_applying_decorator_on_function_with_args(mock_decorator): mock_decorator.side_effect = lambda func: func args = (1, "2") @recursive_decorator(mock_decorator) def func_to_decorate(x, y): func_to_decorate.args = (x, y) mock_decorator.assert_called_once() func_to_decorate(*args) assert func_to_decorate.args == args def test_applying_decorator_on_function_with_asterisk_args(mock_decorator): mock_decorator.side_effect = lambda func: func args = (1, "2") @recursive_decorator(mock_decorator) def func_to_decorate(*args): func_to_decorate.args = args mock_decorator.assert_called_once() func_to_decorate(*args) assert func_to_decorate.args == args def test_applying_decorator_on_function_with_kwargs(mock_decorator): mock_decorator.side_effect = lambda func: func func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator) def func_to_decorate(a, c, b, d): func_to_decorate.kwargs = {"a": a, "c": c, "b": b, "d": d} mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_on_function_with_asterisk_kwargs(mock_decorator): mock_decorator.side_effect = lambda func: func func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator) def func_to_decorate(**kwargs): func_to_decorate.kwargs = kwargs mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_args(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper args = (1, 2, 'a', "b") @recursive_decorator(mock_decorator, *args) def func_to_decorate(): func_to_decorate.has_been_called = True mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*args) func_to_decorate() assert func_to_decorate.has_been_called is True def test_applying_decorator_with_args_on_function_with_args(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper decorator_args = (1, 2, 'a', "b") func_args = (6, 7, 'c', "d") @recursive_decorator(mock_decorator, *decorator_args) def func_to_decorate(x, y, z, w): func_to_decorate.args = (x, y, z, w) mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*decorator_args) func_to_decorate(*func_args) assert func_to_decorate.args == func_args def test_applying_decorator_with_args_on_function_with_asterisk_args( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper decorator_args = (1, 2, 'a', "b") func_args = (6, 7, 'c', "d") @recursive_decorator(mock_decorator, *decorator_args) def func_to_decorate(*args): func_to_decorate.args = args mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*decorator_args) func_to_decorate(*func_args) assert func_to_decorate.args == func_args def test_applying_decorator_with_args_on_function_with_kwargs(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper decorator_args = (1, 2, 'a', "b") func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args) def func_to_decorate(a, c, b, d): func_to_decorate.kwargs = {"a": a, "c": c, "b": b, "d": d} mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*decorator_args) func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_args_on_function_with_asterisk_kwargs( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper decorator_args = (1, 2, 'a', "b") func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args) def func_to_decorate(**func_kwargs): func_to_decorate.kwargs = func_kwargs mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*decorator_args) func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_kwargs(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, **kwargs) def func_to_decorate(): func_to_decorate.has_been_called = True mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(**kwargs) func_to_decorate() assert func_to_decorate.has_been_called is True def test_applying_decorator_with_kwargs_on_function_with_args(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper function_args = (1, "2") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, **decorator_kwargs) def func_to_decorate(x, y): func_to_decorate.args = (x, y) mock_decorator.assert_called_once() func_to_decorate(*function_args) assert func_to_decorate.args == function_args def test_applying_decorator_with_kwargs_on_function_with_asterisk_args( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper function_args = (1, "2") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, **decorator_kwargs) def func_to_decorate(*args): func_to_decorate.args = args mock_decorator.assert_called_once() func_to_decorate(*function_args) assert func_to_decorate.args == function_args def test_applying_decorator_with_kwargs_on_function_with_kwargs(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, **decorator_kwargs) def func_to_decorate(a, c, b, d): func_to_decorate.kwargs = {"a": a, "c": c, "b": b, "d": d} mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_kwargs_on_function_with_asterisk_kwargs( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, **decorator_kwargs) def func_to_decorate(**kwargs): func_to_decorate.kwargs = kwargs mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_args_and_kwargs(mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper args = (1, 2, 'a', "b") kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *args, **kwargs) def func_to_decorate(): func_to_decorate.has_been_called = True mock_wrapper.assert_called_once() mock_decorator.assert_called_once_with(*args, **kwargs) func_to_decorate() assert func_to_decorate.has_been_called is True # def test_applying_decorator_with_args_and_kwargs_on_function_with_args( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper function_args = (1, "2") decorator_args = (1, 2, 'a', "b") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args, **decorator_kwargs) def func_to_decorate(x, y): func_to_decorate.args = (x, y) mock_decorator.assert_called_once() func_to_decorate(*function_args) assert func_to_decorate.args == function_args def test_applying_decorator_with_args_and_kwargs_on_function_with_asterisk_args( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper function_args = (1, "2") decorator_args = (1, 2, 'a', "b") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args, **decorator_kwargs) def func_to_decorate(*args): func_to_decorate.args = args mock_decorator.assert_called_once() func_to_decorate(*function_args) assert func_to_decorate.args == function_args def test_applying_decorator_with_args_and_kwargs_on_function_with_kwargs( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} decorator_args = (1, 2, 'a', "b") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args, **decorator_kwargs) def func_to_decorate(a, c, b, d): func_to_decorate.kwargs = {"a": a, "c": c, "b": b, "d": d} mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_applying_decorator_with_args_and_kwargs_on_function_with_asterisk_kwargs( mock_decorator, mock_wrapper): mock_decorator.return_value = mock_wrapper func_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} decorator_args = (1, 2, 'a', "b") decorator_kwargs = {'a': 1, 'c': '1', 'b': 2, 'd': '2'} @recursive_decorator(mock_decorator, *decorator_args, **decorator_kwargs) def func_to_decorate(**kwargs): func_to_decorate.kwargs = kwargs mock_decorator.assert_called_once() func_to_decorate(**func_kwargs) assert func_to_decorate.kwargs == func_kwargs def test_wrapped_value_when_decorator_change_function(mock_decorator): def another_func(): pass mock_decorator.side_effect = lambda func: another_func @recursive_decorator(mock_decorator) def func_to_decorate(): pass func_after_decorating_list = getattr(func_to_decorate, DECORATOR_LIST_FIELD_NAME) assert func_after_decorating_list == ["mock_decorator"] def test_wrapped_value_when_decorator_change_method(mock_decorator): class A: def __init__(self): pass def method(self): pass def another_method(self): pass instance = A() method = instance.method another_method = instance.another_method mock_decorator.side_effect = lambda method: another_method decorated_method = recursive_decorator(mock_decorator)(method) func_after_decorating_list = getattr(decorated_method, DECORATOR_LIST_FIELD_NAME) assert func_after_decorating_list == ["mock_decorator"]
29.32
82
0.694808
1,656
12,461
4.789251
0.047101
0.154079
0.151809
0.0899
0.898247
0.879965
0.869247
0.853612
0.843778
0.827008
0
0.010907
0.197978
12,461
424
83
29.389151
0.78267
0.008988
0
0.766667
0
0
0.016449
0
0
0
0
0
0.188889
1
0.188889
false
0.018519
0.014815
0
0.214815
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
b635a69663e54ad78374bc1361efc4e648b627d7
2,502
py
Python
maze_solver.py
Omair-R/PathFinder
8dfc655c2a06c3722d782736cd128b5d7ec35fdd
[ "MIT" ]
null
null
null
maze_solver.py
Omair-R/PathFinder
8dfc655c2a06c3722d782736cd128b5d7ec35fdd
[ "MIT" ]
null
null
null
maze_solver.py
Omair-R/PathFinder
8dfc655c2a06c3722d782736cd128b5d7ec35fdd
[ "MIT" ]
null
null
null
from util import * import pygame def Dijkstar(grid, clock, display_cost=False): close = [] open = [] current = None grid.partial_reset() if not grid.has_begin or not grid.has_end: return open.append(grid.start_node) while True: idx = find_minimum_g(open) current = open[idx] open.pop(idx) close.append(current) if current.is_end: break if not current.is_begin: current.change_color(colors.gold, display_cost=display_cost) neighbors = find_neighbors(grid, current) for neighbor in neighbors: if neighbor in close or neighbor.is_wall: continue if not neighbor.is_end: neighbor.change_color(colors.coral, display_cost=display_cost) if not (neighbor in open): neighbor.parent = current neighbor.calculate_g(grid) open.append(neighbor) clock.tick(50) pygame.display.flip() while current.parent and len(open) != 0: if not current.is_end: current.change_color(colors.purple, display_cost=display_cost) current = current.parent def A_star(grid, clock, display_cost=False): close = [] open = [] current = None grid.partial_reset() if not grid.has_begin or not grid.has_end: return open.append(grid.start_node) while True: if len(open) == 0: ### print something on screen """ To fix!!!! """ break idx = find_minimum_f(open) current = open[idx] open.pop(idx) close.append(current) if current.is_end: break if not current.is_begin: current.change_color(colors.gold, display_cost=display_cost) neighbors = find_neighbors(grid, current) for neighbor in neighbors: if neighbor in close or neighbor.is_wall: continue if not neighbor.is_end: neighbor.change_color(colors.coral, display_cost=display_cost) if not (neighbor in open): neighbor.parent = current neighbor.calculate_f(grid) open.append(neighbor) clock.tick(50) pygame.display.flip() while current.parent and len(open) != 0: if not current.is_end: current.change_color(colors.purple, display_cost=display_cost) current = current.parent
24.057692
78
0.590727
301
2,502
4.754153
0.215947
0.107617
0.071279
0.092243
0.916841
0.916841
0.916841
0.916841
0.916841
0.916841
0
0.004149
0.325739
2,502
103
79
24.291262
0.844102
0.009992
0
0.848485
0
0
0
0
0
0
0
0
0
1
0.030303
false
0
0.030303
0
0.060606
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
b6432d83ed0fba701247fa23a2c2cd5288aed9d8
68
py
Python
rcnn/symbol/__init__.py
qilei123/MASK_4_RETINA
28eecec985c760b1beeab9d62b54de1ce42aeecc
[ "Apache-2.0" ]
null
null
null
rcnn/symbol/__init__.py
qilei123/MASK_4_RETINA
28eecec985c760b1beeab9d62b54de1ce42aeecc
[ "Apache-2.0" ]
null
null
null
rcnn/symbol/__init__.py
qilei123/MASK_4_RETINA
28eecec985c760b1beeab9d62b54de1ce42aeecc
[ "Apache-2.0" ]
null
null
null
#from symbol_mask_fpn import * from symbol_mask_fpn_dcn_v1 import *
22.666667
36
0.838235
12
68
4.25
0.583333
0.392157
0.54902
0.666667
0
0
0
0
0
0
0
0.016667
0.117647
68
2
37
34
0.833333
0.426471
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
8
b68b4c71a1cf0d5ec8493bf7e3be6c9406fbcbf6
56,576
py
Python
A-star/quad-puzzl.py
SP2LC/procon25-main
7f17dc882c2e33455651e672fca3c486c2f56bde
[ "Apache-2.0" ]
1
2015-04-19T03:56:57.000Z
2015-04-19T03:56:57.000Z
A-star/quad-puzzl.py
SP2LC/procon25-main
7f17dc882c2e33455651e672fca3c486c2f56bde
[ "Apache-2.0" ]
null
null
null
A-star/quad-puzzl.py
SP2LC/procon25-main
7f17dc882c2e33455651e672fca3c486c2f56bde
[ "Apache-2.0" ]
null
null
null
#-*- coding:utf-8 -*- import random import requests from requests.auth import HTTPDigestAuth import json import sys import communication import config import time from copy import deepcopy ALL_COST = 0 def print_matrix(matrix): for i in range(len(matrix)): for j in range(len(matrix[0])): print matrix[i][j] ," ", print "" def make_answer(w,h): arr = make_problem(w,h) for i in range(len(arr)): random.shuffle(arr[i]) arr = transpose(arr) for i in range(len(arr)): random.shuffle(arr[i]) arr = transpose(arr) return arr def transpose(arr2d): #転置した2次元配列を返す result = [] for i in range(len(arr2d[0])): arr = [] for j in range(len(arr2d)): arr.append(arr2d[j][i]) result.append(arr) return result def rotation(matrix): ans_matrix = [] for i in reversed(xrange(len(matrix))): temp = [] for j in reversed(xrange(len(matrix[0]))): temp.append(matrix[i][j]) ans_matrix.append(temp) return ans_matrix def exchange (board, selection_positon, exchange_positon): si,sj = selection_positon ei,ej = exchange_positon temp = board[si][sj] board[si][sj] = board[ei][ej] board[ei][ej] = temp return board def make_problem(w, h): arr = [] for i in range(w): column = [] for j in range(h): column.append((i, j)) arr.append(column) return arr def check_matrix(matrix_A,matrix_B,selection_positon): ok_count = 0 no_count = 0 for i in range(len(matrix_A)): #print "" for j in range(len(matrix_A[0])): if matrix_A[i][j] == matrix_B[i][j]: # print "OK ", ok_count += 1 else: # if selection_positon == (i,j): # print "SL ", # else: # print "FF ", no_count += 1 #print "" #print " 一致マス数",ok_count #print "不一致マス数",no_count return ok_count,no_count def position_up(board,selection_positon,answer_text): #print "want to up", i,j = selection_positon new_board = exchange(board,(i,j),(i-1,j)) new_answer_text = answer_text + "U" new_selection_position = (i-1,j) #print "selection_positon U ",selection_positon," -> ",new_selection_position return new_board,new_selection_position,new_answer_text def position_down(board,selection_positon,answer_text): #print "want to down", i,j = selection_positon new_board = exchange(board,(i,j),(i+1,j)) new_answer_text = answer_text + "D" new_selection_position = (i+1,j) #print "selection_positon D ",selection_positon," -> ",new_selection_position return new_board,new_selection_position,new_answer_text def position_right(board,selection_positon,answer_text): #print "want to right", i,j = selection_positon new_board = exchange(board,(i,j),(i,j+1)) new_answer_text = answer_text + "R" new_selection_position = (i,j+1) #print "selection_positon R ",selection_positon," -> ",new_selection_position return new_board,new_selection_position,new_answer_text def position_left(board,selection_positon,answer_text): #print "want to left", i,j = selection_positon new_board = exchange(board,(i,j),(i,j-1)) new_answer_text = answer_text + "L" new_selection_position = (i,j-1) #print "selection_positon L ",selection_positon," -> ",new_selection_position return new_board,new_selection_position,new_answer_text def search(board,selection): for i in range(len(board)): for j in range(len(board[0])): if board[i][j] == selection : return (i,j) def purpose_position_up(board,selection_positon,answer_text):#purposeの下からスタート board,selection_positon,answer_text = position_right(board,selection_positon,answer_text) board,selection_positon,answer_text = position_up(board,selection_positon,answer_text) board,selection_positon,answer_text = position_up(board,selection_positon,answer_text) board,selection_positon,answer_text = position_left(board,selection_positon,answer_text) board,selection_positon,answer_text = position_down(board,selection_positon,answer_text) return board,selection_positon,answer_text def purpose_position_right(board,selection_positon,answer_text): board,selection_positon,answer_text = position_down(board,selection_positon,answer_text) board,selection_positon,answer_text = position_right(board,selection_positon,answer_text) board,selection_positon,answer_text = position_right(board,selection_positon,answer_text) board,selection_positon,answer_text = position_up(board,selection_positon,answer_text) board,selection_positon,answer_text = position_left(board,selection_positon,answer_text) return board,selection_positon,answer_text def purpose_position_left(board,selection_positon,answer_text): board,selection_positon,answer_text = position_down(board,selection_positon,answer_text) board,selection_positon,answer_text = position_left(board,selection_positon,answer_text) board,selection_positon,answer_text = position_left(board,selection_positon,answer_text) board,selection_positon,answer_text = position_up(board,selection_positon,answer_text) board,selection_positon,answer_text = position_right(board,selection_positon,answer_text) return board,selection_positon,answer_text def encode_answer_format(RLUD_text1,RLUD_text2,selection,first_selection): answer_text = "" if selection == (-1,-1): selection_count = 1 answer_text = str(selection_count) + "\r\n" + "%X%X"%(first_selection[1],first_selection[0]) +"\r\n"+ str(len(RLUD_text1)) +"\r\n"+ RLUD_text1 else: selection_count = 2 answer_text1 = str(selection_count) + "\r\n" + "%X%X"%(first_selection[1],first_selection[0]) +"\r\n"+ str(len(RLUD_text1)) +"\r\n"+ RLUD_text1+"\r\n" answer_text2 = "%X%X"%(selection[1],selection[0]) +"\r\n"+ str(len(RLUD_text2)) + "\r\n"+ RLUD_text2 answer_text = answer_text1+answer_text2 return answer_text def encode_perfect_answer(LRUD_text): ans_LRUD = "" i = 0 while (1): if len(LRUD_text) <= i+1: break text = LRUD_text[i]+LRUD_text[i+1] if text == "LR" or text == "RL" or text == "UD" or text == "DU": i += 1 else: ans_LRUD = ans_LRUD + LRUD_text[i] i+= 1 if i > len(LRUD_text)-2: break ans_LRUD = ans_LRUD + LRUD_text[len(LRUD_text)-1] return ans_LRUD def loop_encode_text(LRUD_text): while (1): old_text = LRUD_text LRUD_text = encode_perfect_answer(LRUD_text) if old_text == LRUD_text: return LRUD_text def transpose_operations(ans_text): print ans_text lines = ans_text.split("\r\n") answer_text = lines[0] lines = lines[1:] for i in range(len(lines)): if i % 3 == 0: # 選択位置 answer_text += "\r\n" + lines[i][1] + lines[i][0] elif i % 3 == 1: # 選択回数 answer_text += "\r\n" + lines[i] else: # 交換手順 answer_text += "\r\n" for j in range(len(lines[i])): ans_text = lines[i] if ans_text[j] == "R": answer_text += "D" elif ans_text[j] == "L": answer_text += "U" elif ans_text[j] == "U": answer_text += "L" elif ans_text[j] == "D": answer_text += "R" return answer_text def rotation_operations(ans_text, matrix): answer_text = "" for i in range(len(ans_text)): if ans_text[i] == "R": answer_text += "L" if ans_text[i] == "L": answer_text += "R" if ans_text[i] == "U": answer_text += "D" if ans_text[i] == "D": answer_text += "U" lines = ans_text.split("\r\n") answer_text = lines[0] lines = lines[1:] for i in range(len(lines)): if i % 3 == 0: # 選択位置 (x, y) = (int(lines[i][0], 16), int(lines[i][1], 16)) answer_text += "\r\n" + "%X%X" % (len(matrix) - 1 - x, len(matrix[0]) - 1 - y) elif i % 3 == 1: # 選択回数 answer_text += "\r\n" + lines[i] else: # 交換手順 answer_text += "\r\n" for j in range(len(lines[i])): ans_text = lines[i] if ans_text[j] == "R": answer_text += "L" elif ans_text[j] == "L": answer_text += "R" elif ans_text[j] == "U": answer_text += "D" elif ans_text[j] == "D": answer_text += "U" return answer_text return answer_text def move(pi,pj,i,j,problem,selection_positon,answer_text,answer): purpose = answer[i][j] purpose_positon = search(problem,purpose) p_to_pp_dis = (pi - purpose_positon[0],pj - purpose_positon[1]) s_to_p_dis = (purpose_positon[0] - selection_positon[0],purpose_positon[1] - selection_positon[1]) #print "目的ピース",purpose,"目的地",(pi,pj),"目的ピースポジション",purpose_positon,"目的ピースから目的地までの距離",p_to_pp_dis #print "s_to_p","選択ピース位置",selection_positon,"選択ピースから目的ピースまでの距離",s_to_p_dis height = len(problem)-1 width = len(problem[0])-1 flg = False#目的ピースの位置判定で排他的になる用 exception = False # すでに目的地に目的ピースがいる場合 if p_to_pp_dis[0] == 0 and p_to_pp_dis[1] == 0: #print "すでに目的地にいる" return (problem,selection_positon,answer_text) #目的ピースの位置判定 if flg == False and purpose_positon[1] == 0 and purpose_positon[0] != height :#目的ピースが左端にあって左下角ではない flg = True if purpose_positon[0] == 0:#目的ピースが左上角にあったとき(このif文に入ることはない) print "入った!すごい!プログラムミスだ!" else :#目的ピースが左端にあったとき if p_to_pp_dis[1] == 0:#真上に行きたい(=目的ピースの下に回りこんで上に上げる) if s_to_p_dis[1] == 0:#目的ピースの真上(真下)に選択ピースがあったとき problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[0] == 0:#選択ピースが目的ピースと同じ高さにあるときにあるとき problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if s_to_p_dis[0] > 0:#選択ピースが目的ピースの上側にある for n in range(abs(s_to_p_dis[0]) + 1): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if s_to_p_dis[0] < 0:#選択ピースが目的ピースの側下にある for n in range(abs(s_to_p_dis[0]) - 1): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if s_to_p_dis[1] == 0:#目的ピースの真上に選択ピースがあった時は右に一つ動かしたので左に一つ動かす problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])):#目的ピースを上に動かす problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) else:#真上以外に行きたいとき if s_to_p_dis[1] == 0:#目的ピースの真上(真下)に選択ピースがあったとき problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[0] > 0:#選択ピースが目的ピースの上側にある for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if s_to_p_dis[0] < 0:#選択ピースが目的ピースの側下にある for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if s_to_p_dis[1] == 0: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])-1): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if flg == False and purpose_positon[1] == width and purpose_positon[0] != height :#目的ピースが右端にあって左角ではない flg = True if purpose_positon[0] == 0:#目的ピースが右上角にあったとき(このif文は入ると思う) if s_to_p_dis[1] == 0:#目的ピースの真下に選択ピースがあったとき problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[1]) - 1 ): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) #ここまでで、目的ピースの左隣にくる problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])-1): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) else:#目的ピースが右端にあったとき loop = abs(s_to_p_dis[1]) if s_to_p_dis[1] == 0:#選択ピースと目的ピースが同じ高さにある problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) loop += 1 else:#揃ったピースを考慮するため for n in range(abs(s_to_p_dis[1])-1): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[0] < 0: for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if s_to_p_dis[0] > 0: for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])-1): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if flg == False and purpose_positon[0] == height : #目的ピースが下端にある if p_to_pp_dis[1] == 0:#真上に行きたい(=目的ピースの下に回りこんで上に上げる) flg = True if s_to_p_dis[0] == 0:#目的ピースと選択ピースが同じ高さにあるとき problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if s_to_p_dis[1] > 0:#目的ピースが選択ピースの右側にあるとき for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[1] < 0:#目的ピースが選択ピースの左側にあるとき for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if s_to_p_dis[0] == 0: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0]) - 1): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) else: if purpose_positon[1] == 0:#目的ピースが左下角 flg = True if s_to_p_dis[1] == 0:#目的ピースの上に選択ピースがある problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if s_to_p_dis[1] == 0: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if abs(p_to_pp_dis[1] ) - 1 != 0:#目的地が上じゃないとき problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1]) - 1): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0]) - 1): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if purpose_positon[1] == width:#目的ピースが右下角 flg = True if s_to_p_dis[1] == 0:#目的ピースの上に選択ピースがある problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if s_to_p_dis[1] == 0: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if abs(p_to_pp_dis[1] ) - 1 != 0:#目的地が上じゃないとき problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1]) - 1): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0]) - 1): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if flg == False:#普通に下端だったとき flg = True if s_to_p_dis[1] == 0:#目的ピースの真上に選択ピースがあったとき for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if p_to_pp_dis[1] < 0: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0]) - 1): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) else: loop = abs(s_to_p_dis[0]) if selection_positon[0] == pi and pi < height-1: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) loop -= 1 if s_to_p_dis[0] == 0:#目的ピースと選択ピースが同じ高さにあるとき problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if s_to_p_dis[1] < 0:#目的ピースが選択ピースの右側にあるとき for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if s_to_p_dis[1] > 0:#目的ピースが選択ピースの左側にあるとき for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[0] == 0: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) else: for n in range(loop): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if p_to_pp_dis[1] < 0:#目的ピースが左側に行きたいとき problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0:#目的ピースが右側に行きたいとき problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0]) - 1):#目的ピースを上に上げる problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) #例外処理 if flg == False and s_to_p_dis[0] == 0 and ((s_to_p_dis[1] < 0 and p_to_pp_dis[1] > 0) or (s_to_p_dis[1] > 0 and p_to_pp_dis[1] < 0)):#選択ピースと目的ピースの行きたい方向がぶつかったとき flg = True if s_to_p_dis[1] < 0 and p_to_pp_dis[1] > 0:#選択ピースが右にある かつ 目的ピースが右に行きたい for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1]) - 1): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[1] > 0 and p_to_pp_dis[1] < 0:#選択ピースが左にある かつ 目的ピースが左に行きたい for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1]) - 1): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if flg == False and s_to_p_dis[1] == 0 and s_to_p_dis[0] > 0 and p_to_pp_dis[0] < 0: #縦にぶつかったとき flg = True if p_to_pp_dis[1] == 0: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])+1): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0:#目的ピースは右に行きたい #print problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])-1): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if p_to_pp_dis[1] < 0:#目的ピースは左に行きたい problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[1])-1): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if flg == False:#基本的にこれ 左・右・下端でなく、特殊条件でもない right = False left = False loop = 0 if selection_positon[0] == pi and s_to_p_dis[0] != 0: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) exception = True if abs(s_to_p_dis[0]) - 1 == 0: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) s_to_p_dis = (purpose_positon[0] - selection_positon[0],purpose_positon[1] - selection_positon[1]) if s_to_p_dis[1] < 0:#選択ピースは目的ピースの右側にある right = True if p_to_pp_dis[1] > 0:#目的ピースは右に行きたい loop = abs(s_to_p_dis[1]) + 1 if p_to_pp_dis[1] < 0:#目的ピースは左に行きたい loop = abs(s_to_p_dis[1]) - 1 for n in range(loop): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if s_to_p_dis[1] > 0:#選択ピースは目的ピースの左側にある left = True if p_to_pp_dis[1] > 0:#目的ピースは右に行きたい loop = abs(s_to_p_dis[1]) - 1 if p_to_pp_dis[1] < 0:#目的ピースは左に行きたい loop = abs(s_to_p_dis[1]) + 1 for n in range(loop): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if s_to_p_dis[0] == 0 :#同じ高さに選択ピースと目的ピースがある if p_to_pp_dis[1] == 0:#目的地が真上だったとき problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if right: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if left: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) else:#目的地は真上ではない if right:#選択ピースは目的ピースの右側にある for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if left:#選択ピースは目的ピースの左側にある for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if s_to_p_dis[0] > 0:#選択ピースは目的ピースの上側にある if exception == True: for n in range(abs(s_to_p_dis[0])-1): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) else: for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0: for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if p_to_pp_dis[1] < 0: for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if p_to_pp_dis[1] == 0:#真上に行きたい problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if left: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if right: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) if s_to_p_dis[0] < 0:#選択ピースは目的ピースの下側にある if s_to_p_dis[1] == 0:#同じ幅に選択ピースと目的ピースがある if p_to_pp_dis[1] < 0: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) for n in range(abs(s_to_p_dis[0])): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) if p_to_pp_dis[1] < 0:#目的ピースは左に行きたい for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) if p_to_pp_dis[1] > 0:#目的ピースは右に行きたい for n in range(abs(p_to_pp_dis[1])): problem,selection_positon,answer_text = purpose_position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if p_to_pp_dis[1] == 0:#真上に行きたい problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if left: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if right: for n in range(abs(s_to_p_dis[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) #目的ピースは上に行きたい for n in range(abs(p_to_pp_dis[0])): problem,selection_positon,answer_text = purpose_position_up(problem,selection_positon,answer_text) return (problem,selection_positon,answer_text) def puzzle(problem, answer): answer_text = "" #print "answer" #print_matrix(answer) #print "problem" #print_matrix(problem) selection = answer[len(answer)-1][len(answer[0])-1] selection_positon = search(problem,selection) static_first_selection_positon = selection_positon dummy,dummy= check_matrix(answer,problem,selection_positon) #print "selection\n",selection #for i in range(len(problem)): for i in range(len(problem)-2): #for j in range(len(problem[0])): for j in range(len(problem[0])-2): if answer[i][j] != problem[i][j]: problem,selection_positon,answer_text = move(i,j,i,j,problem,selection_positon,answer_text,answer) #print "" #dummy,dummy= check_matrix(answer,problem,selection_positon) #if i == 14 and j == 2: # print "break" # return answer_text #ここから車庫入れ処理 #print "後ろ2つ ---------------------------------------------------------------" if selection_positon[0] == i: #print "選択ピースの位置が悪い" problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) #print "answer" #print_matrix(answer) if answer[i] != problem[i]: problem,selection_positon,answer_text = move(i,len(problem[0])-2,i,len(problem[0])-1,problem,selection_positon,answer_text,answer) #print "problem" #print_matrix(problem) dummy,dummy = check_matrix(answer,problem,selection_positon) #例外処理 #print "後入れ-----------------------------------------------------------------" if problem[i][len(problem[0])-1] == answer[i][len(problem[0])-2] :#or problem[i+1][len(problem)-1] == answer[i][len(problem)-2]: if selection_positon[1] != len(problem[0])-2: if selection_positon[1] == len(problem[0])-1: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) else: for n in range(len(problem[0])-2 - selection_positon[1]): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if selection_positon[0] != i: for n in range(i - selection_positon[0]): problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) dummy,dummy = check_matrix(answer,problem,selection_positon) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) else: if selection_positon[0] == i: #print "選択ピースの位置が悪い" problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) #print "test" problem,selection_positon,answer_text = move(i+1,len(problem[0])-2,i,len(problem[0])-2,problem,selection_positon,answer_text,answer) #print "test" if (selection_positon[0] == i+1 and selection_positon[1] == len(problem[0]) -3) or (selection_positon[0] == i+1 and selection_positon[1] == len(problem[0]) -1) or (selection_positon[0] == i+2 and selection_positon[1] == len(problem[0]) -2) : if selection_positon[0] == i+1 and selection_positon[1] == len(problem[0]) -3: #print "パターン1" problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if selection_positon[0] == i+1 and selection_positon[1] == len(problem[0]) -1: #print "パターン2" problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if selection_positon[0] == i+2 and selection_positon[1] == len(problem[0]) -2: #print "パターン3" problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) else: #print "OKKKKKKKKKKK" if i + 1 == selection_positon[0]: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) if selection_positon[1] < len(problem[0])-2: for n in range(abs(selection_positon[1] - (len(problem[0])-2))): problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) if selection_positon[1] > len(problem[0])-2: problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) #print "パターン3" problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) #print i,"行目終わり!!*******************************************************" #print "answer" #print_matrix(answer) #print "problem" #print_matrix(problem) #dummy,dummy = check_matrix(answer,problem,selection_positon) #print "*****************************************************************" #ラスト2段処理開始 #print "ラスト2段処理!!!!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" for j in range(len(problem[0])-2): #print "answer" #print_matrix(answer) #print "problem" #print_matrix(problem) #dummy,dummy= check_matrix(answer,problem,selection_positon) i = len(problem)-2 #print "i = ",i,"j = ",j problem,selection_positon,answer_text = move(i,j,i+1,j,problem,selection_positon,answer_text,answer) #dummy,dummy= check_matrix(answer,problem,selection_positon) #print "problem" #print_matrix(problem) ##print "selection",selection #print "selection_positon",selection_positon if selection_positon == (i+1,j): #print "選択ピースの位置が面倒" problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) else:#奇跡に等しい #print "奇跡に等しい神配置" if abs(selection_positon[0] - i) == 1: problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) for n in range(abs(j+1 - selection_positon[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) #print "answer" #print_matrix(answer) #print "problem" #print_matrix(problem) #dummy,dummy= check_matrix(answer,problem,selection_positon) if problem[i+1][j] == answer[i][j]: #print "めんどくさいパターン2" problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) else: problem,selection_positon,answer_text = move(i,j+1,i,j,problem,selection_positon,answer_text,answer) #if i == 14 and j == 2: # dummy,dummy= check_matrix(answer,problem,selection_positon) # break #print "problem" #print_matrix(problem) if abs(selection_positon[0] - i) == 0: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) for n in range(abs(j - selection_positon[1])): problem,selection_positon,answer_text = position_left(problem,selection_positon,answer_text) #print "車庫入れver2" problem,selection_positon,answer_text = position_up(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) #print "answer" #print_matrix(answer) #print "problem" #print_matrix(problem) #dummy,dummy = check_matrix(answer,problem,selection_positon) #check_matrix(answer,problem,selection_positon) flg = False #print "右下4マス処理================================================================================" i = len(problem)-1 j = len(problem[0])-1 count = 0 selection_count = 1 answer_text2 = "" if problem[i][j] == answer[i][j]: count += 1 if problem[i][j-1] == answer[i][j-1]: count += 1 if problem[i-1][j] == answer[i-1][j]: count += 1 static_selection_positon = (-1,-1) #木の下のどれか if count == 0: #print "counte = 3" if problem[i-1][j] == answer[i-1][j-1] and flg == False: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) selection_positon = (i-1 ,j-1) #print selection_positon selection_count += 1 static_selection_positon = selection_positon problem,selection_positon,answer_text2 = position_right(problem,selection_positon,answer_text2) flg = True if problem[i][j-1] == answer[i-1][j-1] and flg == False: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) selection_positon = (i-1 ,j-1) selection_count += 1 static_selection_positon = selection_positon problem,selection_positon,answer_text2 = position_down(problem,selection_positon,answer_text2) flg = True if problem[i][j] == answer[i-1][j-1] and flg == False: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) selection_positon = (i,j-1) selection_count += 1 static_selection_positon = selection_positon problem,selection_positon,answer_text2 = position_up(problem,selection_positon,answer_text2) problem,selection_positon,answer_text2 = position_right(problem,selection_positon,answer_text2) flg = True if count == 1: if problem[i][j-1] == answer[i][j-1] and flg == False: problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) flg = True if problem[i-1][j] == answer[i-1][j] and flg == False: problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) flg = True if count == 2: #print "count = 2" problem,selection_positon,answer_text = position_right(problem,selection_positon,answer_text) problem,selection_positon,answer_text = position_down(problem,selection_positon,answer_text) selection_positon = (i-1,j) #print selection_positon selection_count += 1 static_selection_positon = selection_positon problem,selection_positon,answer_text2 = position_left(problem,selection_positon,answer_text2) print "表示テスト" print "selection_positon",selection_positon print "\nlast board" print_matrix(problem) print "交換回数",len(answer_text) dummy,no_count = check_matrix(answer,problem,selection_positon) #print answer_text answer_text = loop_encode_text(answer_text) ALL_COST = selection_count*SELECTON_RATE + (len(answer_text)+len(answer_text2))*EXCHANGE_RATE encode_text = encode_answer_format(answer_text,answer_text2,static_selection_positon,static_first_selection_positon) #print answer_text return encode_text def calculation_cost_from_string(answer_string): cost = 0 split_string = answer_string.split("\r\n") cost += int(split_string[0]) * SELECTON_RATE split_string.pop(0) for line in range(0,len(split_string),3): cost += int(split_string[line+1]) * EXCHANGE_RATE return cost def solve(sortedImages, splitColumns, splitRows, limit, sel_rate, exc_rate): global LIMIT_SELECTION, SELECTON_RATE, EXCHANGE_RATE, distance_table,answer_text,ALL_COST LIMIT_SELECTION = limit SELECTON_RATE = sel_rate EXCHANGE_RATE = exc_rate problem = transpose(make_problem(splitColumns, splitRows)) answer = transpose(sortedImages) U_text = puzzle(deepcopy(problem),answer) L_text = transpose_operations(puzzle(transpose(deepcopy(problem)),transpose(answer))) D_text = rotation_operations(puzzle(rotation(deepcopy(problem)),rotation(answer)), transpose(answer)) R_text = transpose_operations( rotation_operations( puzzle(transpose(rotation(deepcopy(problem))),transpose(rotation(answer))), answer ) ) #print "U_text","\n",U_text #print "L_text","\n",L_text #print "D_text","\n",D_text #print "R_text","\n",R_text return min([U_text, L_text, D_text, R_text], key=calculation_cost_from_string) #main master = "" if len(sys.argv) == 2: master = sys.argv[1] else: master = config.master para = communication.get_problem(master) ans_str = solve(para['answer'], para['columns'], para['rows'], para['lim_select'], para['selection_rate'], para['exchange_rate']) communication.post(master, ans_str)
55.196098
257
0.651902
6,966
56,576
4.972438
0.037611
0.29101
0.344881
0.400081
0.859028
0.843958
0.828339
0.809487
0.791241
0.772591
0
0.012359
0.250619
56,576
1,024
258
55.25
0.804585
0.075103
0
0.69359
0
0
0.004488
0
0.001282
0
0
0
0
0
null
null
0
0.011538
null
null
0.012821
0
0
0
null
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
10
b698a84c99b4ec1408daa921c7d5839d76684920
195
py
Python
com/LimePencil/Q7569/_.py
LimePencil/baekjoonProblems
61eeeeb875585d165d9e39ecdb3d905b4ba6aa87
[ "MIT" ]
2
2021-07-17T13:05:42.000Z
2021-09-12T09:14:24.000Z
com/LimePencil/Q7569/_.py
LimePencil/baekjoonProblems
61eeeeb875585d165d9e39ecdb3d905b4ba6aa87
[ "MIT" ]
null
null
null
com/LimePencil/Q7569/_.py
LimePencil/baekjoonProblems
61eeeeb875585d165d9e39ecdb3d905b4ba6aa87
[ "MIT" ]
null
null
null
import sys # int(sys.stdin.readline().rstrip("\n")) # list(map(int,sys.stdin.readline().rstrip("\n").split(" "))) # t= int(sys.stdin.readline().rstrip("\n")) # for _ in range(t): # print()
21.666667
61
0.6
29
195
4
0.517241
0.155172
0.284483
0.491379
0.672414
0.672414
0
0
0
0
0
0
0.117949
195
9
62
21.666667
0.674419
0.876923
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
1
1
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
1
0
1
0
0
8
b6a67c21c4bab9ba40405cf3986f5f0abad02163
6,034
py
Python
tests/test_generic_cl_scenario.py
lebrice/avalanche
fe7e1e664ab20697343495fbe1328a20215feffb
[ "MIT" ]
3
2021-09-20T11:43:25.000Z
2022-03-31T09:04:34.000Z
tests/test_generic_cl_scenario.py
lebrice/avalanche
fe7e1e664ab20697343495fbe1328a20215feffb
[ "MIT" ]
null
null
null
tests/test_generic_cl_scenario.py
lebrice/avalanche
fe7e1e664ab20697343495fbe1328a20215feffb
[ "MIT" ]
null
null
null
import unittest import torch from avalanche.benchmarks import dataset_benchmark, Experience, \ GenericExperience from avalanche.benchmarks.utils import AvalancheTensorDataset class GenericCLScenarioTests(unittest.TestCase): def test_classes_in_exp(self): train_exps = [] tensor_x = torch.rand(200, 3, 28, 28) tensor_y = torch.randint(0, 70, (200,)) tensor_t = torch.randint(0, 5, (200,)) train_exps.append(AvalancheTensorDataset( tensor_x, tensor_y, task_labels=tensor_t)) tensor_x = torch.rand(200, 3, 28, 28) tensor_y = torch.randint(0, 100, (200,)) tensor_t = torch.randint(0, 5, (200,)) train_exps.append(AvalancheTensorDataset( tensor_x, tensor_y, task_labels=tensor_t)) test_exps = [] test_x = torch.rand(200, 3, 28, 28) test_y = torch.randint(100, 200, (200,)) test_t = torch.randint(0, 5, (200,)) test_exps.append(AvalancheTensorDataset( test_x, test_y, task_labels=test_t)) other_stream_exps = [] other_x = torch.rand(200, 3, 28, 28) other_y = torch.randint(400, 600, (200,)) other_t = torch.randint(0, 5, (200,)) other_stream_exps.append(AvalancheTensorDataset( other_x, other_y, task_labels=other_t)) benchmark_instance = dataset_benchmark( train_datasets=train_exps, test_datasets=test_exps, other_streams_datasets={'other': other_stream_exps}) train_0_classes = benchmark_instance.classes_in_experience['train'][0] train_1_classes = benchmark_instance.classes_in_experience['train'][1] train_0_classes_min = min(train_0_classes) train_1_classes_min = min(train_1_classes) train_0_classes_max = max(train_0_classes) train_1_classes_max = max(train_1_classes) self.assertGreaterEqual(train_0_classes_min, 0) self.assertLess(train_0_classes_max, 70) self.assertGreaterEqual(train_1_classes_min, 0) self.assertLess(train_1_classes_max, 100) # Test deprecated behavior train_0_classes = benchmark_instance.classes_in_experience[0] train_1_classes = benchmark_instance.classes_in_experience[1] train_0_classes_min = min(train_0_classes) train_1_classes_min = min(train_1_classes) train_0_classes_max = max(train_0_classes) train_1_classes_max = max(train_1_classes) self.assertGreaterEqual(train_0_classes_min, 0) self.assertLess(train_0_classes_max, 70) self.assertGreaterEqual(train_1_classes_min, 0) self.assertLess(train_1_classes_max, 100) # End test deprecated behavior test_0_classes = benchmark_instance.classes_in_experience['test'][0] test_0_classes_min = min(test_0_classes) test_0_classes_max = max(test_0_classes) self.assertGreaterEqual(test_0_classes_min, 100) self.assertLess(test_0_classes_max, 200) other_0_classes = benchmark_instance.classes_in_experience['other'][0] other_0_classes_min = min(other_0_classes) other_0_classes_max = max(other_0_classes) self.assertGreaterEqual(other_0_classes_min, 400) self.assertLess(other_0_classes_max, 600) def test_classes_in_this_experience(self): train_exps = [] tensor_x = torch.rand(200, 3, 28, 28) tensor_y = torch.randint(0, 70, (200,)) tensor_t = torch.randint(0, 5, (200,)) train_exps.append(AvalancheTensorDataset( tensor_x, tensor_y, task_labels=tensor_t)) tensor_x = torch.rand(200, 3, 28, 28) tensor_y = torch.randint(0, 100, (200,)) tensor_t = torch.randint(0, 5, (200,)) train_exps.append(AvalancheTensorDataset( tensor_x, tensor_y, task_labels=tensor_t)) test_exps = [] test_x = torch.rand(200, 3, 28, 28) test_y = torch.randint(100, 200, (200,)) test_t = torch.randint(0, 5, (200,)) test_exps.append(AvalancheTensorDataset( test_x, test_y, task_labels=test_t)) other_stream_exps = [] other_x = torch.rand(200, 3, 28, 28) other_y = torch.randint(400, 600, (200,)) other_t = torch.randint(0, 5, (200,)) other_stream_exps.append(AvalancheTensorDataset( other_x, other_y, task_labels=other_t)) benchmark_instance = dataset_benchmark( train_datasets=train_exps, test_datasets=test_exps, other_streams_datasets={'other': other_stream_exps}) train_exp_0: GenericExperience = benchmark_instance.train_stream[0] train_exp_1: GenericExperience = benchmark_instance.train_stream[1] train_0_classes = train_exp_0.classes_in_this_experience train_1_classes = train_exp_1.classes_in_this_experience train_0_classes_min = min(train_0_classes) train_1_classes_min = min(train_1_classes) train_0_classes_max = max(train_0_classes) train_1_classes_max = max(train_1_classes) self.assertGreaterEqual(train_0_classes_min, 0) self.assertLess(train_0_classes_max, 70) self.assertGreaterEqual(train_1_classes_min, 0) self.assertLess(train_1_classes_max, 100) test_exp_0: GenericExperience = benchmark_instance.test_stream[0] test_0_classes = test_exp_0.classes_in_this_experience test_0_classes_min = min(test_0_classes) test_0_classes_max = max(test_0_classes) self.assertGreaterEqual(test_0_classes_min, 100) self.assertLess(test_0_classes_max, 200) other_exp_0: GenericExperience = benchmark_instance.other_stream[0] other_0_classes = other_exp_0.classes_in_this_experience other_0_classes_min = min(other_0_classes) other_0_classes_max = max(other_0_classes) self.assertGreaterEqual(other_0_classes_min, 400) self.assertLess(other_0_classes_max, 600) if __name__ == '__main__': unittest.main()
41.613793
78
0.686609
807
6,034
4.707559
0.071871
0.109503
0.071861
0.027376
0.887339
0.83522
0.813898
0.788102
0.763622
0.737299
0
0.063821
0.223566
6,034
144
79
41.902778
0.747065
0.008784
0
0.79661
0
0
0.006189
0
0
0
0
0
0.169492
1
0.016949
false
0
0.033898
0
0.059322
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
1e3dc135435acbe988eeff018f57db4fb9f7538b
3,208
py
Python
tests/test_srtm.py
bilgelm/kineticmodel
1060f7bb3a140d3dac3679d88ab997084e5de8c7
[ "MIT" ]
4
2017-10-23T08:00:50.000Z
2018-08-07T23:15:01.000Z
tests/test_srtm.py
bilgelm/kineticmodel
1060f7bb3a140d3dac3679d88ab997084e5de8c7
[ "MIT" ]
null
null
null
tests/test_srtm.py
bilgelm/kineticmodel
1060f7bb3a140d3dac3679d88ab997084e5de8c7
[ "MIT" ]
3
2017-11-09T13:45:36.000Z
2021-11-05T12:29:22.000Z
from kineticmodel import SRTM_Zhou2003, SRTM_Lammertsma1996, SRTM_Gunn1997 from .generate_test_data import generate_fakeTAC_SRTM import unittest from ddt import ddt, data, unpack @ddt class TestSRTM(unittest.TestCase): iters = [(BP, R1, startActivity) for BP in [0.2, 0.5, 0.8] \ for R1 in [1.0, 0.7, 1.3] \ for startActivity in ['flat','increasing']] @unpack @data(*iters) def test_srtm_zhou2003_fit(self, BP, R1, startActivity): self.t, self.dt, self.TAC, self.refTAC = generate_fakeTAC_SRTM(BP, R1) self.model = SRTM_Zhou2003(self.t, self.dt, self.TAC, self.refTAC, startActivity=startActivity) print('\nFitting SRTM_Zhou2003 with %s start activity' % startActivity) self.model.fit() print('True BP = %.6f; estimated BP = %.6f; percent error = %.1E' % \ (BP, self.model.results['BP'], 100*abs(BP-self.model.results['BP'])/BP)) print('True R1 = %.6f; estimated R1 = %.6f; percent error = %.1E' % \ (R1, self.model.results['R1'], 100*abs(R1-self.model.results['R1'])/R1)) self.assertAlmostEqual(BP, self.model.results['BP'], delta=5e-3) self.assertAlmostEqual(R1, self.model.results['R1'], delta=5e-2) @unpack @data(*iters) def test_srtm_lammertsma(self, BP, R1, startActivity): self.t, self.dt, self.TAC, self.refTAC = generate_fakeTAC_SRTM(BP, R1) self.model = SRTM_Lammertsma1996(self.t, self.dt, self.TAC, self.refTAC, startActivity=startActivity) print('\nFitting SRTM_Lammertsma1996 with %s start activity' % startActivity) self.model.fit() print('True BP = %.6f; estimated BP = %.6f; percent error = %.1E' % \ (BP, self.model.results['BP'], 100*abs(BP-self.model.results['BP'])/BP)) print('True R1 = %.6f; estimated R1 = %.6f; percent error = %.1E' % \ (R1, self.model.results['R1'], 100*abs(R1-self.model.results['R1'])/R1)) self.assertAlmostEqual(BP, self.model.results['BP'], delta=5e-2) self.assertAlmostEqual(R1, self.model.results['R1'], delta=5e-1) @unpack @data(*iters) def test_srtm_gunn(self, BP, R1, startActivity): self.t, self.dt, self.TAC, self.refTAC = generate_fakeTAC_SRTM(BP, R1) self.model = SRTM_Gunn1997(self.t, self.dt, self.TAC, self.refTAC, startActivity=startActivity) print('\nFitting SRTM_Gunn1997 with %s start activity' % startActivity) self.model.fit() print('True BP = %.6f; estimated BP = %.6f; percent error = %.1E' % \ (BP, self.model.results['BP'], 100*abs(BP-self.model.results['BP'])/BP)) print('True R1 = %.6f; estimated R1 = %.6f; percent error = %.1E' % \ (R1, self.model.results['R1'], 100*abs(R1-self.model.results['R1'])/R1)) self.assertAlmostEqual(BP, self.model.results['BP'], delta=5e-1) self.assertAlmostEqual(R1, self.model.results['R1'], delta=7e-1)
47.176471
85
0.582606
406
3,208
4.539409
0.150246
0.1172
0.156267
0.0879
0.807922
0.807922
0.7656
0.7656
0.74064
0.688551
0
0.057374
0.266521
3,208
67
86
47.880597
0.725882
0
0
0.578947
1
0
0.167082
0
0
0
0
0
0.105263
1
0.052632
false
0
0.070175
0
0.157895
0.157895
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7
1eb6f6a1b08d5259fa9e59e2e067497b2ba09a9f
9,049
py
Python
samurai/reparameterize.py
jlustigy/samurai
ed46e45600956581c94ae44d820e06c35c464962
[ "MIT" ]
1
2021-01-05T07:27:40.000Z
2021-01-05T07:27:40.000Z
samurai/reparameterize.py
jlustigy/samurai
ed46e45600956581c94ae44d820e06c35c464962
[ "MIT" ]
null
null
null
samurai/reparameterize.py
jlustigy/samurai
ed46e45600956581c94ae44d820e06c35c464962
[ "MIT" ]
null
null
null
import numpy as np #--------------------------------------------------- def transform_Y2X(Y_array, n_type, n_band, n_slice, flatten=False): Y_array = np.maximum(Y_array, -10) Y_array = np.minimum(Y_array, 10) # 'albedo' part Y_albd_kj_flat = Y_array[0:n_type*n_band] X_albd_kj_flat = np.exp( Y_albd_kj_flat )/( 1 + np.exp( Y_albd_kj_flat ) ) # 'area fraction' part Y_area_lk = Y_array[n_type*n_band:n_type*n_band+n_slice*(n_type-1)].reshape([n_slice, n_type-1]) expY_area_lk = np.exp( Y_area_lk ) expYY_area_lk = 1./( 1 + expY_area_lk ) cumprodY_area_lk = np.cumprod( expYY_area_lk, axis=1 ) X_area_lk = expY_area_lk * cumprodY_area_lk # print '1. X_area_lk', X_area_lk X_area_lk = np.c_[X_area_lk, 1. - np.sum( X_area_lk, axis=1 )] X_area_lk_flat = X_area_lk.flatten() # print '2. X_area_lk', X_area_lk if flatten : X_array = np.r_[ X_albd_kj_flat, X_area_lk_flat ] return X_array else : X_albd_kj = X_albd_kj_flat.reshape([ n_type, n_band ]) return X_albd_kj, X_area_lk #--------------------------------------------------- def transform_X2Y(X_albd_kj, X_area_lk): n_slice = len( X_area_lk ) n_type = len( X_albd_kj ) # 'albedo' part Y_albd_kj = np.log(X_albd_kj) - np.log(1.-X_albd_kj) # 'area' part sumX_area_lk = np.cumsum( X_area_lk, axis=1 ) Y_area_lk = np.log( X_area_lk[:,:-1] / ( 1. - sumX_area_lk[:,:-1] ) ) return np.concatenate([Y_albd_kj.flatten(), Y_area_lk.flatten()]) #--------------------------------------------------- def transform_Y2X_atmosphere(Y_array, n_type, n_band, n_slice, use_grey = False, use_global = False, flatten=False): """ Transform state vector back into physical parameters """ if (not use_grey) and (not use_global): # original model # 'albedo' part Y_albd_kj_flat = Y_array[0:n_type*n_band] X_albd_kj_flat = np.exp( Y_albd_kj_flat )/( 1 + np.exp( Y_albd_kj_flat ) ) # 'area fraction' part Y_area_lk = Y_array[n_type*n_band:n_type*n_band+n_slice*(n_type-1)].reshape([n_slice, n_type-1]) expY_area_lk = np.exp( Y_area_lk ) expYY_area_lk = 1./( 1 + expY_area_lk ) cumprodY_area_lk = np.cumprod( expYY_area_lk, axis=1 ) X_area_lk = expY_area_lk * cumprodY_area_lk X_area_lk = np.c_[X_area_lk, 1. - np.sum( X_area_lk, axis=1 )] X_area_lk_flat = X_area_lk.flatten() elif use_grey and (not use_global): # 'albedo' part Y_albd_kj_flat = Y_array[0:(n_type-1)*n_band] X_albd_kj_flat = np.exp( Y_albd_kj_flat )/( 1 + np.exp( Y_albd_kj_flat ) ) # Treat grey albedo Y_albd_grey = Y_array[-1] X_albd_grey = np.exp( Y_albd_grey )/( 1 + np.exp( Y_albd_grey ) ) X_albd_kj_flat = np.hstack([X_albd_kj_flat, X_albd_grey * np.ones(n_band)]) # 'area fraction' part Y_area_lk = Y_array[(n_type-1)*n_band:(n_type-1)*n_band+n_slice*(n_type-1)].reshape([n_slice, n_type-1]) expY_area_lk = np.exp( Y_area_lk ) expYY_area_lk = 1./( 1 + expY_area_lk ) cumprodY_area_lk = np.cumprod( expYY_area_lk, axis=1 ) X_area_lk = expY_area_lk * cumprodY_area_lk X_area_lk = np.c_[X_area_lk, 1. - np.sum( X_area_lk, axis=1 )] X_area_lk_flat = X_area_lk.flatten() elif use_global and (not use_grey): # 'albedo' part Y_albd_kj_flat = Y_array[0:n_type*n_band] X_albd_kj_flat = np.exp( Y_albd_kj_flat )/( 1 + np.exp( Y_albd_kj_flat ) ) # Treat global area fraction Y_area_global = Y_array[-1] X_area_global = np.exp( Y_area_global )/( 1 + np.exp( Y_area_global ) ) # 'area fraction' part Y_area_lk = Y_array[n_type*n_band:n_type*n_band+n_slice*(n_type-2)].reshape([n_slice, n_type-2]) expY_area_lk = np.exp( Y_area_lk ) expYY_area_lk = (1.0 - X_area_global)/( 1.0 + expY_area_lk ) cumprodY_area_lk = np.cumprod( expYY_area_lk, axis=1 ) X_area_lk = expY_area_lk * cumprodY_area_lk X_area_lk = np.c_[X_area_lk, (1.0 - X_area_global) - np.sum( X_area_lk, axis=1 ), X_area_global*np.ones(n_slice)] X_area_lk_flat = X_area_lk.flatten() elif use_grey and use_global: # 'albedo' part Y_albd_kj_flat = Y_array[0:(n_type-1)*n_band] X_albd_kj_flat = np.exp( Y_albd_kj_flat )/( 1 + np.exp( Y_albd_kj_flat ) ) # Treat grey albedo (second to last item) Y_albd_grey = Y_array[-2] X_albd_grey = np.exp( Y_albd_grey )/( 1 + np.exp( Y_albd_grey ) ) # Combine albedos and Swap last two columns in albedo grid because grey # alb is second to last when global model is also used X_albd_kj_flat_new = np.zeros(n_band*n_type) X_albd_kj_flat_new[0:n_band*(n_type-2)] = X_albd_kj_flat[0:n_band*(n_type-2)] X_albd_kj_flat_new[n_band*(n_type-2):n_band*(n_type-1)] = X_albd_grey * np.ones(n_band) X_albd_kj_flat_new[n_band*(n_type-1):] = X_albd_kj_flat[n_band*(n_type-2):] #X_albd_kj_flat = np.hstack([X_albd_kj_flat, X_albd_grey * np.ones(n_band)]) X_albd_kj_flat = X_albd_kj_flat_new # Treat global area fraction (last item) Y_area_global = Y_array[-1] X_area_global = np.exp( Y_area_global )/( 1 + np.exp( Y_area_global ) ) # 'area fraction' part Y_area_lk = Y_array[(n_type-1)*n_band:(n_type-1)*n_band+n_slice*(n_type-2)].reshape([n_slice, n_type-2]) expY_area_lk = np.exp( Y_area_lk ) expYY_area_lk = (1.0 - X_area_global)/( 1.0 + expY_area_lk ) cumprodY_area_lk = np.cumprod( expYY_area_lk, axis=1 ) X_area_lk = expY_area_lk * cumprodY_area_lk X_area_lk = np.c_[X_area_lk, (1.0 - X_area_global) - np.sum( X_area_lk, axis=1 ), X_area_global*np.ones(n_slice)] X_area_lk_flat = X_area_lk.flatten() if flatten : X_array = np.r_[ X_albd_kj_flat, X_area_lk_flat ] return X_array else : X_albd_kj = X_albd_kj_flat.reshape([ n_type, n_band ]) return X_albd_kj, X_area_lk #--------------------------------------------------- def transform_X2Y_atmosphere(X_albd_kj, X_area_lk, use_grey = False, use_global = False): """ Transforms physical X array to parameterized Y array for fitting (state vector) """ n_slice = len( X_area_lk ) n_type = len( X_albd_kj ) if (not use_grey) and (not use_global): # 'albedo' part Y_albd_kj = np.log(X_albd_kj) - np.log(1.-X_albd_kj) # 'area' part sumX_area_lk = np.cumsum( X_area_lk, axis=1 ) Y_area_lk = np.log( X_area_lk[:,:-1] / ( 1. - sumX_area_lk[:,:-1] ) ) # Compose Y_array Y_array = np.concatenate([Y_albd_kj.flatten(), Y_area_lk.flatten()]) elif use_grey and (not use_global): # Get grey albedo X_albd_grey = X_albd_kj[-1,:][0] # Delete grey albedo row X_albd_new = np.delete(X_albd_kj, -1, 0) # Reparameterize albedo Y_albd_kj = np.log(X_albd_new) - np.log(1.-X_albd_new) Y_albd_grey = np.log(X_albd_grey) - np.log(1.-X_albd_grey) # Reparameterize area sumX_area_lk = np.cumsum( X_area_lk, axis=1 ) Y_area_lk = np.log( X_area_lk[:,:-1] / ( 1. - sumX_area_lk[:,:-1] ) ) # Compose Y_array Y_array = np.hstack([Y_albd_kj.flatten(), Y_area_lk.flatten(), Y_albd_grey]) elif use_global and (not use_grey): # Get global area X_area_global = X_area_lk[:,-1][0] # cumulative sum except last column sumX_area_new = np.cumsum( X_area_lk[:,:-1], axis=1 ) # reparameterize areas except last two columns Y_area_lk = np.log( X_area_lk[:,:-2] / ( (1.0 - X_area_global) - sumX_area_new[:,:-1] ) ) # reparameterize lone area Y_area_global = np.log(X_area_global) - np.log(1.-X_area_global) # Reparameterize albedo Y_albd_kj = np.log(X_albd_kj) - np.log(1.-X_albd_kj) # Compose Y_array Y_array = np.hstack([Y_albd_kj.flatten(), Y_area_lk.flatten(), Y_area_global]) elif use_grey and use_global: # Get grey albedo X_albd_grey = X_albd_kj[-2,:][0] # Delete grey albedo row X_albd_new = np.delete(X_albd_kj, -2, 0) # Reparameterize albedo Y_albd_kj = np.log(X_albd_new) - np.log(1.-X_albd_new) Y_albd_grey = np.log(X_albd_grey) - np.log(1.-X_albd_grey) # Get global area X_area_global = X_area_lk[:,-1][0] # cumulative sum except last column sumX_area_new = np.cumsum( X_area_lk[:,:-1], axis=1 ) # reparameterize areas except last two columns Y_area_lk = np.log( X_area_lk[:,:-2] / ( 1.0 - X_area_global - sumX_area_new[:,:-1] ) ) # reparameterize lone area Y_area_global = np.log(X_area_global) - np.log(1.-X_area_global) # Compose Y_array Y_array = np.hstack([Y_albd_kj.flatten(), Y_area_lk.flatten(), Y_albd_grey, Y_area_global]) return Y_array
37.704167
121
0.623273
1,582
9,049
3.142225
0.063843
0.138805
0.076041
0.04647
0.895796
0.88111
0.856769
0.845102
0.829813
0.818346
0
0.018481
0.234612
9,049
239
122
37.861925
0.699249
0.159023
0
0.752066
0
0
0
0
0
0
0
0
0
1
0.033058
false
0
0.008264
0
0.090909
0
0
0
0
null
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
7