adding all files done so far
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# ignore matplotlib
|
||||
./bayes-learning/packages/matplotlib/*
|
||||
@@ -0,0 +1,945 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"list",
|
||||
"list_of_ips\tstatement"
|
||||
],
|
||||
[
|
||||
"su",
|
||||
"sub_list\tstatement"
|
||||
],
|
||||
[
|
||||
"def",
|
||||
"def\tFunction"
|
||||
],
|
||||
[
|
||||
"fun",
|
||||
"function12\tfunction"
|
||||
],
|
||||
[
|
||||
"func",
|
||||
"function1\tfunction"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
{
|
||||
"file": "/home/dtomlinson/projects/learning/class-and-object-orianted-python/links.txt",
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 105,
|
||||
"encoding": "UTF-8",
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"contents": "#!/usr/bin/python\n\nreplace_chars = ['[', ']', '\\'', ',']\nlist_of_ips = ['list-items-in-here']\nnew_list = []\n\n\ndef split_ips(list):\n for sub_list in list:\n for ip in sub_list.split():\n for i in range(len(replace_chars)):\n ip = ip.replace(replace_chars[i], '')\n new_list.append(ip)\n\n\nsplit_ips(list_of_ips)\n",
|
||||
"file": "/home/dtomlinson/projects/temp/test.py",
|
||||
"file_size": 356,
|
||||
"file_write_time": 132035419907730753,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 352,
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"contents": "#!/usr/bin/python\n\nreplace_chars = ['[', ']', '\\'', ',']\nlist_of_ips = [\n 'test1', 'test2', 'test3\"'\n]\nnew_list = []\n\n\ndef split_ips(list):\n \"\"\"replaces items in a list with speicified character from another list\"\"\"\n for sub_list in list:\n print(sub_list)\n for ip in sub_list.split():\n print(ip)\n for i in range(len(replace_chars)):\n ip = ip.replace(replace_chars[i], '')\n new_list.append(ip)\n\n\nfinal_list = split_ips(list_of_ips)\n\nprint(final_list)\n",
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 521,
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
}
|
||||
],
|
||||
"build_system": "Packages/Python/Python.sublime-build",
|
||||
"build_system_choices":
|
||||
[
|
||||
[
|
||||
[
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
"Syntax Check"
|
||||
]
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
]
|
||||
]
|
||||
],
|
||||
"build_varint": "",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"ins",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"virtual",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"packa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"vir",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"virtualen",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"install pa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"insta",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"brow",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"browse",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"remove",
|
||||
"Package Control: Remove Package"
|
||||
],
|
||||
[
|
||||
"Snippet: ",
|
||||
"Snippet: For Loop"
|
||||
],
|
||||
[
|
||||
"remo",
|
||||
"Package Control: Remove Channel"
|
||||
],
|
||||
[
|
||||
"show all",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"prefs",
|
||||
"Preferences: SublimeLinter Settings"
|
||||
],
|
||||
[
|
||||
"package in",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"install pack",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ayu: Activate theme",
|
||||
"ayu: Activate theme"
|
||||
],
|
||||
[
|
||||
"Browse Pack",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"Package Control: insta",
|
||||
"Package Control: Install Package"
|
||||
]
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 250.0,
|
||||
"history":
|
||||
[
|
||||
"sublime.cache_path()",
|
||||
"import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
|
||||
]
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"expanded_folders":
|
||||
[
|
||||
"/home/dtomlinson/projects",
|
||||
"/home/dtomlinson/projects/learning",
|
||||
"/home/dtomlinson/projects/learning/class-and-object-orianted-python"
|
||||
],
|
||||
"file_history":
|
||||
[
|
||||
"/home/dtomlinson/projects/base/base.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp_1.py",
|
||||
"/home/dtomlinson/projects/temp/temp_new.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp.sublime-project",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-mirage.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-dark.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SideBarEnhancements/Side Bar.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Python.sublime-settings"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"ip",
|
||||
"~/.virtualenvs/temp",
|
||||
"space",
|
||||
"spaces",
|
||||
"indent",
|
||||
"tab",
|
||||
"Tab",
|
||||
"FreeMono",
|
||||
"Source Code Pro",
|
||||
"PragmataPro Mono Liga"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": false,
|
||||
"wrap": true
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"selected": 0,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 0,
|
||||
"file": "/home/dtomlinson/projects/learning/class-and-object-orianted-python/links.txt",
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 105,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
105,
|
||||
105
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"open_with_edit": true,
|
||||
"syntax": "Packages/Text/Plain text.tmLanguage"
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 2,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"selected": 0,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 1,
|
||||
"file": "/home/dtomlinson/projects/temp/test.py",
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 352,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
352,
|
||||
352
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.141.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.15.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions"
|
||||
],
|
||||
"SL.26.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.33.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.444.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.88.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions"
|
||||
],
|
||||
"auto_complete_triggers":
|
||||
[
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - comment - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
}
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content"
|
||||
],
|
||||
"syntax": "Packages/Python/Python.sublime-syntax"
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 0,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"buffer": 2,
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 521,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
521,
|
||||
521
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.143.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.19.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.28.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.34.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.446.region_keys":
|
||||
[
|
||||
],
|
||||
"SL.90.region_keys":
|
||||
[
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content"
|
||||
],
|
||||
"default_dir": "/home/dtomlinson/projects/temp",
|
||||
"syntax": "Packages/Python/Python.sublime-syntax"
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 1,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 51.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.5,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.SublimeLinter":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"output.find_results":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.unsaved_changes":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"pinned_build_system": "Packages/Virtualenv/Python + Virtualenv.sublime-build",
|
||||
"project": "base.sublime-project",
|
||||
"replace":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 500.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"",
|
||||
"~/projects/learning/learning.sublime-project"
|
||||
]
|
||||
],
|
||||
"width": 380.0
|
||||
},
|
||||
"select_symbol":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"selected_group": 1,
|
||||
"settings":
|
||||
{
|
||||
},
|
||||
"show_minimap": true,
|
||||
"show_open_files": true,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 212.0,
|
||||
"status_bar_visible": true,
|
||||
"template_settings":
|
||||
{
|
||||
"max_columns": 2
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
|
||||
# path = os.getcwd()
|
||||
|
||||
# data = pd.read_csv(path + str('/data/Social_Network_Ads.csv'),
|
||||
# engine='python')
|
||||
# df = pd.DataFrame(data)
|
||||
|
||||
|
||||
# train_size = int(0.75 * df.shape[0])
|
||||
# test_size = int(0.25 * df.shape[0])
|
||||
|
||||
# print('Training set size {}, Testing set size {}'.format(train_size,
|
||||
# test_size))
|
||||
|
||||
|
||||
class bayesClassifer(object):
|
||||
"""initial implmentation of a bayes classifer"""
|
||||
|
||||
path = os.getcwd()
|
||||
|
||||
def __init__(self, data_file):
|
||||
super(bayesClassifer, self).__init__()
|
||||
self.data_file = data_file
|
||||
|
||||
def createDataFrame(self):
|
||||
return pd.read_csv(self.path + self.data_file, engine='python')
|
||||
|
||||
def print_debug(self):
|
||||
print('{0} rows, {1} columns'.format(self.df.shape[0],
|
||||
self.df.shape[1]))
|
||||
print(self.df[1:7])
|
||||
|
||||
def trainData(dataframe):
|
||||
train_size = int(0.75 * dataframe.shape[0])
|
||||
test_size = int(0.25 * dataframe.shape[0])
|
||||
return(train_size, test_size)
|
||||
|
||||
|
||||
bayesClassifer('/data/Social_Network_Ads.csv')
|
||||
bayesClassifer.createDataFrame()
|
||||
@@ -0,0 +1,401 @@
|
||||
User ID,Gender,Age,EstimatedSalary,Purchased
|
||||
15624510,Male,19,19000,0
|
||||
15810944,Male,35,20000,0
|
||||
15668575,Female,26,43000,0
|
||||
15603246,Female,27,57000,0
|
||||
15804002,Male,19,76000,0
|
||||
15728773,Male,27,58000,0
|
||||
15598044,Female,27,84000,0
|
||||
15694829,Female,32,150000,1
|
||||
15600575,Male,25,33000,0
|
||||
15727311,Female,35,65000,0
|
||||
15570769,Female,26,80000,0
|
||||
15606274,Female,26,52000,0
|
||||
15746139,Male,20,86000,0
|
||||
15704987,Male,32,18000,0
|
||||
15628972,Male,18,82000,0
|
||||
15697686,Male,29,80000,0
|
||||
15733883,Male,47,25000,1
|
||||
15617482,Male,45,26000,1
|
||||
15704583,Male,46,28000,1
|
||||
15621083,Female,48,29000,1
|
||||
15649487,Male,45,22000,1
|
||||
15736760,Female,47,49000,1
|
||||
15714658,Male,48,41000,1
|
||||
15599081,Female,45,22000,1
|
||||
15705113,Male,46,23000,1
|
||||
15631159,Male,47,20000,1
|
||||
15792818,Male,49,28000,1
|
||||
15633531,Female,47,30000,1
|
||||
15744529,Male,29,43000,0
|
||||
15669656,Male,31,18000,0
|
||||
15581198,Male,31,74000,0
|
||||
15729054,Female,27,137000,1
|
||||
15573452,Female,21,16000,0
|
||||
15776733,Female,28,44000,0
|
||||
15724858,Male,27,90000,0
|
||||
15713144,Male,35,27000,0
|
||||
15690188,Female,33,28000,0
|
||||
15689425,Male,30,49000,0
|
||||
15671766,Female,26,72000,0
|
||||
15782806,Female,27,31000,0
|
||||
15764419,Female,27,17000,0
|
||||
15591915,Female,33,51000,0
|
||||
15772798,Male,35,108000,0
|
||||
15792008,Male,30,15000,0
|
||||
15715541,Female,28,84000,0
|
||||
15639277,Male,23,20000,0
|
||||
15798850,Male,25,79000,0
|
||||
15776348,Female,27,54000,0
|
||||
15727696,Male,30,135000,1
|
||||
15793813,Female,31,89000,0
|
||||
15694395,Female,24,32000,0
|
||||
15764195,Female,18,44000,0
|
||||
15744919,Female,29,83000,0
|
||||
15671655,Female,35,23000,0
|
||||
15654901,Female,27,58000,0
|
||||
15649136,Female,24,55000,0
|
||||
15775562,Female,23,48000,0
|
||||
15807481,Male,28,79000,0
|
||||
15642885,Male,22,18000,0
|
||||
15789109,Female,32,117000,0
|
||||
15814004,Male,27,20000,0
|
||||
15673619,Male,25,87000,0
|
||||
15595135,Female,23,66000,0
|
||||
15583681,Male,32,120000,1
|
||||
15605000,Female,59,83000,0
|
||||
15718071,Male,24,58000,0
|
||||
15679760,Male,24,19000,0
|
||||
15654574,Female,23,82000,0
|
||||
15577178,Female,22,63000,0
|
||||
15595324,Female,31,68000,0
|
||||
15756932,Male,25,80000,0
|
||||
15726358,Female,24,27000,0
|
||||
15595228,Female,20,23000,0
|
||||
15782530,Female,33,113000,0
|
||||
15592877,Male,32,18000,0
|
||||
15651983,Male,34,112000,1
|
||||
15746737,Male,18,52000,0
|
||||
15774179,Female,22,27000,0
|
||||
15667265,Female,28,87000,0
|
||||
15655123,Female,26,17000,0
|
||||
15595917,Male,30,80000,0
|
||||
15668385,Male,39,42000,0
|
||||
15709476,Male,20,49000,0
|
||||
15711218,Male,35,88000,0
|
||||
15798659,Female,30,62000,0
|
||||
15663939,Female,31,118000,1
|
||||
15694946,Male,24,55000,0
|
||||
15631912,Female,28,85000,0
|
||||
15768816,Male,26,81000,0
|
||||
15682268,Male,35,50000,0
|
||||
15684801,Male,22,81000,0
|
||||
15636428,Female,30,116000,0
|
||||
15809823,Male,26,15000,0
|
||||
15699284,Female,29,28000,0
|
||||
15786993,Female,29,83000,0
|
||||
15709441,Female,35,44000,0
|
||||
15710257,Female,35,25000,0
|
||||
15582492,Male,28,123000,1
|
||||
15575694,Male,35,73000,0
|
||||
15756820,Female,28,37000,0
|
||||
15766289,Male,27,88000,0
|
||||
15593014,Male,28,59000,0
|
||||
15584545,Female,32,86000,0
|
||||
15675949,Female,33,149000,1
|
||||
15672091,Female,19,21000,0
|
||||
15801658,Male,21,72000,0
|
||||
15706185,Female,26,35000,0
|
||||
15789863,Male,27,89000,0
|
||||
15720943,Male,26,86000,0
|
||||
15697997,Female,38,80000,0
|
||||
15665416,Female,39,71000,0
|
||||
15660200,Female,37,71000,0
|
||||
15619653,Male,38,61000,0
|
||||
15773447,Male,37,55000,0
|
||||
15739160,Male,42,80000,0
|
||||
15689237,Male,40,57000,0
|
||||
15679297,Male,35,75000,0
|
||||
15591433,Male,36,52000,0
|
||||
15642725,Male,40,59000,0
|
||||
15701962,Male,41,59000,0
|
||||
15811613,Female,36,75000,0
|
||||
15741049,Male,37,72000,0
|
||||
15724423,Female,40,75000,0
|
||||
15574305,Male,35,53000,0
|
||||
15678168,Female,41,51000,0
|
||||
15697020,Female,39,61000,0
|
||||
15610801,Male,42,65000,0
|
||||
15745232,Male,26,32000,0
|
||||
15722758,Male,30,17000,0
|
||||
15792102,Female,26,84000,0
|
||||
15675185,Male,31,58000,0
|
||||
15801247,Male,33,31000,0
|
||||
15725660,Male,30,87000,0
|
||||
15638963,Female,21,68000,0
|
||||
15800061,Female,28,55000,0
|
||||
15578006,Male,23,63000,0
|
||||
15668504,Female,20,82000,0
|
||||
15687491,Male,30,107000,1
|
||||
15610403,Female,28,59000,0
|
||||
15741094,Male,19,25000,0
|
||||
15807909,Male,19,85000,0
|
||||
15666141,Female,18,68000,0
|
||||
15617134,Male,35,59000,0
|
||||
15783029,Male,30,89000,0
|
||||
15622833,Female,34,25000,0
|
||||
15746422,Female,24,89000,0
|
||||
15750839,Female,27,96000,1
|
||||
15749130,Female,41,30000,0
|
||||
15779862,Male,29,61000,0
|
||||
15767871,Male,20,74000,0
|
||||
15679651,Female,26,15000,0
|
||||
15576219,Male,41,45000,0
|
||||
15699247,Male,31,76000,0
|
||||
15619087,Female,36,50000,0
|
||||
15605327,Male,40,47000,0
|
||||
15610140,Female,31,15000,0
|
||||
15791174,Male,46,59000,0
|
||||
15602373,Male,29,75000,0
|
||||
15762605,Male,26,30000,0
|
||||
15598840,Female,32,135000,1
|
||||
15744279,Male,32,100000,1
|
||||
15670619,Male,25,90000,0
|
||||
15599533,Female,37,33000,0
|
||||
15757837,Male,35,38000,0
|
||||
15697574,Female,33,69000,0
|
||||
15578738,Female,18,86000,0
|
||||
15762228,Female,22,55000,0
|
||||
15614827,Female,35,71000,0
|
||||
15789815,Male,29,148000,1
|
||||
15579781,Female,29,47000,0
|
||||
15587013,Male,21,88000,0
|
||||
15570932,Male,34,115000,0
|
||||
15794661,Female,26,118000,0
|
||||
15581654,Female,34,43000,0
|
||||
15644296,Female,34,72000,0
|
||||
15614420,Female,23,28000,0
|
||||
15609653,Female,35,47000,0
|
||||
15594577,Male,25,22000,0
|
||||
15584114,Male,24,23000,0
|
||||
15673367,Female,31,34000,0
|
||||
15685576,Male,26,16000,0
|
||||
15774727,Female,31,71000,0
|
||||
15694288,Female,32,117000,1
|
||||
15603319,Male,33,43000,0
|
||||
15759066,Female,33,60000,0
|
||||
15814816,Male,31,66000,0
|
||||
15724402,Female,20,82000,0
|
||||
15571059,Female,33,41000,0
|
||||
15674206,Male,35,72000,0
|
||||
15715160,Male,28,32000,0
|
||||
15730448,Male,24,84000,0
|
||||
15662067,Female,19,26000,0
|
||||
15779581,Male,29,43000,0
|
||||
15662901,Male,19,70000,0
|
||||
15689751,Male,28,89000,0
|
||||
15667742,Male,34,43000,0
|
||||
15738448,Female,30,79000,0
|
||||
15680243,Female,20,36000,0
|
||||
15745083,Male,26,80000,0
|
||||
15708228,Male,35,22000,0
|
||||
15628523,Male,35,39000,0
|
||||
15708196,Male,49,74000,0
|
||||
15735549,Female,39,134000,1
|
||||
15809347,Female,41,71000,0
|
||||
15660866,Female,58,101000,1
|
||||
15766609,Female,47,47000,0
|
||||
15654230,Female,55,130000,1
|
||||
15794566,Female,52,114000,0
|
||||
15800890,Female,40,142000,1
|
||||
15697424,Female,46,22000,0
|
||||
15724536,Female,48,96000,1
|
||||
15735878,Male,52,150000,1
|
||||
15707596,Female,59,42000,0
|
||||
15657163,Male,35,58000,0
|
||||
15622478,Male,47,43000,0
|
||||
15779529,Female,60,108000,1
|
||||
15636023,Male,49,65000,0
|
||||
15582066,Male,40,78000,0
|
||||
15666675,Female,46,96000,0
|
||||
15732987,Male,59,143000,1
|
||||
15789432,Female,41,80000,0
|
||||
15663161,Male,35,91000,1
|
||||
15694879,Male,37,144000,1
|
||||
15593715,Male,60,102000,1
|
||||
15575002,Female,35,60000,0
|
||||
15622171,Male,37,53000,0
|
||||
15795224,Female,36,126000,1
|
||||
15685346,Male,56,133000,1
|
||||
15691808,Female,40,72000,0
|
||||
15721007,Female,42,80000,1
|
||||
15794253,Female,35,147000,1
|
||||
15694453,Male,39,42000,0
|
||||
15813113,Male,40,107000,1
|
||||
15614187,Male,49,86000,1
|
||||
15619407,Female,38,112000,0
|
||||
15646227,Male,46,79000,1
|
||||
15660541,Male,40,57000,0
|
||||
15753874,Female,37,80000,0
|
||||
15617877,Female,46,82000,0
|
||||
15772073,Female,53,143000,1
|
||||
15701537,Male,42,149000,1
|
||||
15736228,Male,38,59000,0
|
||||
15780572,Female,50,88000,1
|
||||
15769596,Female,56,104000,1
|
||||
15586996,Female,41,72000,0
|
||||
15722061,Female,51,146000,1
|
||||
15638003,Female,35,50000,0
|
||||
15775590,Female,57,122000,1
|
||||
15730688,Male,41,52000,0
|
||||
15753102,Female,35,97000,1
|
||||
15810075,Female,44,39000,0
|
||||
15723373,Male,37,52000,0
|
||||
15795298,Female,48,134000,1
|
||||
15584320,Female,37,146000,1
|
||||
15724161,Female,50,44000,0
|
||||
15750056,Female,52,90000,1
|
||||
15609637,Female,41,72000,0
|
||||
15794493,Male,40,57000,0
|
||||
15569641,Female,58,95000,1
|
||||
15815236,Female,45,131000,1
|
||||
15811177,Female,35,77000,0
|
||||
15680587,Male,36,144000,1
|
||||
15672821,Female,55,125000,1
|
||||
15767681,Female,35,72000,0
|
||||
15600379,Male,48,90000,1
|
||||
15801336,Female,42,108000,1
|
||||
15721592,Male,40,75000,0
|
||||
15581282,Male,37,74000,0
|
||||
15746203,Female,47,144000,1
|
||||
15583137,Male,40,61000,0
|
||||
15680752,Female,43,133000,0
|
||||
15688172,Female,59,76000,1
|
||||
15791373,Male,60,42000,1
|
||||
15589449,Male,39,106000,1
|
||||
15692819,Female,57,26000,1
|
||||
15727467,Male,57,74000,1
|
||||
15734312,Male,38,71000,0
|
||||
15764604,Male,49,88000,1
|
||||
15613014,Female,52,38000,1
|
||||
15759684,Female,50,36000,1
|
||||
15609669,Female,59,88000,1
|
||||
15685536,Male,35,61000,0
|
||||
15750447,Male,37,70000,1
|
||||
15663249,Female,52,21000,1
|
||||
15638646,Male,48,141000,0
|
||||
15734161,Female,37,93000,1
|
||||
15631070,Female,37,62000,0
|
||||
15761950,Female,48,138000,1
|
||||
15649668,Male,41,79000,0
|
||||
15713912,Female,37,78000,1
|
||||
15586757,Male,39,134000,1
|
||||
15596522,Male,49,89000,1
|
||||
15625395,Male,55,39000,1
|
||||
15760570,Male,37,77000,0
|
||||
15566689,Female,35,57000,0
|
||||
15725794,Female,36,63000,0
|
||||
15673539,Male,42,73000,1
|
||||
15705298,Female,43,112000,1
|
||||
15675791,Male,45,79000,0
|
||||
15747043,Male,46,117000,1
|
||||
15736397,Female,58,38000,1
|
||||
15678201,Male,48,74000,1
|
||||
15720745,Female,37,137000,1
|
||||
15637593,Male,37,79000,1
|
||||
15598070,Female,40,60000,0
|
||||
15787550,Male,42,54000,0
|
||||
15603942,Female,51,134000,0
|
||||
15733973,Female,47,113000,1
|
||||
15596761,Male,36,125000,1
|
||||
15652400,Female,38,50000,0
|
||||
15717893,Female,42,70000,0
|
||||
15622585,Male,39,96000,1
|
||||
15733964,Female,38,50000,0
|
||||
15753861,Female,49,141000,1
|
||||
15747097,Female,39,79000,0
|
||||
15594762,Female,39,75000,1
|
||||
15667417,Female,54,104000,1
|
||||
15684861,Male,35,55000,0
|
||||
15742204,Male,45,32000,1
|
||||
15623502,Male,36,60000,0
|
||||
15774872,Female,52,138000,1
|
||||
15611191,Female,53,82000,1
|
||||
15674331,Male,41,52000,0
|
||||
15619465,Female,48,30000,1
|
||||
15575247,Female,48,131000,1
|
||||
15695679,Female,41,60000,0
|
||||
15713463,Male,41,72000,0
|
||||
15785170,Female,42,75000,0
|
||||
15796351,Male,36,118000,1
|
||||
15639576,Female,47,107000,1
|
||||
15693264,Male,38,51000,0
|
||||
15589715,Female,48,119000,1
|
||||
15769902,Male,42,65000,0
|
||||
15587177,Male,40,65000,0
|
||||
15814553,Male,57,60000,1
|
||||
15601550,Female,36,54000,0
|
||||
15664907,Male,58,144000,1
|
||||
15612465,Male,35,79000,0
|
||||
15810800,Female,38,55000,0
|
||||
15665760,Male,39,122000,1
|
||||
15588080,Female,53,104000,1
|
||||
15776844,Male,35,75000,0
|
||||
15717560,Female,38,65000,0
|
||||
15629739,Female,47,51000,1
|
||||
15729908,Male,47,105000,1
|
||||
15716781,Female,41,63000,0
|
||||
15646936,Male,53,72000,1
|
||||
15768151,Female,54,108000,1
|
||||
15579212,Male,39,77000,0
|
||||
15721835,Male,38,61000,0
|
||||
15800515,Female,38,113000,1
|
||||
15591279,Male,37,75000,0
|
||||
15587419,Female,42,90000,1
|
||||
15750335,Female,37,57000,0
|
||||
15699619,Male,36,99000,1
|
||||
15606472,Male,60,34000,1
|
||||
15778368,Male,54,70000,1
|
||||
15671387,Female,41,72000,0
|
||||
15573926,Male,40,71000,1
|
||||
15709183,Male,42,54000,0
|
||||
15577514,Male,43,129000,1
|
||||
15778830,Female,53,34000,1
|
||||
15768072,Female,47,50000,1
|
||||
15768293,Female,42,79000,0
|
||||
15654456,Male,42,104000,1
|
||||
15807525,Female,59,29000,1
|
||||
15574372,Female,58,47000,1
|
||||
15671249,Male,46,88000,1
|
||||
15779744,Male,38,71000,0
|
||||
15624755,Female,54,26000,1
|
||||
15611430,Female,60,46000,1
|
||||
15774744,Male,60,83000,1
|
||||
15629885,Female,39,73000,0
|
||||
15708791,Male,59,130000,1
|
||||
15793890,Female,37,80000,0
|
||||
15646091,Female,46,32000,1
|
||||
15596984,Female,46,74000,0
|
||||
15800215,Female,42,53000,0
|
||||
15577806,Male,41,87000,1
|
||||
15749381,Female,58,23000,1
|
||||
15683758,Male,42,64000,0
|
||||
15670615,Male,48,33000,1
|
||||
15715622,Female,44,139000,1
|
||||
15707634,Male,49,28000,1
|
||||
15806901,Female,57,33000,1
|
||||
15775335,Male,56,60000,1
|
||||
15724150,Female,49,39000,1
|
||||
15627220,Male,39,71000,0
|
||||
15672330,Male,47,34000,1
|
||||
15668521,Female,48,35000,1
|
||||
15807837,Male,48,33000,1
|
||||
15592570,Male,47,23000,1
|
||||
15748589,Female,45,45000,1
|
||||
15635893,Male,60,42000,1
|
||||
15757632,Female,39,59000,0
|
||||
15691863,Female,46,41000,1
|
||||
15706071,Male,51,23000,1
|
||||
15654296,Female,50,20000,1
|
||||
15755018,Male,36,33000,0
|
||||
15594041,Female,49,36000,1
|
||||
|
@@ -0,0 +1,33 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
from matplotlib.colors import ListedColormap
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
matplotlib.rcParams['backend'] = 'TkAgg'
|
||||
|
||||
|
||||
class getData(object):
|
||||
"""docstring for getData"""
|
||||
def __init__(self, file):
|
||||
super(getData, self).__init__()
|
||||
self.file = file
|
||||
|
||||
|
||||
class Bayes(getData):
|
||||
"""docstring for Bayes"""
|
||||
|
||||
def __init__(self, file):
|
||||
super(Bayes, self).__init__()
|
||||
self.file = file
|
||||
|
||||
def get_path(self):
|
||||
path = os.getcwd()
|
||||
file_path = path + self.file
|
||||
return file_path
|
||||
|
||||
|
||||
bayes = Bayes(file='data/Social_Network_Ads.csv')
|
||||
print(bayes.get_path())
|
||||
@@ -0,0 +1,152 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
from sklearn.preprocessing import Normalizer, StandardScaler
|
||||
from matplotlib.colors import ListedColormap
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.naive_bayes import GaussianNB
|
||||
from sklearn.metrics import confusion_matrix, classification_report
|
||||
|
||||
matplotlib.rcParams['backend'] = 'TkAgg'
|
||||
|
||||
plt.style.use('seaborn-dark-palette')
|
||||
|
||||
# path = os.getcwd()
|
||||
path = '/home/dtomlinson/projects/bayes-learning'
|
||||
|
||||
data = pd.read_csv(path + str('/data/Social_Network_Ads.csv'), engine='python')
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
print('{0} rows, {1} columns'.format(df.shape[0], df.shape[1]))
|
||||
# print(df[1:7])
|
||||
|
||||
train_size = int(0.75 * df.shape[0])
|
||||
test_size = int(0.25 * df.shape[0])
|
||||
|
||||
print('Training set size {}, Testing set size {}'.format(train_size,
|
||||
test_size))
|
||||
|
||||
df = df.sample(frac=1).reset_index(drop=True)
|
||||
|
||||
print(df[0:5])
|
||||
|
||||
X = df.iloc[:, [2, 3]].values
|
||||
y = df.iloc[:, 4].values
|
||||
|
||||
normalizer = StandardScaler(copy=False).fit(X)
|
||||
X = normalizer.fit_transform(X)
|
||||
|
||||
X_train = X[0:train_size, :]
|
||||
y_train = y[0:train_size]
|
||||
|
||||
X_test = X[train_size:, :]
|
||||
y_test = y[train_size:]
|
||||
|
||||
X_set, y_set = X_train, y_train
|
||||
|
||||
|
||||
# ind = np.argsort(X_set[:, 0])
|
||||
# X_set = X_set[ind]
|
||||
|
||||
|
||||
for i, j in enumerate(np.unique(y_set)):
|
||||
plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 1],
|
||||
c=ListedColormap(('red', 'blue'))(i),
|
||||
label=j, marker='.')
|
||||
|
||||
|
||||
plt.title('Training Set')
|
||||
plt.xlabel('Age')
|
||||
plt.ylabel('Estimated Salary')
|
||||
plt.legend()
|
||||
|
||||
|
||||
def generate_data(class_data_dic, X_train, y_train):
|
||||
|
||||
first_one = True
|
||||
first_zero = True
|
||||
|
||||
for i in range(y_train.shape[0]):
|
||||
X_temp = X_train[i, :].reshape(X_train[i, :].shape[0], 1)
|
||||
|
||||
if y_train[i] == 1:
|
||||
if first_one is True:
|
||||
class_data_dic[1] = X_temp
|
||||
first_one = False
|
||||
else:
|
||||
class_data_dic[1] = np.append(class_data_dic[1], X_temp,
|
||||
axis=1)
|
||||
elif y_train[i] == 0:
|
||||
if first_zero is True:
|
||||
class_data_dic[0] = X_temp
|
||||
first_zero = False
|
||||
else:
|
||||
class_data_dic[0] = np.append(class_data_dic[0], X_temp,
|
||||
axis=1)
|
||||
|
||||
return class_data_dic
|
||||
|
||||
|
||||
class_data_dic = generate_data(class_data_dic={}, X_train=X_train,
|
||||
y_train=y_train)
|
||||
|
||||
"""find the mean (2x1) for each column. 0 and 1 are the values for having 0
|
||||
and 1 seperately"""
|
||||
|
||||
mean_0 = np.mean(class_data_dic[0], axis=1)
|
||||
mean_1 = np.mean(class_data_dic[1], axis=1)
|
||||
std_0 = np.std(class_data_dic[0], axis=1)
|
||||
std_1 = np.std(class_data_dic[1], axis=1)
|
||||
|
||||
print('mean_0={}, std_0={}, mean_1={}, std_1={}'.format(
|
||||
mean_0, mean_1, std_0, std_1))
|
||||
# plt.show()
|
||||
|
||||
"""define the likelyhood function (the pdf of the norm dist) """
|
||||
|
||||
|
||||
def likelyhood(x, mean, sigma):
|
||||
return np.exp(-(x - mean)**2 / (2 * sigma ** 2)) * (1 / (np.sqrt(2 * np.pi) * sigma ** 2))
|
||||
|
||||
|
||||
""" the posterior function times together all the likelihoods for each row
|
||||
of X_test here we are working out the likelihood func for each row of X_test
|
||||
with their corresponding mean and stdev """
|
||||
"""we then times this by the prior-prob-func to find the posterior func"""
|
||||
|
||||
|
||||
def posterior(X, X_train_class, mean_, std_):
|
||||
product = np.prod(likelyhood(X, mean_, std_), axis=1)
|
||||
product = product * (X_train_class.shape[0] / X.shape[0])
|
||||
return product
|
||||
|
||||
|
||||
""" we test the posterior fun with the test data to find the probs"""
|
||||
p_1 = posterior(X_test, class_data_dic[1], mean_1, std_1)
|
||||
p_0 = posterior(X_test, class_data_dic[0], mean_0, std_0)
|
||||
y_pred = 1 * (p_1 > p_0)
|
||||
|
||||
print(X_test.shape)
|
||||
print(class_data_dic[0].shape)
|
||||
print(p_1.shape)
|
||||
tp = len([i for i in range(0, y_test.shape[0])
|
||||
if y_test[i] == 0 and y_pred[i] == 0])
|
||||
tn = len([i for i in range(0, y_test.shape[0])
|
||||
if y_test[i] == 0 and y_pred[i] == 1])
|
||||
fp = len([i for i in range(0, y_test.shape[0])
|
||||
if y_test[i] == 1 and y_pred[i] == 0])
|
||||
fn = len([i for i in range(0, y_test.shape[0])
|
||||
if y_test[i] == 1 and y_pred[i] == 1])
|
||||
confusion_matrix_alg = np.array([[tp, tn], [fp, fn]])
|
||||
print(confusion_matrix_alg)
|
||||
|
||||
|
||||
classifer = GaussianNB()
|
||||
classifer.fit(X_train, y_train)
|
||||
|
||||
y_pred = classifer.predict(X_test)
|
||||
cm = confusion_matrix(y_test, y_pred)
|
||||
report = classification_report(y_test, y_pred)
|
||||
print(cm)
|
||||
print(report)
|
||||
@@ -0,0 +1,3 @@
|
||||
,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190
|
||||
0,-0.06256109973954335,-1.1132055228463764,-0.25358735848624026,-0.06256109973954335,0.22397828838050202,-0.4446136172329372,0.3194914177538505,0.12846515900715358,-0.15807422911289182,-0.34910048785958875,1.083596452740638,-0.25358735848624026,-0.7311530053529826,-0.4446136172329372,-0.25358735848624026,-0.15807422911289182,-1.3042317815930733,-1.7817974284598157,-0.7311530053529826,-0.7311530053529826,0.7970570646205928,-1.2087186522197249,-1.3997449109664217,-0.7311530053529826,-1.7817974284598157,-0.25358735848624026,-0.34910048785958875,0.415004547127199,-0.06256109973954335,-1.1132055228463764,-1.6862842990864673,-0.25358735848624026,-1.3997449109664217,-0.06256109973954335,-0.9221792640996795,-0.6356398759796341,-0.826666134726331,0.12846515900715358,0.22397828838050202,-0.06256109973954335,-0.6356398759796341,-0.6356398759796341,-0.826666134726331,0.3194914177538505,0.5105176765005474,-1.3997449109664217,-1.3042317815930733,-1.3042317815930733,-0.25358735848624026,-0.9221792640996795,-0.15807422911289182,-1.017692393473028,-0.826666134726331,-0.4446136172329372,-0.5401267466062857,-1.1132055228463764,-0.25358735848624026,-1.1132055228463764,-0.9221792640996795,-1.017692393473028,0.03295202963380511,-0.4446136172329372,-1.017692393473028,-1.2087186522197249,0.12846515900715358,0.415004547127199,-0.25358735848624026,-1.017692393473028,-0.25358735848624026,0.3194914177538505,-1.4952580403397702,-1.017692393473028,0.3194914177538505,1.1791095821139865,-0.5401267466062857,0.9880833233672897,-0.826666134726331,-1.1132055228463764,-1.8773105578331641,0.03295202963380511,-0.9221792640996795,-1.5907711697131186,-1.5907711697131186,2.0387277464741227,0.3194914177538505,-1.1132055228463764,-1.4952580403397702,1.083596452740638,-0.826666134726331,-1.5907711697131186,-0.6356398759796341,-1.8773105578331641,-0.7311530053529826,0.03295202963380511,-0.25358735848624026,-1.7817974284598157,-0.7311530053529826,-1.017692393473028,-0.06256109973954335,-0.25358735848624026,-0.5401267466062857,1.3701358408606836,-0.6356398759796341,0.22397828838050202,-0.06256109973954335,-1.2087186522197249,0.03295202963380511,-0.4446136172329372,0.7970570646205928,-1.017692393473028,-0.6356398759796341,-0.4446136172329372,-0.6356398759796341,0.03295202963380511,0.22397828838050202,0.22397828838050202,-1.6862842990864673,-1.1132055228463764,0.8925701939939412,-1.017692393473028,0.12846515900715358,-0.15807422911289182,0.22397828838050202,0.12846515900715358,-0.6356398759796341,-0.9221792640996795,-0.06256109973954335,-0.25358735848624026,-0.826666134726331,0.03295202963380511,-0.25358735848624026,-1.2087186522197249,-0.25358735848624026,0.3194914177538505,-1.1132055228463764,-0.25358735848624026,-1.017692393473028,-1.1132055228463764,-0.25358735848624026,-0.25358735848624026,-0.06256109973954335,-1.7817974284598157,-0.4446136172329372,-1.6862842990864673,-1.8773105578331641,-0.25358735848624026,-1.7817974284598157,-1.3997449109664217,-1.1132055228463764,0.415004547127199,0.12846515900715358,-0.25358735848624026,-1.3042317815930733,-1.3997449109664217,-0.06256109973954335,-0.34910048785958875,0.415004547127199,-0.25358735848624026,-1.2087186522197249,-0.25358735848624026,-0.15807422911289182,0.3194914177538505,-1.1132055228463764,-1.7817974284598157,-1.3042317815930733,-0.9221792640996795,-1.5907711697131186,0.03295202963380511,0.03295202963380511,-1.3042317815930733,-0.25358735848624026,-0.15807422911289182,-0.9221792640996795,0.415004547127199,-1.6862842990864673,-1.1132055228463764,-0.7311530053529826,-0.25358735848624026,0.03295202963380511,-0.9221792640996795,-0.25358735848624026,0.3194914177538505,-0.25358735848624026,-0.06256109973954335,0.3194914177538505,-1.017692393473028,-1.3042317815930733,0.22397828838050202,-0.7311530053529826,-1.3042317815930733,0.415004547127199
|
||||
1,-0.5210059679415002,-1.0202085298693855,-0.25672225868556103,-0.49164111135750704,0.1543857334903445,-0.28608711526955427,0.06629116373836477,-0.25672225868556103,-0.5797356811094868,1.3289799968500746,0.12502087690635127,-0.28608711526955427,-0.60910053769348,-0.8440193903654261,-0.3154519718535475,-0.1979925455175745,-1.2551273825413316,0.44803429933027705,-0.22735740210156777,1.3583448534340679,0.3599397295782973,0.5067640124982635,-0.6384653942774733,0.5067640124982635,-1.4900462352132775,0.21311544665833101,-0.7852896771974396,-0.139262832349588,0.12502087690635127,0.3012100164103108,0.12502087690635127,-0.4329113981895205,-1.2257625259573384,-0.22735740210156777,-0.961478816701399,-1.0495733864533787,-0.7852896771974396,-0.3154519718535475,-0.37418168502153404,0.1543857334903445,0.12502087690635127,-0.10989797576559475,0.1543857334903445,0.06629116373836477,1.8575474153619531,-0.1979925455175745,0.56549372566625,-1.3725868088773046,-1.3725868088773046,0.56549372566625,-0.46227625477351375,-1.1376679562053587,-0.7852896771974396,1.2702502836820881,0.4773991559142703,0.4773991559142703,0.036926307154371514,-1.1083030996213654,-0.7559248206134463,-0.34481682843754075,1.240885427098095,-1.1376679562053587,-0.34481682843754075,0.3012100164103108,0.036926307154371514,0.3012100164103108,0.09565602032235802,-1.4606813786292843,0.06629116373836477,-0.5210059679415002,0.33057487299430405,0.56549372566625,-0.5210059679415002,-0.7559248206134463,1.387709710018061,2.092466268033899,-0.25672225868556103,0.33057487299430405,0.4773991559142703,-0.25672225868556103,0.2718451598263175,0.5361288690822568,-0.05116826259760824,0.3893045861622905,0.2718451598263175,-1.167032812789352,-0.1979925455175745,-0.139262832349588,0.3893045861622905,-1.5781408049652574,-1.6075056615492507,-0.7559248206134463,0.3012100164103108,-0.5797356811094868,-1.2551273825413316,0.18375059007433778,0.2718451598263175,0.4186694427462838,0.3012100164103108,-0.9027491035334125,-1.519411091797271,1.2996151402660814,-0.05116826259760824,0.24248030324232428,0.036926307154371514,-1.4019516654612978,-0.5797356811094868,-1.2257625259573384,0.7710477217542028,-0.37418168502153404,-0.34481682843754075,-0.02180340601361499,0.18375059007433778,0.036926307154371514,0.1543857334903445,-0.139262832349588,-0.60910053769348,0.3012100164103108,-0.6678302508614665,0.5948585822502434,0.2718451598263175,-0.28608711526955427,0.06629116373836477,0.09565602032235802,0.56549372566625,0.44803429933027705,0.21311544665833101,-0.7559248206134463,0.3012100164103108,0.036926307154371514,1.123426000762122,0.5948585822502434,-0.37418168502153404,0.3012100164103108,1.4170745666020543,-0.9321139601174058,-1.5487759483812642,-1.5781408049652574,-1.4019516654612978,-1.313857095709318,0.06629116373836477,-1.2844922391253248,-0.7852896771974396,0.4773991559142703,-0.05116826259760824,-0.34481682843754075,-1.431316522045291,-1.4606813786292843,-0.5210059679415002,-0.16862768893358124,-0.8146545337814328,-0.6678302508614665,-0.4329113981895205,0.3599397295782973,-0.4329113981895205,0.06629116373836477,-0.46227625477351375,-0.5797356811094868,-1.0789382430373722,-1.4606813786292843,-0.5210059679415002,-1.167032812789352,0.4186694427462838,0.007561450570378263,-1.4900462352132775,-0.3154519718535475,0.06629116373836477,-0.139262832349588,-0.3154519718535475,-1.1083030996213654,-0.139262832349588,0.1543857334903445,-0.4329113981895205,-0.49164111135750704,-1.3725868088773046,-0.7852896771974396,0.56549372566625,0.06629116373836477,0.3012100164103108,-1.1083030996213654,0.5361288690822568,-0.28608711526955427,0.1543857334903445,0.3012100164103108,-0.726559964029453,-0.46227625477351375,-0.4329113981895205,-0.25672225868556103,-1.6075056615492507,-0.34481682843754075,0.007561450570378263
|
||||
|
Submodule
+1
Submodule bayes-learning/packages/matplotlib added at fdc7a8c384
@@ -0,0 +1,84 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
# from sklearn.preprocessing import StandardScaler
|
||||
from sklearn.model_selection import train_test_split
|
||||
import numpy as np
|
||||
from scipy.stats import trim_mean, kurtosis
|
||||
from scipy.stats.mstats import mode, gmean, hmean
|
||||
|
||||
|
||||
def linebreak():
|
||||
"""prints a line break to split up functions"""
|
||||
print('\n ============================================== \n')
|
||||
|
||||
|
||||
matplotlib.rcParams['backend'] = 'TkAgg'
|
||||
plt.style.use('seaborn-dark-palette')
|
||||
|
||||
path = os.getcwd()
|
||||
data_file = str('/data/Social_Network_Ads.csv')
|
||||
|
||||
df = pd.read_csv(path + data_file)
|
||||
# df = pd.DataFrame(df)
|
||||
|
||||
df = df.sample(frac=1).reset_index(drop=True)
|
||||
|
||||
print('{} rows. {} cols.'.format(df.shape[0], df.shape[1]))
|
||||
|
||||
linebreak()
|
||||
print(df.iloc[0:10, :])
|
||||
|
||||
linebreak()
|
||||
X = df[['Age', 'EstimatedSalary']]
|
||||
y = df['Purchased'].to_frame()
|
||||
|
||||
print('X equals:')
|
||||
print(X.iloc[0:5])
|
||||
linebreak()
|
||||
print('y equals:')
|
||||
print(y[0:5])
|
||||
linebreak()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
|
||||
|
||||
description = df.describe().drop(columns=['User ID'])
|
||||
|
||||
description_grouped = df.groupby(['Purchased'])
|
||||
|
||||
description_grouped_split = description_grouped['Age', 'EstimatedSalary']\
|
||||
.describe().unstack()
|
||||
|
||||
description_grouped_mode = description_grouped['Age'].apply(mode, axis=None)
|
||||
|
||||
df_quartile_slary = df.groupby('Purchased')['EstimatedSalary']\
|
||||
.quantile([.1, .5, .9])
|
||||
df_quartile_age = df.groupby('Purchased')['Age'].quantile([.1, .5, .9])
|
||||
|
||||
df_trimmed_mean = description_grouped['Age', 'EstimatedSalary'].\
|
||||
aggregate(trim_mean, .1)
|
||||
|
||||
df_summary = description_grouped['Age', 'EstimatedSalary']\
|
||||
.aggregate([np.median, np.std, np.mean, gmean, hmean])
|
||||
|
||||
df_var = description_grouped['Age', 'EstimatedSalary'].var()
|
||||
|
||||
df_null = df.isna().sum()
|
||||
|
||||
print(description)
|
||||
linebreak()
|
||||
print(description_grouped_split)
|
||||
linebreak()
|
||||
print(description_grouped_mode)
|
||||
linebreak()
|
||||
print(df_quartile_slary)
|
||||
print(df_quartile_age)
|
||||
linebreak()
|
||||
print(df_trimmed_mean)
|
||||
linebreak()
|
||||
print(df_summary)
|
||||
linebreak()
|
||||
print(df_var)
|
||||
linebreak()
|
||||
print(df_null)
|
||||
@@ -0,0 +1,58 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import os
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy.stats import trim_mean
|
||||
from scipy.stats.mstats import mode, gmean, hmean
|
||||
from sklearn.model_selection import train_test_split
|
||||
import seaborn as sns
|
||||
|
||||
|
||||
def linebreak():
|
||||
"""prints a line break to split up functions"""
|
||||
print('\n ============================================== \n')
|
||||
|
||||
|
||||
matplotlib.rcParams['backend'] = 'TkAgg'
|
||||
# plt.style.use('seaborn-dark-palette')
|
||||
|
||||
path = os.getcwd()
|
||||
data_file = str('/data/Social_Network_Ads.csv')
|
||||
|
||||
df = pd.read_csv(path + data_file)
|
||||
|
||||
df = df.sample(frac=1).reset_index(drop=True)
|
||||
|
||||
print(df[0:5])
|
||||
|
||||
X = df[['Age', 'EstimatedSalary']]
|
||||
y = df['Purchased']
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
|
||||
|
||||
|
||||
# ax1 = df.plot.scatter(x='Age', y='EstimatedSalary', c='DarkBlue')
|
||||
# ax2 = df.query('Age < 30').plot.scatter(x='Age', y='EstimatedSalary',
|
||||
# c='DarkBlue')
|
||||
|
||||
|
||||
# figure_1 = df.query('Age < 35').plot(kind='scatter', x='Age',
|
||||
# y='EstimatedSalary')
|
||||
|
||||
df_purchased_sum = df['Purchased'].value_counts()
|
||||
|
||||
# figure_2 = plt.plot(df_purchased_sum)
|
||||
|
||||
# cp = sns.countplot(data=df, y='Purchased')
|
||||
|
||||
# pal = dict(1="seagreen", 0="gray")
|
||||
|
||||
fig, axs = plt.subplots(ncols=2)
|
||||
|
||||
sns.countplot(data=df, x='Age', hue='Purchased', ax=axs[0])
|
||||
cp = sns.countplot(data=df, x='Purchased', ax=axs[1])
|
||||
|
||||
plt.show()
|
||||
|
||||
# print(df_purchased_sum)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
https://medium.com/@urvashilluniya/why-data-normalization-is-necessary-for-machine-learning-models-681b65a05029
|
||||
|
||||
visualise data
|
||||
https://towardsdatascience.com/the-art-of-effective-visualization-of-multi-dimensional-data-6c7202990c57
|
||||
|
||||
https://www.marsja.se/pandas-python-descriptive-statistics/
|
||||
|
||||
https://www.marsja.se/explorative-data-analysis-with-pandas-scipy-and-seaborn/
|
||||
|
||||
|
||||
|
||||
deep learning https://towardsdatascience.com/detecting-malaria-with-deep-learning-9e45c1e34b60
|
||||
|
||||
likelihood functions https://stats.stackexchange.com/questions/2641/what-is-the-difference-between-likelihood-and-probability
|
||||
|
||||
|
||||
plotting with df and matplotlib
|
||||
https://nbviewer.jupyter.org/urls/gist.github.com/fonnesbeck/5850463/raw/a29d9ffb863bfab09ff6c1fc853e1d5bf69fe3e4/3.+Plotting+and+Visualization.ipynb
|
||||
https://towardsdatascience.com/a-guide-to-pandas-and-matplotlib-for-data-exploration-56fad95f951c
|
||||
|
||||
seaborne
|
||||
|
||||
vis the dist
|
||||
https://seaborn.pydata.org/tutorial/distributions.html
|
||||
|
||||
|
||||
pdfs
|
||||
https://stats.stackexchange.com/questions/14483/intuitive-explanation-for-density-of-transformed-variable
|
||||
|
||||
kernel
|
||||
https://mathisonian.github.io/kde/
|
||||
https://chemicalstatistician.wordpress.com/2013/06/09/exploratory-data-analysis-kernel-density-estimation-in-r-on-ozone-pollution-data-in-new-york-and-ozonopolis/
|
||||
https://www.quora.com/What-is-kernel-density-estimation
|
||||
choose bandwith so that it minimses the mean integrated square error so ban = min(MSIE)
|
||||
|
||||
|
||||
pandas plotting
|
||||
https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html
|
||||
|
||||
|
||||
class
|
||||
https://jeffknupp.com/blog/2017/03/27/improve-your-python-python-classes-and-object-oriented-programming/
|
||||
https://realpython.com/python3-object-oriented-programming/
|
||||
|
||||
errors
|
||||
https://doughellmann.com/blog/2009/06/19/python-exception-handling-techniques/
|
||||
|
||||
public + private members
|
||||
https://www.tutorialsteacher.com/python/private-and-protected-access-modifiers-in-python
|
||||
|
||||
properties
|
||||
https://www.programiz.com/python-programming/property
|
||||
|
||||
|
||||
generators
|
||||
https://pythontips.com/2013/09/29/the-python-yield-keyword-explained/
|
||||
https://www.programiz.com/python-programming/generator
|
||||
|
||||
class methods with inheritence
|
||||
https://stackoverflow.com/questions/5738470/whats-an-example-use-case-for-a-python-classmethod
|
||||
@@ -0,0 +1,6 @@
|
||||
from sklearn.cross_validation import train_test_split
|
||||
x_train, x_test, y_train, y_test = train_test_split(x, y , train_size = 0.7, random_state = 90)
|
||||
|
||||
normalizing methods : https://docs.microsoft.com/en-us/azure/machine-learning/studio-module-reference/normalize-data
|
||||
https://en.wikipedia.org/wiki/Feature_scaling
|
||||
we apply the normalizing methods to the training data first, then seperately to the test data to compare!
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,21 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import matplotlib.colors
|
||||
|
||||
x = np.linspace(-3, 3)
|
||||
X, Y = np.meshgrid(x, x)
|
||||
Z = np.exp(-(X**2 + Y**2))
|
||||
fig, (ax, ax2) = plt.subplots(ncols=2)
|
||||
|
||||
colors = ["red", "orange", "gold", "limegreen", "k",
|
||||
"#550011", "purple", "seagreen"]
|
||||
|
||||
ax.set_title("contour with color list")
|
||||
contour = ax.contourf(X, Y, Z, colors=colors)
|
||||
|
||||
ax2.set_title("contour with colormap")
|
||||
cmap = matplotlib.colors.ListedColormap(colors)
|
||||
contour = ax2.contourf(X, Y, Z, cmap=cmap)
|
||||
fig.colorbar(contour)
|
||||
|
||||
plt.show()
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
blocking_suggestions_2019-07-01T00.csv
|
||||
blocking_suggestions_2019-07-01T02.csv
|
||||
blocking_suggestions_2019-07-01T04.csv
|
||||
blocking_suggestions_2019-07-01T06.csv
|
||||
blocking_suggestions_2019-07-01T08.csv
|
||||
blocking_suggestions_2019-07-01T10.csv
|
||||
blocking_suggestions_2019-07-01T12.csv
|
||||
blocking_suggestions_2019-07-01T14.csv
|
||||
blocking_suggestions_2019-07-01T16.csv
|
||||
blocking_suggestions_2019-07-01T18.csv
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+167
@@ -0,0 +1,167 @@
|
||||
2019-07-01 21:27:23,774 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:27:23,775 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:27:24,113 - INFO - opening history file
|
||||
2019-07-01 21:27:24,113 - CRITICAL - history file cannot be found or created - check permissions of the folder.
|
||||
2019-07-01 21:28:25,693 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:28:25,693 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:28:26,137 - INFO - opening history file
|
||||
2019-07-01 21:28:26,137 - CRITICAL - history file cannot be found or created - check permissions of the folder.
|
||||
2019-07-01 21:28:55,767 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:28:55,767 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:28:56,074 - INFO - opening history file
|
||||
2019-07-01 21:28:56,075 - INFO - attempting to clear current files
|
||||
2019-07-01 21:28:56,075 - INFO - no files to remove
|
||||
2019-07-01 21:28:56,805 - INFO - downloaded blocking_suggestions_2019-07-01T00.csv
|
||||
2019-07-01 21:28:56,947 - INFO - downloaded blocking_suggestions_2019-07-01T02.csv
|
||||
2019-07-01 21:28:57,080 - INFO - downloaded blocking_suggestions_2019-07-01T04.csv
|
||||
2019-07-01 21:28:57,238 - INFO - downloaded blocking_suggestions_2019-07-01T06.csv
|
||||
2019-07-01 21:28:57,435 - INFO - downloaded blocking_suggestions_2019-07-01T08.csv
|
||||
2019-07-01 21:28:57,570 - INFO - downloaded blocking_suggestions_2019-07-01T10.csv
|
||||
2019-07-01 21:28:57,686 - INFO - downloaded blocking_suggestions_2019-07-01T12.csv
|
||||
2019-07-01 21:28:58,131 - INFO - downloaded blocking_suggestions_2019-07-01T14.csv
|
||||
2019-07-01 21:28:58,395 - INFO - downloaded blocking_suggestions_2019-07-01T16.csv
|
||||
2019-07-01 21:28:58,395 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 21:31:10,636 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:31:10,637 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:31:10,921 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:31:30,515 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:31:30,515 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:31:31,077 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:31:52,287 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:31:52,288 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:31:52,566 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:32:33,361 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:32:33,361 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:32:33,642 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:32:52,126 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:32:52,127 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:32:52,395 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:33:03,360 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:33:03,360 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:33:03,638 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:33:37,285 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:33:37,285 - INFO - path entered is blocking_suggestions/
|
||||
2019-07-01 21:33:37,571 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:33:59,988 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:33:59,988 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:34:00,308 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:34:34,827 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:34:34,827 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:34:35,107 - INFO - no files available to download -- exiting
|
||||
2019-07-01 21:34:48,900 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:34:48,900 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:34:49,188 - INFO - opening history file
|
||||
2019-07-01 21:34:49,189 - INFO - attempting to clear current files
|
||||
2019-07-01 21:34:49,189 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T14.csv
|
||||
2019-07-01 21:34:49,189 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T04.csv
|
||||
2019-07-01 21:34:49,190 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T16.csv
|
||||
2019-07-01 21:34:49,190 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T06.csv
|
||||
2019-07-01 21:34:49,190 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T00.csv
|
||||
2019-07-01 21:34:49,191 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T08.csv
|
||||
2019-07-01 21:34:49,191 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T12.csv
|
||||
2019-07-01 21:34:49,191 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T02.csv
|
||||
2019-07-01 21:34:49,191 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T10.csv
|
||||
2019-07-01 21:34:50,976 - INFO - downloaded test.json
|
||||
2019-07-01 21:34:50,976 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 21:35:10,779 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 21:35:10,779 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 21:35:11,169 - INFO - opening history file
|
||||
2019-07-01 21:35:11,169 - INFO - attempting to clear current files
|
||||
2019-07-01 21:35:11,170 - INFO - no files to remove
|
||||
2019-07-01 21:35:13,482 - INFO - downloaded results.2019-06-03_00:00.json
|
||||
2019-07-01 21:35:15,199 - INFO - downloaded results.2019-06-03_00:01.json
|
||||
2019-07-01 21:35:18,301 - INFO - downloaded results.2019-06-03_00:02.json
|
||||
2019-07-01 21:35:19,611 - INFO - downloaded results.2019-06-03_00:03.json
|
||||
2019-07-01 21:35:19,681 - INFO - downloaded results.2019-06-03_00:04.json
|
||||
2019-07-01 21:35:19,755 - INFO - downloaded results.2019-06-03_00:05.json
|
||||
2019-07-01 21:35:19,823 - INFO - downloaded results.2019-06-03_00:06.json
|
||||
2019-07-01 21:35:19,909 - INFO - downloaded results.2019-06-03_00:07.json
|
||||
2019-07-01 21:35:19,978 - INFO - downloaded results.2019-06-03_00:08.json
|
||||
2019-07-01 21:35:20,049 - INFO - downloaded results.2019-06-03_00:09.json
|
||||
2019-07-01 21:35:20,116 - INFO - downloaded results.2019-06-03_00:10.json
|
||||
2019-07-01 21:35:20,184 - INFO - downloaded results.2019-06-03_00:11.json
|
||||
2019-07-01 21:35:20,255 - INFO - downloaded results.2019-06-03_00:12.json
|
||||
2019-07-01 21:35:20,319 - INFO - downloaded results.2019-06-03_00:13.json
|
||||
2019-07-01 21:35:20,389 - INFO - downloaded results.2019-06-03_00:14.json
|
||||
2019-07-01 21:35:20,480 - INFO - downloaded results.2019-06-03_00:15.json
|
||||
2019-07-01 21:35:20,554 - INFO - downloaded results.2019-06-03_00:16.json
|
||||
2019-07-01 21:35:20,625 - INFO - downloaded results.2019-06-03_00:17.json
|
||||
2019-07-01 21:35:20,699 - INFO - downloaded results.2019-06-03_00:18.json
|
||||
2019-07-01 21:35:20,768 - INFO - downloaded results.2019-06-03_00:19.json
|
||||
2019-07-01 21:35:20,837 - INFO - downloaded results.2019-06-03_00:20.json
|
||||
2019-07-01 21:35:20,917 - INFO - downloaded results.2019-06-03_00:21.json
|
||||
2019-07-01 21:35:20,985 - INFO - downloaded results.2019-06-03_00:22.json
|
||||
2019-07-01 21:35:21,052 - INFO - downloaded results.2019-06-03_00:23.json
|
||||
2019-07-01 21:35:21,121 - INFO - downloaded results.2019-06-03_00:24.json
|
||||
2019-07-01 21:35:21,195 - INFO - downloaded results.2019-06-03_00:25.json
|
||||
2019-07-01 21:35:23,040 - INFO - downloaded results.2019-06-03_00:26.json
|
||||
2019-07-01 21:35:24,395 - INFO - downloaded results.2019-06-03_00:27.json
|
||||
2019-07-01 21:35:25,530 - INFO - downloaded results.2019-06-03_00:28.json
|
||||
2019-07-01 21:35:26,554 - INFO - downloaded results.2019-06-03_00:29.json
|
||||
2019-07-01 21:35:27,933 - INFO - downloaded results.2019-06-03_00:30.json
|
||||
2019-07-01 21:35:29,166 - INFO - downloaded results.2019-06-03_00:31.json
|
||||
2019-07-01 21:35:30,229 - INFO - downloaded results.2019-06-03_00:32.json
|
||||
2019-07-01 21:35:31,218 - INFO - downloaded results.2019-06-03_00:33.json
|
||||
2019-07-01 21:35:32,235 - INFO - downloaded results.2019-06-03_00:34.json
|
||||
2019-07-01 22:10:03,817 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:10:03,818 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:10:04,137 - INFO - no files available to download -- exiting
|
||||
2019-07-01 22:10:12,537 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:10:12,537 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:10:12,832 - INFO - opening history file
|
||||
2019-07-01 22:10:12,832 - INFO - attempting to clear current files
|
||||
2019-07-01 22:10:12,833 - INFO - no files to remove
|
||||
2019-07-01 22:10:13,506 - INFO - downloaded blocking_suggestions_2019-07-01T00.csv
|
||||
2019-07-01 22:10:13,672 - INFO - downloaded blocking_suggestions_2019-07-01T02.csv
|
||||
2019-07-01 22:10:13,778 - INFO - downloaded blocking_suggestions_2019-07-01T04.csv
|
||||
2019-07-01 22:10:13,901 - INFO - downloaded blocking_suggestions_2019-07-01T06.csv
|
||||
2019-07-01 22:10:14,100 - INFO - downloaded blocking_suggestions_2019-07-01T08.csv
|
||||
2019-07-01 22:10:14,210 - INFO - downloaded blocking_suggestions_2019-07-01T10.csv
|
||||
2019-07-01 22:10:14,316 - INFO - downloaded blocking_suggestions_2019-07-01T12.csv
|
||||
2019-07-01 22:10:14,474 - INFO - downloaded blocking_suggestions_2019-07-01T14.csv
|
||||
2019-07-01 22:10:14,709 - INFO - downloaded blocking_suggestions_2019-07-01T16.csv
|
||||
2019-07-01 22:10:14,841 - INFO - downloaded blocking_suggestions_2019-07-01T18.csv
|
||||
2019-07-01 22:10:14,842 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 22:10:21,141 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:10:21,141 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:10:21,465 - INFO - opening history file
|
||||
2019-07-01 22:10:21,466 - INFO - attempting to clear current files
|
||||
2019-07-01 22:10:21,467 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T14.csv
|
||||
2019-07-01 22:10:21,467 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T04.csv
|
||||
2019-07-01 22:10:21,467 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T16.csv
|
||||
2019-07-01 22:10:21,467 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T06.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T00.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T18.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T08.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T12.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T02.csv
|
||||
2019-07-01 22:10:21,468 - INFO - removed /home/dtomlinson/projects/boto3/blocking_suggestions/blocking_suggestions_2019-07-01T10.csv
|
||||
2019-07-01 22:10:21,469 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 22:10:28,475 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:10:28,475 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:10:28,757 - INFO - opening history file
|
||||
2019-07-01 22:10:28,757 - INFO - attempting to clear current files
|
||||
2019-07-01 22:10:28,759 - INFO - no files to remove
|
||||
2019-07-01 22:10:28,759 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 22:12:55,531 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:12:55,531 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:12:55,833 - INFO - opening history file
|
||||
2019-07-01 22:12:55,833 - INFO - attempting to clear current files
|
||||
2019-07-01 22:12:55,834 - INFO - no files to remove
|
||||
2019-07-01 22:12:55,834 - INFO - ========= SCRIPT FINISHED =========
|
||||
2019-07-01 22:13:07,271 - INFO - ========= SCRIPT STARTED =========
|
||||
2019-07-01 22:13:07,272 - INFO - no path entered, using current directory /home/dtomlinson/projects/boto3/blocking_suggestions/
|
||||
2019-07-01 22:13:07,571 - INFO - opening history file
|
||||
2019-07-01 22:13:07,572 - INFO - attempting to clear current files
|
||||
2019-07-01 22:13:07,572 - INFO - no files to remove
|
||||
2019-07-01 22:13:08,239 - INFO - downloaded blocking_suggestions_2019-07-01T00.csv
|
||||
2019-07-01 22:13:08,373 - INFO - downloaded blocking_suggestions_2019-07-01T02.csv
|
||||
2019-07-01 22:13:08,522 - INFO - downloaded blocking_suggestions_2019-07-01T04.csv
|
||||
2019-07-01 22:13:08,636 - INFO - downloaded blocking_suggestions_2019-07-01T06.csv
|
||||
2019-07-01 22:13:08,816 - INFO - downloaded blocking_suggestions_2019-07-01T08.csv
|
||||
2019-07-01 22:13:08,949 - INFO - downloaded blocking_suggestions_2019-07-01T10.csv
|
||||
2019-07-01 22:13:09,075 - INFO - downloaded blocking_suggestions_2019-07-01T12.csv
|
||||
2019-07-01 22:13:09,558 - INFO - downloaded blocking_suggestions_2019-07-01T14.csv
|
||||
2019-07-01 22:13:09,814 - INFO - downloaded blocking_suggestions_2019-07-01T16.csv
|
||||
2019-07-01 22:13:10,020 - INFO - downloaded blocking_suggestions_2019-07-01T18.csv
|
||||
2019-07-01 22:13:10,020 - INFO - ========= SCRIPT FINISHED =========
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
import boto3
|
||||
import botocore
|
||||
import os
|
||||
from datetime import date
|
||||
import sys
|
||||
import logging
|
||||
import argparse
|
||||
import glob
|
||||
|
||||
# Set Global Variables
|
||||
log_location = 'pull.log'
|
||||
|
||||
remote_folder = ['bot_predictions']
|
||||
remote_file_prefix = ['blocking_suggestions_']
|
||||
|
||||
append_date = [True]
|
||||
date_format = ['%Y-%m-%d']
|
||||
|
||||
bucket = ['td-ingest-storage-williamhill']
|
||||
access_key = ['AKIAYJXVWMRHQ2OGNHLA']
|
||||
secret_key = ['0/4wxdBmpiU3gK1QHLk4me0zj2RHuNAcSOfgJm1B']
|
||||
|
||||
|
||||
class downloadFiles(object):
|
||||
"""docstring for downloadFiles"""
|
||||
today = date.today()
|
||||
|
||||
def __init__(self,
|
||||
client,
|
||||
resource,
|
||||
bucket,
|
||||
remote_folder,
|
||||
remote_file_prefix,
|
||||
local_path,
|
||||
append_date=False,
|
||||
date_format=''):
|
||||
super(downloadFiles, self).__init__()
|
||||
self.client = client
|
||||
self.resource = resource
|
||||
self.bucket = bucket
|
||||
self.append_date = append_date
|
||||
self.date_format = date_format
|
||||
self.remote_folder = self._folder_fixer(remote_folder)
|
||||
self.dest = f'{self.remote_folder!s}{remote_file_prefix!s}'
|
||||
self.local_path = local_path
|
||||
self.remote_list, self.local_list, self.local_file_list = \
|
||||
(list() for _ in range(3))
|
||||
|
||||
@staticmethod
|
||||
def generate_date(date_format):
|
||||
date = downloadFiles.today.strftime(date_format)
|
||||
return date
|
||||
|
||||
@staticmethod
|
||||
def _folder_fixer(folder):
|
||||
try:
|
||||
if folder[-1] != '/':
|
||||
folder = f'{folder}/'
|
||||
except IndexError:
|
||||
folder = ''
|
||||
return folder
|
||||
|
||||
def get_path(self):
|
||||
if self.local_path:
|
||||
self.local_path = self._folder_fixer(self.local_path)
|
||||
logger.info(f'path entered is {self.local_path}')
|
||||
return self
|
||||
else:
|
||||
self.local_path = os.getcwd()
|
||||
self.local_path = self._folder_fixer(self.local_path)
|
||||
self.local_path = f'{self.local_path}blocking_suggestions/'
|
||||
logger.info(f'no path entered, using current directory '
|
||||
f'{self.local_path}')
|
||||
return self
|
||||
|
||||
def get_files(self):
|
||||
if self.append_date:
|
||||
date = f'{self.generate_date(self.date_format)!s}'
|
||||
else:
|
||||
date = ''
|
||||
self.dest = f'{self.dest!s}{date!s}'
|
||||
|
||||
paginator = self.client.get_paginator('list_objects')
|
||||
iterator = paginator.paginate(Bucket=self.bucket, Prefix=self.dest)
|
||||
self.filtered = iterator.search('Contents[*].Key')
|
||||
for i in self.filtered:
|
||||
try:
|
||||
self.remote_list.append(i)
|
||||
self.local_list.append(
|
||||
f'{self.local_path}{i[len(self.remote_folder):]}'
|
||||
)
|
||||
self.local_file_list.append(
|
||||
f'{i[len(self.remote_folder):]}'
|
||||
)
|
||||
except TypeError:
|
||||
logger.info('no files available to download -- exiting')
|
||||
raise SystemExit
|
||||
logger.debug(f'remote files are {self.remote_list}')
|
||||
logger.debug(f'saving files locally to {self.local_list}')
|
||||
return self
|
||||
|
||||
def get_history(self):
|
||||
self.history_file = f'{self.local_path}.history.txt'
|
||||
try:
|
||||
logger.info('opening history file')
|
||||
open(self.history_file, 'a').close()
|
||||
pass
|
||||
except FileNotFoundError:
|
||||
logger.critical('history file cannot be found or created'
|
||||
' - check permissions of the folder.')
|
||||
raise
|
||||
self.history_list = \
|
||||
[line.rstrip('\n') for line in open(self.history_file)]
|
||||
return self
|
||||
|
||||
def remove_files(self):
|
||||
logger.info('attempting to clear current files')
|
||||
current_files = glob.glob(f'{self.local_path}[!history.txt]*')
|
||||
if current_files:
|
||||
for i in current_files:
|
||||
try:
|
||||
os.remove(i)
|
||||
logger.info(f'removed {i}')
|
||||
except OSError:
|
||||
logger.exception('Error:')
|
||||
else:
|
||||
logger.info('no files to remove')
|
||||
return self
|
||||
|
||||
def download_files(self):
|
||||
for remote_file, local_file_with_path, local_file in zip(
|
||||
self.remote_list, self.local_list, self.local_file_list):
|
||||
if local_file not in self.history_list:
|
||||
with open(local_file_with_path, 'wb'), \
|
||||
open(self.history_file, 'a') as hist:
|
||||
try:
|
||||
self.resource.Bucket(self.bucket).download_file(
|
||||
remote_file, local_file_with_path)
|
||||
hist.write(f'\n{local_file}')
|
||||
logger.info(f'downloaded {local_file}')
|
||||
except botocore.exceptions.ClientError as e:
|
||||
if e.response['Error']['Code'] == '404':
|
||||
print(f'The object {remote_file} does not exist.')
|
||||
else:
|
||||
raise
|
||||
if local_file in self.history_list:
|
||||
logger.debug(f'{local_file} already downloaded - skipping')
|
||||
return self
|
||||
|
||||
|
||||
def _call():
|
||||
global args, debug
|
||||
parser = argparse.ArgumentParser(description="""
|
||||
downloads any new files for the current day from an S3 bucket. \
|
||||
uses a local history file to track what has been \
|
||||
previously downloaded in the download path.
|
||||
""")
|
||||
parser.add_argument('--path', type=str,
|
||||
help='enter pull path to download to. if left \
|
||||
blank will use the same location as the script.',
|
||||
default='')
|
||||
parser.add_argument('--debug', action='store_true', default=False,
|
||||
help='Use this to log DEBUG information.')
|
||||
|
||||
args = parser.parse_args()
|
||||
debug = vars(args)['debug']
|
||||
|
||||
if debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
main(_clients=_clients,
|
||||
_resources=_resources,
|
||||
_buckets=_buckets,
|
||||
remote_folder=remote_folder,
|
||||
remote_file_prefix=remote_file_prefix,
|
||||
append_date=append_date,
|
||||
date_format=date_format,
|
||||
**vars(args))
|
||||
|
||||
|
||||
def main(*args,
|
||||
_clients={'client0': ''},
|
||||
_resources={'resource0': ''},
|
||||
_buckets={'bucket0': ''},
|
||||
remote_folder=[''],
|
||||
remote_file_prefix=[''],
|
||||
append_date=['True'],
|
||||
date_format=[''],
|
||||
path='',
|
||||
**kwargs):
|
||||
logger.info('========= SCRIPT STARTED =========')
|
||||
instance = downloadFiles(client=_clients['client0'],
|
||||
resource=_resources['resource0'],
|
||||
bucket=_buckets['bucket0'],
|
||||
remote_folder=remote_folder[0],
|
||||
remote_file_prefix=remote_file_prefix[0],
|
||||
local_path=path,
|
||||
append_date=append_date[0],
|
||||
date_format=date_format[0])
|
||||
instance.get_path().get_files().get_history().remove_files()\
|
||||
.download_files()
|
||||
logger.info('========= SCRIPT FINISHED =========')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args, debug = '', ''
|
||||
|
||||
# define logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
c_handler = logging.StreamHandler(sys.stdout)
|
||||
f_handler = logging.FileHandler(log_location)
|
||||
|
||||
c_format = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
f_format = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
c_handler.setFormatter(c_format)
|
||||
f_handler.setFormatter(f_format)
|
||||
|
||||
logger.addHandler(c_handler)
|
||||
logger.addHandler(f_handler)
|
||||
|
||||
_clients = {}
|
||||
_resources = {}
|
||||
_buckets = {}
|
||||
|
||||
for i in range(0, len(bucket)):
|
||||
_clients[f'client{i}'] =\
|
||||
boto3.client('s3',
|
||||
aws_access_key_id=f'{access_key[i]}',
|
||||
aws_secret_access_key=f'{secret_key[i]}')
|
||||
_resources[f'resource{i}'] =\
|
||||
boto3.resource('s3',
|
||||
aws_access_key_id=f'{access_key[i]}',
|
||||
aws_secret_access_key=f'{secret_key[i]}')
|
||||
_buckets[f'bucket{i}'] = f'{bucket[i]}'
|
||||
|
||||
try:
|
||||
_length = len(remote_folder)
|
||||
if _length == 0:
|
||||
remote_folder = ['']
|
||||
elif remote_folder[0] == 'root':
|
||||
remote_folder = ['']
|
||||
else:
|
||||
pass
|
||||
except NameError:
|
||||
remote_folder = ['']
|
||||
_call()
|
||||
@@ -0,0 +1,23 @@
|
||||
#!~/.virtualenvs/learning/bin/python
|
||||
|
||||
|
||||
class Customer(object):
|
||||
"""example class defining a customer deposit and withdraw methods
|
||||
for a bank.
|
||||
|
||||
Attributes:
|
||||
name: A string represnting the customer's name
|
||||
balance: A float tracking the current balance of the customer."""
|
||||
|
||||
def __init__(self, name, balance, list):
|
||||
super(Customer, self).__init__()
|
||||
self.name = name
|
||||
self.balance = balance
|
||||
self.list = list
|
||||
print(self.name)
|
||||
print(self.balance)
|
||||
for i in range(len(self.list)):
|
||||
print(self.list[i])
|
||||
|
||||
|
||||
Customer('Homer', 200, ['100', '102', '103'])
|
||||
@@ -0,0 +1 @@
|
||||
https://jeffknupp.com/blog/2017/03/27/improve-your-python-python-classes-and-object-oriented-programming/
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
from decorator import timer, debug, repeatN, repeat_partial, count_calls, \
|
||||
Counter, Slow, slowDown
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
class TimeWaster(object):
|
||||
@debug
|
||||
def __init__(self, max_num: int):
|
||||
super(TimeWaster, self).__init__()
|
||||
self.max_num = max_num
|
||||
|
||||
@timer
|
||||
def waste_time(self, num_times: int):
|
||||
for _ in range(num_times):
|
||||
sum([i ** 2 for i in range(self.max_num)])
|
||||
|
||||
|
||||
@timer
|
||||
@dataclass
|
||||
class PlayingCard(object):
|
||||
rank: str
|
||||
suit: str
|
||||
|
||||
|
||||
@repeatN
|
||||
def say_hello(name: str):
|
||||
print(f'Hello, {name}.')
|
||||
|
||||
|
||||
@repeatN(num=5)
|
||||
def say_hi(name: str):
|
||||
print(f'Hi, {name}.')
|
||||
|
||||
|
||||
@repeat_partial(num=10)
|
||||
def say_yo(name: str):
|
||||
print(f'Yo, {name}!')
|
||||
|
||||
|
||||
@count_calls
|
||||
def say_whee():
|
||||
print('Whee!')
|
||||
|
||||
|
||||
@Counter
|
||||
def say_howdy():
|
||||
print('Howdy!')
|
||||
|
||||
|
||||
@slowDown()
|
||||
def count_down(num: int):
|
||||
if not isinstance(num, int):
|
||||
raise TypeError("Must input an integer.")
|
||||
if num >= 1:
|
||||
print(num)
|
||||
count_down(num - 1)
|
||||
else:
|
||||
print('Liftoff!')
|
||||
@@ -0,0 +1,72 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
import decorator
|
||||
from itertools import repeat
|
||||
|
||||
# @slowDown(1)
|
||||
# def count_down(num: int):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count_down(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# @Counter
|
||||
# def say_howdy():
|
||||
# print('Howdy!')
|
||||
|
||||
|
||||
class tester(object):
|
||||
@decorator.slowDown()
|
||||
def count(self, num):
|
||||
if not isinstance(num, int):
|
||||
raise TypeError("Must input an integer.")
|
||||
if num >= 1:
|
||||
print(num)
|
||||
self.count(num - 1)
|
||||
else:
|
||||
print('Liftoff!')
|
||||
|
||||
# print()
|
||||
# var = tester()
|
||||
# var.count(1)
|
||||
|
||||
|
||||
# @decorator.slowDown()
|
||||
# def count(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# print()
|
||||
# count(3)
|
||||
|
||||
# @decorator.slowDown
|
||||
# def count(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# @slowDown
|
||||
# def countme(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# countme(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
Executable
+204
@@ -0,0 +1,204 @@
|
||||
import itertools
|
||||
import functools
|
||||
from time import perf_counter, sleep
|
||||
import sys
|
||||
|
||||
|
||||
def do_twice(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
for _ in itertools.repeat(None, 2):
|
||||
func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
def timer(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_timer(*args, **kwargs):
|
||||
start_time = perf_counter()
|
||||
value = func(*args, **kwargs)
|
||||
end_time = perf_counter()
|
||||
run_time = end_time - start_time
|
||||
print(f'Finished {func.__name__!r} in {run_time:.4f} secs')
|
||||
return value
|
||||
return wrapper_timer
|
||||
|
||||
|
||||
def debug(func):
|
||||
""" Print the function signature and return the value """
|
||||
@functools.wraps(func)
|
||||
def wrapper_debug(*args, **kwargs):
|
||||
args_repr = [repr(a) for a in args]
|
||||
kwargs_repr = [f'{k}={v!r}' for k, v in kwargs.items()]
|
||||
signature = ', '.join(args_repr + kwargs_repr)
|
||||
print(f'Calling {func.__name__}({signature})')
|
||||
value = func(*args, **kwargs)
|
||||
print(f'{func.__name__!r} returned {value!r}')
|
||||
return value
|
||||
return wrapper_debug
|
||||
|
||||
|
||||
def slow_down(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_slow_down(*args, **kwargs):
|
||||
sleep(1)
|
||||
return func(*args, **kwargs)
|
||||
return wrapper_slow_down
|
||||
|
||||
|
||||
def repeat(num: int):
|
||||
def decorator_repeat(func: callable):
|
||||
@functools.wraps(func)
|
||||
def wrapper_repeat(*args: list, **kwargs: dict):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return wrapper_repeat
|
||||
return decorator_repeat
|
||||
|
||||
|
||||
def repeatN(_func=None, *, num=2):
|
||||
def decorator_repeatN(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_repeatN(*args, **kwargs):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return wrapper_repeatN
|
||||
|
||||
if _func is None:
|
||||
return decorator_repeatN
|
||||
else:
|
||||
return decorator_repeatN(_func)
|
||||
|
||||
|
||||
def repeat_partial(func=None, *, num=2):
|
||||
if func is None:
|
||||
return functools.partial(repeat_partial, num=num)
|
||||
|
||||
@functools.wraps(func)
|
||||
def repeat_partial_wrapper(*args, **kwargs):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return repeat_partial_wrapper
|
||||
|
||||
|
||||
# def count_calls(func: callable):
|
||||
# @functools.wraps(func)
|
||||
# def wrapper_count_calls(*args, **kwargs):
|
||||
# wrapper_count_calls.num_calls += 1
|
||||
# print(f'Call {wrapper_count_calls.num_calls} of {func.__name__!r}')
|
||||
# return func(*args, **kwargs)
|
||||
# wrapper_count_calls.num_calls = 0
|
||||
# print(wrapper_count_calls.num_calls)
|
||||
# return wrapper_count_calls
|
||||
|
||||
|
||||
# def count_calls(func: callable):
|
||||
# num_calls = 0
|
||||
# print(num_calls)
|
||||
# @functools.wraps(func)
|
||||
# def wrapper_count_calls(*args, **kwargs):
|
||||
# nonlocal num_calls
|
||||
# num_calls += 1
|
||||
# print(f'Call {num_calls} of {func.__name__}')
|
||||
# return func(*args, **kwargs)
|
||||
# return wrapper_count_calls
|
||||
|
||||
|
||||
def count_calls(func=None, *, num=0):
|
||||
if func is None:
|
||||
return functools.partial(count_calls, num=num)
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper_count_calls(*args, **kwargs):
|
||||
wrapper_count_calls.num += 1
|
||||
print(f'Call {wrapper_count_calls.num} of {func.__name__}')
|
||||
return func(*args, **kwargs)
|
||||
wrapper_count_calls.num = num
|
||||
return wrapper_count_calls
|
||||
|
||||
|
||||
class Counter(object):
|
||||
"""docstring for Counter"""
|
||||
def __init__(self, func):
|
||||
print('start init')
|
||||
super(Counter, self).__init__()
|
||||
functools.update_wrapper(self, func)
|
||||
self.func = func
|
||||
self.num_calls = 0
|
||||
print('finished init')
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
print('start call')
|
||||
self.num_calls += 1
|
||||
print(f'Call {self.num_calls} of {self.func.__name__!r}')
|
||||
print('finished call')
|
||||
return self.func(*args, **kwargs)
|
||||
|
||||
|
||||
# class slowDown(object):
|
||||
# """docstring for slowDown"""
|
||||
# def __init__(self, rate):
|
||||
# if callable(rate):
|
||||
# self.func = rate
|
||||
# self.rate = 1
|
||||
# else:
|
||||
# self.rate = rate
|
||||
|
||||
# def __get__(self, obj, type=None):
|
||||
# return functools.partial(self, obj)
|
||||
|
||||
# def __call__(self, *args, **kwargs):
|
||||
# if not hasattr(self, 'func'):
|
||||
# self.func = args[0]
|
||||
# return self
|
||||
# sleep(self.rate)
|
||||
# self.func(*args, **kwargs)
|
||||
|
||||
|
||||
class slowDown(object):
|
||||
"""docstring for Slow_Down"""
|
||||
def __init__(self, rate=1):
|
||||
print('init')
|
||||
self.rate = rate
|
||||
|
||||
def __call__(self, func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
print('wrapper')
|
||||
sleep(self.rate)
|
||||
func(*args, **kwargs)
|
||||
print('call finished')
|
||||
print(self, func)
|
||||
return wrapper
|
||||
|
||||
|
||||
# class slowDown(object):
|
||||
# """docstring for slowDown"""
|
||||
# def __init__(self, rate):
|
||||
# if callable(rate):
|
||||
# self.func = rate
|
||||
# self.rate = 1
|
||||
# print(f'no args, {locals()}, func={self.func}, rate={self.rate},\
|
||||
# self={self}')
|
||||
# else:
|
||||
# self.rate = rate
|
||||
# print(f'args set, rate={self.rate}')
|
||||
|
||||
# def __get__(self, obj, type=None):
|
||||
# print(f'get called, self={self}, obj={obj}, type={type}')
|
||||
# return functools.partial(self, obj)
|
||||
|
||||
# def __call__(self, *args, **kwargs):
|
||||
# print(f'call called, rate={self.rate}, args={args}'
|
||||
# f', kwargs={kwargs} ,self={self}')
|
||||
# print(f'locals = {locals()}')
|
||||
# if not hasattr(self, 'func'):
|
||||
# self.func = args[0]
|
||||
# print(f'args set, setting self.func to {self.func}')
|
||||
# return self
|
||||
# sleep(self.rate)
|
||||
# self.func(*args, **kwargs)
|
||||
@@ -0,0 +1,58 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
from decorator import timer, debug, slow_down
|
||||
import math
|
||||
import random
|
||||
|
||||
|
||||
PLUGINS = dict()
|
||||
|
||||
|
||||
@timer
|
||||
def waste_time(num):
|
||||
for _ in range(num):
|
||||
sum([i ** 2 for i in range(10000)])
|
||||
|
||||
|
||||
@debug
|
||||
def make_greeting(first_name, age: int):
|
||||
return f'Hello {first_name}, you are {age}!'
|
||||
|
||||
|
||||
math.factorial = debug(math.factorial)
|
||||
|
||||
|
||||
def approximate_e(terms):
|
||||
return sum(1 / math.factorial(n) for n in range(terms))
|
||||
|
||||
|
||||
@slow_down
|
||||
def countdown(num: int):
|
||||
if num < 1:
|
||||
print('Liftoff!')
|
||||
else:
|
||||
print(num)
|
||||
countdown(num - 1)
|
||||
|
||||
|
||||
def register(func):
|
||||
"""Register a function as a plug-in"""
|
||||
PLUGINS[func.__name__] = func
|
||||
return func
|
||||
|
||||
|
||||
@register
|
||||
def say_hello(name: str) -> str:
|
||||
return f'Hello {name}'
|
||||
|
||||
|
||||
@register
|
||||
def be_awesome(name: str) -> str:
|
||||
return f'Yo {name}, together we are awesome!'
|
||||
|
||||
|
||||
def randomly_greet(name):
|
||||
greeter, greeter_func = random.choice(list(PLUGINS.items()))
|
||||
print(f'Using {greeter!r}')
|
||||
return greeter_func(name)
|
||||
@@ -0,0 +1,13 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
import decorator
|
||||
import functools
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=4)
|
||||
@decorator.count_calls
|
||||
def fib(num):
|
||||
if num < 2:
|
||||
return num
|
||||
return fib(num - 1) + fib(num - 2)
|
||||
@@ -0,0 +1,18 @@
|
||||
class Person(object):
|
||||
"""docstring for Person"""
|
||||
def __init__(self, name, age):
|
||||
super(Person, self).__init__()
|
||||
self.name = name
|
||||
self.age = age
|
||||
|
||||
@property
|
||||
def age(self):
|
||||
print('old enough')
|
||||
return self.__age
|
||||
|
||||
@age.setter
|
||||
def age(self, value):
|
||||
if value < 21:
|
||||
raise Exception(f'{self.name} is not old enough.')
|
||||
else:
|
||||
self.__age = value
|
||||
@@ -0,0 +1,37 @@
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
|
||||
class Drinker:
|
||||
def __init__(self):
|
||||
self.req_age = 21
|
||||
self.age = dict()
|
||||
print('init')
|
||||
|
||||
def __get__(self, instance_obj, objtype):
|
||||
print(f'{instance_obj}, {objtype}, {self.age}')
|
||||
return self.age.get(instance_obj, self.req_age)
|
||||
|
||||
def __set__(self, instance, new_age):
|
||||
if new_age < 21:
|
||||
msg = '{name} is too young to legally imbibe'
|
||||
raise Exception(msg.format(name=instance.name))
|
||||
self.age[instance] = new_age
|
||||
print('{name} can legally drink in the USA'.format(
|
||||
name=instance.name))
|
||||
|
||||
def __delete__(self, instance):
|
||||
del self.age[instance]
|
||||
|
||||
|
||||
class Person:
|
||||
drinker_age = Drinker()
|
||||
|
||||
def __init__(self, name, age):
|
||||
self.name = name
|
||||
self.drinker_age = age
|
||||
|
||||
|
||||
p = Person('Miguel', 30)
|
||||
p1 = Person('Bob', 50)
|
||||
|
||||
p = Person('Niki', 13)
|
||||
@@ -0,0 +1,16 @@
|
||||
class P(object):
|
||||
def __init__(self, x):
|
||||
self._x = x
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, x):
|
||||
if x < 0:
|
||||
self._x = 0
|
||||
elif x > 1000:
|
||||
self._x = 1000
|
||||
else:
|
||||
self._x = x
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
2019-06-13 22:23:19,920 - CRITICAL - Critical message
|
||||
2019-06-13 22:26:08,285 - DEBUG - Critical message
|
||||
2019-06-13 22:26:12,263 - DEBUG - Critical message
|
||||
2019-06-13 22:26:13,688 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,120 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,499 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,990 - DEBUG - Critical message
|
||||
2019-06-13 22:26:15,361 - DEBUG - Critical message
|
||||
2019-06-13 22:27:00,510 - ERROR - Critical message
|
||||
2019-06-13 22:27:45,847 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,242 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,513 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,770 - ERROR - Critical message
|
||||
2019-06-13 22:27:47,018 - ERROR - Critical message
|
||||
2019-06-13 22:27:47,534 - ERROR - Critical message
|
||||
2019-06-13 22:27:52,098 - CRITICAL - Critical message
|
||||
2019-06-13 22:27:52,678 - CRITICAL - Critical message
|
||||
2019-06-13 22:27:52,918 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:24,770 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,180 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,487 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,760 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,184 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,538 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,932 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:27,301 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:27,690 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:33,666 - ERROR - Critical message
|
||||
2019-06-13 22:28:34,203 - ERROR - Critical message
|
||||
2019-06-13 22:28:34,414 - ERROR - Critical message
|
||||
2019-06-13 22:28:58,465 - ERROR - Critical message
|
||||
2019-06-13 22:28:58,917 - ERROR - Critical message
|
||||
2019-06-13 22:28:59,138 - ERROR - Critical message
|
||||
2019-06-13 22:29:02,335 - INFO - Critical message
|
||||
@@ -0,0 +1,14 @@
|
||||
def my_decorator(func):
|
||||
def wrapper():
|
||||
print('Something happening before the func is called.')
|
||||
func()
|
||||
print('Something happening after the func is called.')
|
||||
return wrapper
|
||||
|
||||
|
||||
@my_decorator
|
||||
def say_whee():
|
||||
print('Whee!')
|
||||
|
||||
|
||||
say_whee()
|
||||
@@ -0,0 +1,23 @@
|
||||
import argparse
|
||||
|
||||
|
||||
def main(folder, *args, **kwargs):
|
||||
my_path = folder
|
||||
print(my_path)
|
||||
print(f"script2 kwargs {kwargs}")
|
||||
print('end of script2.py')
|
||||
|
||||
|
||||
def call():
|
||||
global arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--path', type=str, default='')
|
||||
parser.add_argument('--folder', type=str, default='test-folder')
|
||||
arguments = parser.parse_args()
|
||||
main(**vars(arguments))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = ''
|
||||
call()
|
||||
# print(f"final {arguments}")
|
||||
@@ -0,0 +1,21 @@
|
||||
import script1
|
||||
import argparse
|
||||
|
||||
|
||||
def main(**kwargs):
|
||||
# print(vars(arguments))
|
||||
script1.main(**vars(arguments))
|
||||
|
||||
|
||||
def call():
|
||||
global arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--path', type=str, default='test-path')
|
||||
parser.add_argument('--folder', type=str, default='test-folder')
|
||||
arguments = parser.parse_args()
|
||||
main(**vars(arguments))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = ''
|
||||
call()
|
||||
@@ -0,0 +1,839 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"drin",
|
||||
"drinker_age"
|
||||
],
|
||||
[
|
||||
"x",
|
||||
"__x"
|
||||
],
|
||||
[
|
||||
"cla",
|
||||
"class\tNew Class"
|
||||
],
|
||||
[
|
||||
"ge",
|
||||
"get_x"
|
||||
],
|
||||
[
|
||||
"tester",
|
||||
"tester1"
|
||||
],
|
||||
[
|
||||
"clas",
|
||||
"class\tNew Class"
|
||||
],
|
||||
[
|
||||
"int",
|
||||
"int\tclass"
|
||||
],
|
||||
[
|
||||
"set",
|
||||
"setattr\tfunction"
|
||||
],
|
||||
[
|
||||
"st",
|
||||
"Standalone"
|
||||
],
|
||||
[
|
||||
"M",
|
||||
"MyClass\tclass"
|
||||
],
|
||||
[
|
||||
"m",
|
||||
"my_printer\tstatement"
|
||||
],
|
||||
[
|
||||
"from",
|
||||
"fromBirthYear\tfunction"
|
||||
],
|
||||
[
|
||||
"class",
|
||||
"classmethod\tclass"
|
||||
],
|
||||
[
|
||||
"par",
|
||||
"partialmethod\tclass"
|
||||
],
|
||||
[
|
||||
"db",
|
||||
"initialize_db"
|
||||
],
|
||||
[
|
||||
"get",
|
||||
"getattr\tfunction"
|
||||
],
|
||||
[
|
||||
"name",
|
||||
"__name__"
|
||||
],
|
||||
[
|
||||
"__get",
|
||||
"__getattribute__\tfunction"
|
||||
],
|
||||
[
|
||||
"kwargs",
|
||||
"kwargs"
|
||||
],
|
||||
[
|
||||
"func",
|
||||
"functools\tmodule"
|
||||
],
|
||||
[
|
||||
"wra",
|
||||
"wrapper_slow_down\tfunction"
|
||||
],
|
||||
[
|
||||
"slo",
|
||||
"slowDownDecorator\tclass"
|
||||
],
|
||||
[
|
||||
"slow",
|
||||
"slowDown\tclass"
|
||||
],
|
||||
[
|
||||
"init",
|
||||
"init"
|
||||
],
|
||||
[
|
||||
"call",
|
||||
"callable"
|
||||
],
|
||||
[
|
||||
"Slo",
|
||||
"Slow_Down_Decorator\tclass"
|
||||
],
|
||||
[
|
||||
"Slow",
|
||||
"Slow_Down\tclass"
|
||||
],
|
||||
[
|
||||
"partial",
|
||||
"partial\tclass"
|
||||
],
|
||||
[
|
||||
"coun",
|
||||
"count_down\tfunction"
|
||||
],
|
||||
[
|
||||
"num",
|
||||
"num_calls\tstatement"
|
||||
],
|
||||
[
|
||||
"sum",
|
||||
"sum_squares"
|
||||
],
|
||||
[
|
||||
"y",
|
||||
"y_total"
|
||||
],
|
||||
[
|
||||
"wrapper",
|
||||
"wrapper_count_calls\tfunction"
|
||||
],
|
||||
[
|
||||
"n",
|
||||
"num_calls"
|
||||
],
|
||||
[
|
||||
"str",
|
||||
"str\tclass"
|
||||
],
|
||||
[
|
||||
"repea",
|
||||
"repeat_partial\tfunction"
|
||||
],
|
||||
[
|
||||
"parti",
|
||||
"repeat_partial_wrapper"
|
||||
],
|
||||
[
|
||||
"repeat",
|
||||
"repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"dec",
|
||||
"decorator_repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"wrapper_rep",
|
||||
"wrapper_repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"de",
|
||||
"decorator_repeat\tfunction"
|
||||
],
|
||||
[
|
||||
"Call",
|
||||
"callable\tfunction"
|
||||
],
|
||||
[
|
||||
"R",
|
||||
"ReferenceError\tclass"
|
||||
],
|
||||
[
|
||||
"gree",
|
||||
"greeter_func\tstatement"
|
||||
],
|
||||
[
|
||||
"re",
|
||||
"return\tkeyword"
|
||||
],
|
||||
[
|
||||
"wrap",
|
||||
"wrapper_debug\tfunction"
|
||||
],
|
||||
[
|
||||
"__",
|
||||
"__name__"
|
||||
],
|
||||
[
|
||||
"kw",
|
||||
"kwargs_repr\tstatement"
|
||||
],
|
||||
[
|
||||
"args",
|
||||
"args_repr"
|
||||
],
|
||||
[
|
||||
"no",
|
||||
"not_during_the_night\tfunction"
|
||||
],
|
||||
[
|
||||
"ex",
|
||||
"executable\tinstance"
|
||||
],
|
||||
[
|
||||
"script",
|
||||
"script_file\tstatement"
|
||||
],
|
||||
[
|
||||
"sc",
|
||||
"script_file\tstatement"
|
||||
],
|
||||
[
|
||||
"Ke",
|
||||
"KeyError\tclass"
|
||||
],
|
||||
[
|
||||
"folder",
|
||||
"folder"
|
||||
],
|
||||
[
|
||||
"ar",
|
||||
"arguments\tstatement"
|
||||
],
|
||||
[
|
||||
"local",
|
||||
"locals_val\tstatement"
|
||||
],
|
||||
[
|
||||
"arguments",
|
||||
"arguments"
|
||||
],
|
||||
[
|
||||
"sctr",
|
||||
"script2_main\tfunction"
|
||||
],
|
||||
[
|
||||
"f",
|
||||
"f"
|
||||
],
|
||||
[
|
||||
"X",
|
||||
"X_train"
|
||||
],
|
||||
[
|
||||
"read_",
|
||||
"read_excel\tfunction"
|
||||
],
|
||||
[
|
||||
"read",
|
||||
"read_csv\tfunction"
|
||||
],
|
||||
[
|
||||
"is",
|
||||
"is_tasty"
|
||||
],
|
||||
[
|
||||
"li",
|
||||
"list_ingredients\tparam"
|
||||
],
|
||||
[
|
||||
"prin",
|
||||
"print_sound"
|
||||
],
|
||||
[
|
||||
"w",
|
||||
"wheels"
|
||||
],
|
||||
[
|
||||
"pr",
|
||||
"print_sound"
|
||||
],
|
||||
[
|
||||
"date",
|
||||
"datetime\tclass"
|
||||
],
|
||||
[
|
||||
"p",
|
||||
"print_wheels\tfunction"
|
||||
],
|
||||
[
|
||||
"File",
|
||||
"FileNotFoundError\tclass"
|
||||
],
|
||||
[
|
||||
"borg",
|
||||
"borg"
|
||||
],
|
||||
[
|
||||
"log",
|
||||
"log"
|
||||
],
|
||||
[
|
||||
"conver",
|
||||
"convert_to_uppercase\tfunction"
|
||||
],
|
||||
[
|
||||
"hell",
|
||||
"hellow_world\tstatement"
|
||||
],
|
||||
[
|
||||
"__m",
|
||||
"__name__\tinstance"
|
||||
],
|
||||
[
|
||||
"fu",
|
||||
"func\tparam"
|
||||
],
|
||||
[
|
||||
"fun",
|
||||
"functools\tmodule"
|
||||
],
|
||||
[
|
||||
"funct",
|
||||
"function_call\tfunction"
|
||||
],
|
||||
[
|
||||
"d",
|
||||
"double_volume\tfunction"
|
||||
],
|
||||
[
|
||||
"s",
|
||||
"surface_area\tfunction"
|
||||
],
|
||||
[
|
||||
"new",
|
||||
"new_length\tparam"
|
||||
],
|
||||
[
|
||||
"Cube",
|
||||
"Cube"
|
||||
],
|
||||
[
|
||||
"area",
|
||||
"area_2\tfunction"
|
||||
],
|
||||
[
|
||||
"tri",
|
||||
"tri_area\tfunction"
|
||||
],
|
||||
[
|
||||
"triangle",
|
||||
"triangle_area\tstatement"
|
||||
],
|
||||
[
|
||||
"bas",
|
||||
"base_area\tstatement"
|
||||
],
|
||||
[
|
||||
"r",
|
||||
"return_colour\tfunction"
|
||||
],
|
||||
[
|
||||
"sl",
|
||||
"slant_height\tparam"
|
||||
],
|
||||
[
|
||||
"heigh",
|
||||
"height_tripled\tfunction"
|
||||
],
|
||||
[
|
||||
"h",
|
||||
"height_doubled\tfunction"
|
||||
],
|
||||
[
|
||||
"__in",
|
||||
"__init__\tfunction"
|
||||
],
|
||||
[
|
||||
"ba",
|
||||
"base_area"
|
||||
],
|
||||
[
|
||||
"garb",
|
||||
"garbage_check\tfunction"
|
||||
],
|
||||
[
|
||||
"len",
|
||||
"length\tparam"
|
||||
],
|
||||
[
|
||||
"__init",
|
||||
"__init_subclass__\tfunction"
|
||||
],
|
||||
[
|
||||
"Square",
|
||||
"Square\tclass"
|
||||
],
|
||||
[
|
||||
"se",
|
||||
"self"
|
||||
],
|
||||
[
|
||||
"list",
|
||||
"list_of_ips\tstatement"
|
||||
],
|
||||
[
|
||||
"su",
|
||||
"sub_list\tstatement"
|
||||
],
|
||||
[
|
||||
"def",
|
||||
"def\tFunction"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
],
|
||||
"build_system": "",
|
||||
"build_system_choices":
|
||||
[
|
||||
],
|
||||
"build_varint": "",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"replv",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl v",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtualen",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"repl p",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl py",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repel p",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"error",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"show",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"rep",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"python",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtual",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"python vi",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl python",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtua",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"sublimerepl",
|
||||
"Virtualenv: SublimeREPL - Python"
|
||||
],
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"virt",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"virtu",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"packa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"vir",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"install pa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"insta",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ins",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"brow",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"browse",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"remove",
|
||||
"Package Control: Remove Package"
|
||||
],
|
||||
[
|
||||
"Snippet: ",
|
||||
"Snippet: For Loop"
|
||||
],
|
||||
[
|
||||
"remo",
|
||||
"Package Control: Remove Channel"
|
||||
],
|
||||
[
|
||||
"show all",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"prefs",
|
||||
"Preferences: SublimeLinter Settings"
|
||||
],
|
||||
[
|
||||
"package in",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"install pack",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ayu: Activate theme",
|
||||
"ayu: Activate theme"
|
||||
],
|
||||
[
|
||||
"Browse Pack",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"Package Control: insta",
|
||||
"Package Control: Install Package"
|
||||
]
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 250.0,
|
||||
"history":
|
||||
[
|
||||
"sublime.cache_path()",
|
||||
"import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
|
||||
]
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"expanded_folders":
|
||||
[
|
||||
"/home/dtomlinson/projects",
|
||||
"/home/dtomlinson/projects/learning",
|
||||
"/home/dtomlinson/projects/learning/descriptors"
|
||||
],
|
||||
"file_history":
|
||||
[
|
||||
"/home/dtomlinson/projects/learning/descriptors/test.py",
|
||||
"/home/dtomlinson/projects/learning/descriptors/descriptors.py",
|
||||
"/home/dtomlinson/projects/learning/descriptors/descriptors2.py",
|
||||
"/home/dtomlinson/projects/temp/temp_new.sublime-workspace",
|
||||
"/home/dtomlinson/sublime/base.sublime-project",
|
||||
"/home/dtomlinson/projects/learning/descriptors/test.py.join(",
|
||||
"/home/dtomlinson/projects/random_sampling/test.py",
|
||||
"/home/dtomlinson/projects/learning/property/property2.py",
|
||||
"/home/dtomlinson/projects/learning/property/property1.py",
|
||||
"/home/dtomlinson/projects/learning/property/property.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/decorator.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/classes_with_args.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/test.py",
|
||||
"/tmp/mozilla_dtomlinson0/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/SublimeREPL.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/learning.sublime-project",
|
||||
"/home/dtomlinson/projects/boto3/blocking_suggestions/.history.txt",
|
||||
"/home/dtomlinson/.bash_profile",
|
||||
"/home/dtomlinson/projects/learning/singletons/client_a.py",
|
||||
"/home/dtomlinson/projects/learning/singletons/client_b.py",
|
||||
"/home/dtomlinson/projects/learning/singletons/db.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/function_decorators.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/classes_decorater.py",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SublimeREPL/SublimeREPL.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/decorators/script1.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/decorators.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/__init__.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/pathfix.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script1.py",
|
||||
"/home/dtomlinson/projects/learning/super/class_1.py",
|
||||
"/home/dtomlinson/projects/learning/super/temp.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script2.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script3.py",
|
||||
"/home/dtomlinson/projects/bayes-learning/lesson1.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/core/series.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/io/api.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/io/excel.py",
|
||||
"/home/dtomlinson/docker-commands/bookstack-temp.txt",
|
||||
"/home/dtomlinson/projects/learning/super/triangle.py",
|
||||
"/home/dtomlinson/projects/learning/super/rectangle-square.py",
|
||||
"/home/dtomlinson/projects/learning/class-and-object-orianted-python/lesson1.py",
|
||||
"/usr/lib64/python3.7/datetime.py",
|
||||
"/home/dtomlinson/projects/bayes-learning/seaborn.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/core/frame.py",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/tmp/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/tmp/borg-backup-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-server.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-download.sh",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-download.sh",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-server.sh",
|
||||
"/home/dtomlinson/Downloads/credentials.csv",
|
||||
"/home/dtomlinson/requirements.txt",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/test.py",
|
||||
"/home/dtomlinson/projects/temp/temp_1.py",
|
||||
"/home/dtomlinson/projects/temp/test.py",
|
||||
"/home/dtomlinson/projects/learning/class-and-object-orianted-python/links.txt",
|
||||
"/home/dtomlinson/projects/base/base.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp_new.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp.sublime-project",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-mirage.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-dark.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SideBarEnhancements/Side Bar.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Python.sublime-settings"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"self.__age",
|
||||
"drinking_age",
|
||||
"name",
|
||||
"name ",
|
||||
"arg",
|
||||
"myobj",
|
||||
"arg",
|
||||
"return",
|
||||
"arg",
|
||||
"return",
|
||||
"__x",
|
||||
"arg",
|
||||
"fibonacci",
|
||||
"self",
|
||||
"decorator",
|
||||
"self"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": true,
|
||||
"wrap": false
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
},
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 51.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.5,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.SublimeLinter":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"output.find_results":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"pinned_build_system": "Packages/Virtualenv/Python + Virtualenv.sublime-build",
|
||||
"project": "/home/dtomlinson/sublime/base.sublime-project",
|
||||
"replace":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 500.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"",
|
||||
"~/projects/bayes-learning/seaborn.sublime-workspace"
|
||||
]
|
||||
],
|
||||
"width": 380.0
|
||||
},
|
||||
"select_symbol":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"selected_group": 0,
|
||||
"settings":
|
||||
{
|
||||
"last_automatic_layout":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
]
|
||||
},
|
||||
"show_minimap": true,
|
||||
"show_open_files": true,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 221.0,
|
||||
"status_bar_visible": true,
|
||||
"template_settings":
|
||||
{
|
||||
"max_columns": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class Celsius(object):
|
||||
"""docstring for Celsius"""
|
||||
def __init__(self, temperature=0):
|
||||
super(Celsius, self).__init__()
|
||||
self.temperature = temperature
|
||||
|
||||
@classmethod
|
||||
def from_fahrenheit(cls, temperature=32):
|
||||
temperature = (temperature - 32) / (9 / 5)
|
||||
return cls(temperature)
|
||||
|
||||
def to_fahrenheit(self):
|
||||
return (self.temperature * 1.8) + 32
|
||||
@@ -0,0 +1,26 @@
|
||||
class P:
|
||||
|
||||
def __init__(self, x):
|
||||
print('init')
|
||||
self._x = x
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
print('get')
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, x):
|
||||
print('set')
|
||||
if x < 0:
|
||||
self._x = 0
|
||||
elif x > 1000:
|
||||
self._x = 1000
|
||||
else:
|
||||
self._x = x
|
||||
|
||||
def double(self):
|
||||
return self.x * 2
|
||||
|
||||
def overwrite(self):
|
||||
self.x = 20
|
||||
@@ -0,0 +1,32 @@
|
||||
class Robot:
|
||||
|
||||
def __init__(self, name, build_year, lk=0.5,
|
||||
lp=0.5):
|
||||
self.name = name
|
||||
self.build_year = build_year
|
||||
self.__potential_physical = lk
|
||||
self.__potential_psychic = lp
|
||||
|
||||
@property
|
||||
def condition(self):
|
||||
s = self.__potential_physical + self.__potential_psychic
|
||||
if s <= -1:
|
||||
return "I feel miserable!"
|
||||
elif s <= 0:
|
||||
return "I feel bad!"
|
||||
elif s <= 0.5:
|
||||
return "Could be worse!"
|
||||
elif s <= 1:
|
||||
return "Seems to be okay!"
|
||||
else:
|
||||
return "Great!"
|
||||
|
||||
def printer(self):
|
||||
return self.condition
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
return 'get'
|
||||
|
||||
|
||||
x = Robot("Marvin", 1979, 0.2, 0.4)
|
||||
y = Robot("Caliban", 1993, -0.4, 0.3)
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
mygenerator = (x * x for x in range(3))
|
||||
for i in mygenerator:
|
||||
print(i)
|
||||
|
||||
for i in mygenerator:
|
||||
print(i)
|
||||
@@ -0,0 +1,4 @@
|
||||
import db
|
||||
|
||||
if (db.db_name == 'mongo'):
|
||||
db.db_name = None
|
||||
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
this = sys.modules[__name__]
|
||||
|
||||
print(this)
|
||||
|
||||
this.db_name = None
|
||||
|
||||
print(this.db_name)
|
||||
|
||||
|
||||
def initialize_db(name):
|
||||
if (this.db_name is None):
|
||||
this.db_name = name
|
||||
# db_name = "Local Variable"
|
||||
else:
|
||||
msg = f"Database is already initialized to {name}"
|
||||
raise RuntimeError(msg.format(this.db_name))
|
||||
@@ -0,0 +1,32 @@
|
||||
class Celsius:
|
||||
def __init__(self, temperature=0):
|
||||
print('initalising')
|
||||
self.temperature = temperature
|
||||
|
||||
def __repr__(self):
|
||||
return(f'current temperature is {self.temperature} degrees C')
|
||||
|
||||
def to_fahrenheit(self):
|
||||
return (self.temperature * 1.8) + 32
|
||||
|
||||
def get_temperature(self):
|
||||
print("Getting value")
|
||||
return self._temperature
|
||||
|
||||
def set_temperature(self, value):
|
||||
if value < -273:
|
||||
raise ValueError("Temperature below -273 is not possible")
|
||||
print("Setting value")
|
||||
self._temperature = value
|
||||
return value
|
||||
|
||||
temperature = property(get_temperature, set_temperature)
|
||||
|
||||
|
||||
# c = Celsius(20)
|
||||
# print(Celsius(20).get_temperature)
|
||||
|
||||
# print(Celsius(20).set_temperature(25))
|
||||
# Celsius(20).get_temperature()
|
||||
c = Celsius()
|
||||
print(c.to_fahrenheit())
|
||||
@@ -0,0 +1,33 @@
|
||||
children precede their parents and the order of appearance in __bases__ is respected.
|
||||
|
||||
why not to use super in object classes: The problem with incompatible signatures https://www.artima.com/weblogs/viewpost.jsp?thread=281127
|
||||
|
||||
why (swap the print and super in each command)
|
||||
class First(object):
|
||||
def __init__(self):
|
||||
super(First, self).__init__()
|
||||
print("first")
|
||||
|
||||
class Second(object):
|
||||
def __init__(self):
|
||||
super(Second, self).__init__()
|
||||
print("second")
|
||||
|
||||
class Third(First, Second):
|
||||
def __init__(self):
|
||||
super(Third, self).__init__()
|
||||
print("third")
|
||||
|
||||
Third()
|
||||
print(Third.__mro__)
|
||||
|
||||
second
|
||||
first
|
||||
third
|
||||
(<class '__main__.Third'>, <class '__main__.First'>, <class '__main__.Second'>, <class 'object'>)
|
||||
[Finished in 0.0s]
|
||||
|
||||
|
||||
https://www.datacamp.com/community/data-science-cheatsheets
|
||||
|
||||
https://www.datacamp.com/community/tutorials/decorators-python - functions returning other functions?
|
||||
@@ -0,0 +1,97 @@
|
||||
#!~/.virtualenvs/learning/bin/python
|
||||
|
||||
|
||||
class Rectangle(object):
|
||||
"""calculates the area and perimeter of a rectangle"""
|
||||
|
||||
def __init__(self, length, width, **kwargs):
|
||||
super(Rectangle, self).__init__(**kwargs)
|
||||
self.length = length
|
||||
self.width = width
|
||||
|
||||
def area(self):
|
||||
return(self.length * self.width)
|
||||
|
||||
def perimeter(self):
|
||||
return(2 * self.length + 2 * self.width)
|
||||
|
||||
|
||||
# Here we can declare the superclass for the subclass Square
|
||||
|
||||
class Square(Rectangle):
|
||||
"""calculates the area and perimeter of a square"""
|
||||
|
||||
def __init__(self, length, **kwargs):
|
||||
super(Square, self).__init__(length=length, width=length, **kwargs)
|
||||
|
||||
|
||||
class Cube(Square):
|
||||
"""calculates the surface area and volume of a cube"""
|
||||
|
||||
def __init__(self, length, **kwargs):
|
||||
super(Cube, self).__init__(length=length, **kwargs)
|
||||
self.length = length
|
||||
|
||||
def surface_area(self):
|
||||
face_area = super(Cube, self).area()
|
||||
return(6 * face_area)
|
||||
|
||||
def volume(self):
|
||||
face_area = super(Cube, self).area()
|
||||
return(face_area * self.length)
|
||||
|
||||
def area(self):
|
||||
return(self.length * self.length + 1)
|
||||
# return(super(Cube, self))
|
||||
|
||||
|
||||
class Triangle(object):
|
||||
"""calculates the area of a triangle"""
|
||||
|
||||
def __init__(self, base, height, **kwargs):
|
||||
self.base = base
|
||||
self.height = height
|
||||
super(Triangle, self).__init__(**kwargs)
|
||||
|
||||
def tri_area(self):
|
||||
return 0.5 * self.base * self.height
|
||||
|
||||
|
||||
class RightPyramid(Square, Triangle):
|
||||
"""calculates the surface area of a right pyramid"""
|
||||
|
||||
def __init__(self, base, slant_height, **kwargs):
|
||||
kwargs['height'] = slant_height
|
||||
kwargs['length'] = base
|
||||
super(RightPyramid, self).__init__(base=base, **kwargs)
|
||||
self.base = base
|
||||
self.slant_height = slant_height
|
||||
|
||||
def area(self):
|
||||
base_area = super(RightPyramid, self).area()
|
||||
perimeter = super(RightPyramid, self).perimeter()
|
||||
return(0.5 * perimeter * self.slant_height + base_area)
|
||||
|
||||
def area_2(self):
|
||||
base_area = super(RightPyramid, self).area()
|
||||
triangle_area = super(RightPyramid, self).tri_area()
|
||||
return(triangle_area * 4 + base_area)
|
||||
|
||||
|
||||
class new_cube(Cube):
|
||||
"""docstring for new_cube"""
|
||||
def __init__(self, new_length):
|
||||
super(new_cube, self).__init__(length=new_length)
|
||||
self.new_length = new_length
|
||||
|
||||
|
||||
# print(RightPyramid.__mro__)
|
||||
pyramid = RightPyramid(2, 4)
|
||||
print(pyramid.area())
|
||||
print(pyramid.area_2())
|
||||
|
||||
nc = new_cube(4)
|
||||
print(nc.surface_area())
|
||||
|
||||
square = Square(3)
|
||||
print(square.perimeter())
|
||||
@@ -0,0 +1,20 @@
|
||||
# ~/.virtualenvs/learning/python
|
||||
|
||||
|
||||
def convert_to_uppercase(function):
|
||||
""" will convert to uppercase """
|
||||
def wrapper():
|
||||
func = function()
|
||||
make_uppercase = func.upper()
|
||||
return make_uppercase
|
||||
|
||||
|
||||
# @convert_to_uppercase
|
||||
def hello():
|
||||
""" print hello world """
|
||||
return 'hello world'
|
||||
|
||||
|
||||
say_HELLO = convert_to_uppercase(hello)
|
||||
|
||||
print(say_HELLO())
|
||||
@@ -0,0 +1,14 @@
|
||||
replace_chars = ['[', ']', '\'', ',']
|
||||
list_of_ips = []
|
||||
new_list = []
|
||||
|
||||
|
||||
def split_ips(list):
|
||||
for sub_list in list:
|
||||
for ip in sub_list.split():
|
||||
for i in range(len(replace_chars)):
|
||||
ip = ip.replace(replace_chars[i], '')
|
||||
new_list.append(ip)
|
||||
|
||||
|
||||
split_ips(list_of_ips)
|
||||
@@ -0,0 +1,9 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
np.random.seed(127)
|
||||
|
||||
df = pd.DataFrame(np.random.uniform(1000, high=1500, size=(30, 1)),
|
||||
columns=['bets']).round(0)
|
||||
|
||||
print(df)
|
||||
@@ -0,0 +1,64 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import itertools
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# np.random.seed(127)
|
||||
low = 1000
|
||||
high = 1200
|
||||
repeat = 120
|
||||
anom_perc = 0.2
|
||||
|
||||
sns.set()
|
||||
sns.set_style("darkgrid")
|
||||
|
||||
|
||||
def generator(low: float, high: float, repeat: int):
|
||||
|
||||
for i in range(repeat):
|
||||
num = np.random.uniform(low, high)
|
||||
curve = float(i) ** 2
|
||||
num = num + curve
|
||||
if num > high * 1.2:
|
||||
low = num - 10
|
||||
high = num + 5
|
||||
elif num < low:
|
||||
low = num - 5
|
||||
high = num + 10
|
||||
else:
|
||||
pass
|
||||
yield num
|
||||
|
||||
|
||||
mygenerator = generator(low, high, repeat)
|
||||
|
||||
|
||||
df = pd.DataFrame([])
|
||||
|
||||
for i, j in zip(mygenerator, np.arange(repeat)):
|
||||
df = df.append([pd.DataFrame({'time': j, 'bets': i, },
|
||||
index=[0])]).round(0)
|
||||
|
||||
|
||||
def create_anom(dataframe, number):
|
||||
for _ in itertools.repeat(None, number):
|
||||
rows = dataframe.shape[0]
|
||||
anomaly = f"{float(dataframe.iloc[-1]['bets']) * (1 - anom_perc)}"
|
||||
anomaly = float(anomaly)
|
||||
dataframe = dataframe.append([pd.DataFrame(
|
||||
{'time': rows, 'bets': anomaly},
|
||||
index=[0])])
|
||||
return dataframe
|
||||
|
||||
|
||||
df_anom = create_anom(df, 3)
|
||||
|
||||
f, axes = plt.subplots(2, 1)
|
||||
|
||||
for ax in axes:
|
||||
ax.set_ylim([low * 0.5, high * 1.5])
|
||||
|
||||
sns.lineplot(x='time', y='bets', data=df, ax=axes[0])
|
||||
sns.lineplot(x='time', y='bets', data=df_anom, ax=axes[1])
|
||||
plt.show()
|
||||
@@ -0,0 +1,19 @@
|
||||
import praw
|
||||
# from praw.models import MoreComments
|
||||
|
||||
r = praw.Reddit(client_id='rDpKg8v-jw4QoQ',
|
||||
client_secret='IUcwsp_1_zkmgGMY-X5fvXKyMWs',
|
||||
password='IjNSZQdtQAdl',
|
||||
user_agent='test-script',
|
||||
username='adhesiveduck')
|
||||
print(r.user.me())
|
||||
|
||||
submission = r.submission(url='https://old.reddit.com/r/AskReddit/comments/'
|
||||
'cbg7m1/what_movie_do_you_consider_perfect/')
|
||||
|
||||
submission.comments.replace_more(limit=20)
|
||||
|
||||
# print(type(submission))
|
||||
|
||||
for top_level_comment in submission.comments:
|
||||
print(top_level_comment.body)
|
||||
Binary file not shown.
+175
@@ -0,0 +1,175 @@
|
||||
import numpy as np
|
||||
import itertools
|
||||
import functools
|
||||
|
||||
""" Define our data """
|
||||
# The Statespace
|
||||
states = np.array(['L', 'w', 'W'])
|
||||
|
||||
# Possible sequences of events
|
||||
transitionName = np.array([['LL', 'Lw', 'LW'],
|
||||
['wL', 'ww', 'wW'],
|
||||
['WL', 'Ww', 'WW']])
|
||||
|
||||
# Probabilities Matrix (transition matrix)
|
||||
transitionMatrix = np.array([[0.8, 0.15, 0.05],
|
||||
[0.8, 0.15, 0.05],
|
||||
[0.8, 0.15, 0.05]])
|
||||
|
||||
# Starting state
|
||||
startingState = 'L'
|
||||
# Steps to run
|
||||
stepTime = 2
|
||||
# End state you want to find probabilites of
|
||||
endState = 'L'
|
||||
|
||||
|
||||
""" Set our parameters """
|
||||
# Should we seed the results?
|
||||
setSeed = False
|
||||
seedNum = 27
|
||||
|
||||
|
||||
""" Simulation parameters """
|
||||
# Should we simulate more than once?
|
||||
setSim = True
|
||||
simNum = 10
|
||||
|
||||
|
||||
# A class that implements the Markov chain to forecast the state/mood:
|
||||
class markov(object):
|
||||
"""simulates a markov chain given its states, current state and
|
||||
transition matrix.
|
||||
|
||||
Parameters:
|
||||
states: 1-d array containing all the possible states
|
||||
transitionName: 2-d array containing a list
|
||||
of the all possible state directions
|
||||
transitionMatrix: 2-d array containing all
|
||||
the probabilites of moving to each state
|
||||
currentState: a string indicating the starting state
|
||||
steps: an integer determining how many steps (or times) to simulate"""
|
||||
|
||||
def __init__(self, states: np.array, transitionName: np.array,
|
||||
transitionMatrix: np.array, currentState: str,
|
||||
steps: int):
|
||||
super(markov, self).__init__()
|
||||
self.states = states
|
||||
self.list = list
|
||||
self.transitionName = transitionName
|
||||
self.transitionMatrix = transitionMatrix
|
||||
self.currentState = currentState
|
||||
self.steps = steps
|
||||
|
||||
@staticmethod
|
||||
def setSeed(num: int):
|
||||
return np.random.seed(num)
|
||||
|
||||
@functools.lru_cache(maxsize=128)
|
||||
def forecast(self):
|
||||
print(f'Start state: {self.currentState}')
|
||||
# Shall store the sequence of states taken
|
||||
self.stateList = [self.currentState]
|
||||
i = 0
|
||||
# To calculate the probability of the stateList
|
||||
self.prob = 1
|
||||
while i != self.steps:
|
||||
if self.currentState == 'L':
|
||||
self.change = np.random.choice(self.transitionName[0],
|
||||
replace=True,
|
||||
p=transitionMatrix[0])
|
||||
if self.change == 'LL':
|
||||
self.prob = self.prob * 0.8
|
||||
self.stateList.append('L')
|
||||
pass
|
||||
elif self.change == 'Lw':
|
||||
self.prob = self.prob * 0.15
|
||||
self.currentState = 'w'
|
||||
self.stateList.append('w')
|
||||
else:
|
||||
self.prob = self.prob * 0.05
|
||||
self.currentState = "W"
|
||||
self.stateList.append("W")
|
||||
elif self.currentState == "w":
|
||||
self.change = np.random.choice(self.transitionName[1],
|
||||
replace=True,
|
||||
p=transitionMatrix[1])
|
||||
if self.change == "ww":
|
||||
self.prob = self.prob * 0.15
|
||||
self.stateList.append("w")
|
||||
pass
|
||||
elif self.change == "wL":
|
||||
self.prob = self.prob * 0.8
|
||||
self.currentState = "L"
|
||||
self.stateList.append("L")
|
||||
else:
|
||||
self.prob = self.prob * 0.05
|
||||
self.currentState = "W"
|
||||
self.stateList.append("W")
|
||||
elif self.currentState == "W":
|
||||
self.change = np.random.choice(self.transitionName[2],
|
||||
replace=True,
|
||||
p=transitionMatrix[2])
|
||||
if self.change == "WW":
|
||||
self.prob = self.prob * 0.05
|
||||
self.stateList.append("W")
|
||||
pass
|
||||
elif self.change == "WL":
|
||||
self.prob = self.prob * 0.8
|
||||
self.currentState = "L"
|
||||
self.stateList.append("L")
|
||||
else:
|
||||
self.prob = self.prob * 0.15
|
||||
self.currentState = "w"
|
||||
self.stateList.append("w")
|
||||
i += 1
|
||||
print(f'Possible states: {self.stateList}')
|
||||
print(f'End state after {self.steps} steps: {self.currentState}')
|
||||
print(f'Probability of all the possible sequence of states:'
|
||||
f' {self.prob}')
|
||||
return self.stateList
|
||||
|
||||
|
||||
def main(*args, **kwargs):
|
||||
try:
|
||||
simNum = kwargs['simNum']
|
||||
except KeyError:
|
||||
pass
|
||||
sumTotal = 0
|
||||
# Check validity of transitionMatrix
|
||||
for i in range(len(transitionMatrix)):
|
||||
sumTotal += sum(transitionMatrix[i])
|
||||
if i != len(states) and i == len(transitionMatrix):
|
||||
raise ValueError('Probabilities should add to 1')
|
||||
# Set the seed so we can repeat with the same results
|
||||
if setSeed:
|
||||
markov.setSeed(seedNum)
|
||||
# Save our simulations:
|
||||
list_state = []
|
||||
count = 0
|
||||
# Simulate Multiple Times
|
||||
if setSim:
|
||||
for _ in itertools.repeat(None, simNum):
|
||||
markovChain = markov(states, transitionName,
|
||||
transitionMatrix, startingState,
|
||||
stepTime)
|
||||
list_state.append(markovChain.forecast())
|
||||
else:
|
||||
for _ in range(1, 2):
|
||||
list_state.append(markov(states, transitionName,
|
||||
transitionMatrix, startingState,
|
||||
stepTime).forecast())
|
||||
for list in list_state:
|
||||
if(list[-1] == f'{endState!s}'):
|
||||
print(True, list)
|
||||
count += 1
|
||||
else:
|
||||
print(False, list)
|
||||
if setSim is False:
|
||||
simNum = 1
|
||||
print(f'\nThe probability of starting in {startingState} and finishing'
|
||||
f' in {endState} after {stepTime} steps is {(count / simNum):.2%}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(simNum=simNum)
|
||||
@@ -0,0 +1,172 @@
|
||||
import numpy as np
|
||||
import itertools
|
||||
import functools
|
||||
|
||||
""" Define our data """
|
||||
# The Statespace
|
||||
states = np.array(['Bonus', 'Ten', 'Fifty', 'Hundred', 'Five-Hundred'])
|
||||
|
||||
# Possible sequences of events
|
||||
transitionName = np.array([['BB', 'BT', 'SI'],
|
||||
['RS', 'RR', 'RI'],
|
||||
['IS', 'IR', 'II']])
|
||||
|
||||
# Probabilities Matrix (transition matrix)
|
||||
transitionMatrix = np.array([[0.2, 0.6, 0.2],
|
||||
[0.1, 0.6, 0.3],
|
||||
[0.2, 0.7, 0.1]])
|
||||
|
||||
# Starting state
|
||||
startingState = 'Sleep'
|
||||
# Steps to run
|
||||
stepTime = 1
|
||||
# End state you want to find probabilites of
|
||||
endState = 'Run'
|
||||
|
||||
|
||||
""" Set our parameters """
|
||||
# Should we seed the results?
|
||||
setSeed = False
|
||||
seedNum = 27
|
||||
|
||||
|
||||
""" Simulation parameters """
|
||||
# Should we simulate more than once?
|
||||
setSim = False
|
||||
simNum = 100000
|
||||
|
||||
|
||||
# A class that implements the Markov chain to forecast the state/mood:
|
||||
class markov(object):
|
||||
"""simulates a markov chain given its states, current state and
|
||||
transition matrix.
|
||||
|
||||
Parameters:
|
||||
states: list containing all the possible states
|
||||
transitionName: a matrix (nested list in a list) containing a list
|
||||
of the all possible state directions
|
||||
transitionMatrix: a matrix (nested list in a list) containing all
|
||||
the probabilites of moving to each state
|
||||
currentState: a string indicating the starting state
|
||||
days: an integer determining how many days (or times) to simulate"""
|
||||
|
||||
def __init__(self, states: np.array, transitionName: np.array,
|
||||
transitionMatrix: np.array, currentState: str,
|
||||
days: int):
|
||||
super(markov, self).__init__()
|
||||
self.states = states
|
||||
self.list = list
|
||||
self.transitionName = transitionName
|
||||
self.transitionMatrix = transitionMatrix
|
||||
self.currentState = currentState
|
||||
self.days = days
|
||||
|
||||
@staticmethod
|
||||
def setSeed(num: int):
|
||||
return np.random.seed(num)
|
||||
|
||||
@functools.lru_cache(maxsize=128)
|
||||
def forecast(self):
|
||||
print(f'Start state: {self.currentState}')
|
||||
# Shall store the sequence of states taken
|
||||
self.stateList = [self.currentState]
|
||||
i = 0
|
||||
# To calculate the probability of the stateList
|
||||
self.prob = 1
|
||||
while i != self.days:
|
||||
if self.currentState == 'Sleep':
|
||||
self.change = np.random.choice(self.transitionName[0],
|
||||
replace=True,
|
||||
p=transitionMatrix[0])
|
||||
if self.change == 'SS':
|
||||
self.prob = self.prob * 0.2
|
||||
self.stateList.append('Sleep')
|
||||
pass
|
||||
elif self.change == 'SR':
|
||||
self.prob = self.prob * 0.6
|
||||
self.currentState = 'Run'
|
||||
self.stateList.append('Run')
|
||||
else:
|
||||
self.prob = self.prob * 0.2
|
||||
self.currentState = "Icecream"
|
||||
self.stateList.append("Icecream")
|
||||
elif self.currentState == "Run":
|
||||
self.change = np.random.choice(self.transitionName[1],
|
||||
replace=True,
|
||||
p=transitionMatrix[1])
|
||||
if self.change == "RR":
|
||||
self.prob = self.prob * 0.6
|
||||
self.stateList.append("Run")
|
||||
pass
|
||||
elif self.change == "RS":
|
||||
self.prob = self.prob * 0.1
|
||||
self.currentState = "Sleep"
|
||||
self.stateList.append("Sleep")
|
||||
else:
|
||||
self.prob = self.prob * 0.3
|
||||
self.currentState = "Icecream"
|
||||
self.stateList.append("Icecream")
|
||||
elif self.currentState == "Icecream":
|
||||
self.change = np.random.choice(self.transitionName[2],
|
||||
replace=True,
|
||||
p=transitionMatrix[2])
|
||||
if self.change == "II":
|
||||
self.prob = self.prob * 0.1
|
||||
self.stateList.append("Icecream")
|
||||
pass
|
||||
elif self.change == "IS":
|
||||
self.prob = self.prob * 0.2
|
||||
self.currentState = "Sleep"
|
||||
self.stateList.append("Sleep")
|
||||
else:
|
||||
self.prob = self.prob * 0.7
|
||||
self.currentState = "Run"
|
||||
self.stateList.append("Run")
|
||||
i += 1
|
||||
print(f'Possible states: {self.stateList}')
|
||||
print(f'End state after {self.days} steps: {self.currentState}')
|
||||
print(f'Probability of all the possible sequence of states:'
|
||||
f' {self.prob}')
|
||||
return self.stateList
|
||||
|
||||
|
||||
def main(*args, **kwargs):
|
||||
try:
|
||||
simNum = kwargs['simNum']
|
||||
except KeyError:
|
||||
pass
|
||||
sumTotal = 0
|
||||
# Check validity of transitionMatrix
|
||||
for i in range(len(transitionMatrix)):
|
||||
sumTotal += sum(transitionMatrix[i])
|
||||
if i != len(states) and i == len(transitionMatrix):
|
||||
raise ValueError('Probabilities should add to 1')
|
||||
# Set the seed so we can repeat with the same results
|
||||
if setSeed:
|
||||
markov.setSeed(seedNum)
|
||||
# Save our simulations:
|
||||
list_state = []
|
||||
count = 0
|
||||
# Simulate Multiple Times
|
||||
if setSim:
|
||||
for _ in itertools.repeat(None, simNum + 1):
|
||||
markovChain = markov(states, transitionName,
|
||||
transitionMatrix, startingState,
|
||||
stepTime)
|
||||
list_state.append(markovChain.forecast())
|
||||
else:
|
||||
for _ in range(1, 2):
|
||||
list_state.append(markov(states, transitionName,
|
||||
transitionMatrix, startingState,
|
||||
stepTime).forecast())
|
||||
for list in list_state:
|
||||
if(list[-1] == f'{endState!s}'):
|
||||
count += 1
|
||||
if setSim is False:
|
||||
simNum = 1
|
||||
print(f'\nThe probability of starting in {startingState} and finishing'
|
||||
f' in {endState} after {stepTime} steps is {(count / simNum):.2%}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,791 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"def",
|
||||
"def\tFunction"
|
||||
],
|
||||
[
|
||||
"fun",
|
||||
"function12\tfunction"
|
||||
],
|
||||
[
|
||||
"func",
|
||||
"function1\tfunction"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
{
|
||||
"contents": "{\n\t\"folders\":\n\t[\n\t\t{\n\t\t\t\"path\": \"/home/dtomlinson/projects\"\n\t\t}\n\t],\n\t\"settings\":\n\t[\n\t\t{\n\t\t\t\"SublimeLinter.linters.pyflakes.python\": \"$VIRTUAL_ENV/bin/python\",\n\t\t\t\"anaconda_linting\": true,\n\t\t\t\"enable_signatures_tooltip\": true,\n\t\t\t\"merge_signatures_and_doc\": true,\n\t\t\t\"python_interpreter\": \"$VIRTUAL_ENV/bin/python\"\n\t\t}\n\t]\n}\n\n\n\n{\n\t\"build_systems\":\n\t[\n\t\t{\n\t\t\t\"file_regex\": \"^[ ]*File \\\"(...*?)\\\", line ([0-9]*)\",\n\t\t\t\"name\": \"Anaconda Python Builder\",\n\t\t\t\"selector\": \"source.python\",\n\t\t\t\"shell_cmd\": \"\\\"/usr/bin/python\\\" -u \\\"$file\\\"\"\n\t\t}\n\t],\n\t\"folders\":\n\t[\n\t\t{\n\t\t\t\"path\": \"/home/dtomlinson/projects\"\n\t\t}\n\t],\n\t\"settings\":\n\t{\n\t\t\"anaconda_linting\": false,\n\t\t\"enable_signatures_tooltip\": true,\n\t\t\"merge_signatures_and_doc\": true,\n\t\t\"python_interpreter\": \"/usr/bin/python\",\n\t\t\"test_command\": \"python -m unittest discover\",\n\t\t\"virtualenv\": \"/home/dtomlinson/.virtualenvs/temp\"\n\t}\n}\n",
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 873,
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 0,
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"contents": "import pandas\n\n\ndef function():\n pass\n\n# test\n\ndef function():\n pass\n ",
|
||||
"file": "temp_1.py",
|
||||
"file_size": 214,
|
||||
"file_write_time": 132033951515939550,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 79,
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
}
|
||||
],
|
||||
"build_system": "Packages/Python/Python.sublime-build",
|
||||
"build_system_choices":
|
||||
[
|
||||
[
|
||||
[
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
"Syntax Check"
|
||||
]
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
]
|
||||
]
|
||||
],
|
||||
"build_varint": "",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"vir",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"virtualen",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"install pa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"packa",
|
||||
"Package Control: Add Channel"
|
||||
],
|
||||
[
|
||||
"insta",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ins",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"brow",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"browse",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"remove",
|
||||
"Package Control: Remove Package"
|
||||
],
|
||||
[
|
||||
"Snippet: ",
|
||||
"Snippet: For Loop"
|
||||
],
|
||||
[
|
||||
"remo",
|
||||
"Package Control: Remove Channel"
|
||||
],
|
||||
[
|
||||
"show all",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"prefs",
|
||||
"Preferences: SublimeLinter Settings"
|
||||
],
|
||||
[
|
||||
"package in",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"install pack",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ayu: Activate theme",
|
||||
"ayu: Activate theme"
|
||||
],
|
||||
[
|
||||
"Browse Pack",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"Package Control: insta",
|
||||
"Package Control: Install Package"
|
||||
]
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 250.0,
|
||||
"history":
|
||||
[
|
||||
"import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
|
||||
]
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"expanded_folders":
|
||||
[
|
||||
"/home/dtomlinson/projects"
|
||||
],
|
||||
"file_history":
|
||||
[
|
||||
"/home/dtomlinson/projects/temp/temp.sublime-project",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/projects/temp/temp_1.py",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-mirage.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-dark.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SideBarEnhancements/Side Bar.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Python.sublime-settings"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"~/.virtualenvs/temp",
|
||||
"space",
|
||||
"spaces",
|
||||
"indent",
|
||||
"tab",
|
||||
"Tab",
|
||||
"FreeMono",
|
||||
"Source Code Pro",
|
||||
"PragmataPro Mono Liga"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": false,
|
||||
"wrap": true
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"selected": 1,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 0,
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 873,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
873,
|
||||
873
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.24.region_keys":
|
||||
[
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content"
|
||||
],
|
||||
"default_dir": "/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda",
|
||||
"syntax": "Packages/zzz A File Icon zzz/aliases/JSON (Sublime).sublime-syntax",
|
||||
"translate_tabs_to_spaces": false
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 2,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"buffer": 1,
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 0,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.32.region_keys":
|
||||
[
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"default_dir": "/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda",
|
||||
"syntax": "Packages/Text/Plain text.tmLanguage"
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 1,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"selected": 0,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 2,
|
||||
"file": "temp_1.py",
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 79,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
79,
|
||||
79
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.15.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions",
|
||||
"SL.pyflakes.Highlights.|40d384088be32979b28a61ef7a04937d07d959ad5140d0cdb21eebc331b5dfe0|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Gutter.|region.redish markup.error.sublime_linter|dot",
|
||||
"SL.pyflakes.Highlights.|2d30fbcbb8da3b3e42b1c007af1f723404f134574da5e36d08f3194e4d7d0600|region.redish markup.error.sublime_linter|32"
|
||||
],
|
||||
"SL.16.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions",
|
||||
"SL.pyflakes.Highlights.|2d30fbcbb8da3b3e42b1c007af1f723404f134574da5e36d08f3194e4d7d0600|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Highlights.|40d384088be32979b28a61ef7a04937d07d959ad5140d0cdb21eebc331b5dfe0|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Gutter.|region.redish markup.error.sublime_linter|dot"
|
||||
],
|
||||
"SL.37.region_keys":
|
||||
[
|
||||
"SL.pyflakes.Highlights.|40d384088be32979b28a61ef7a04937d07d959ad5140d0cdb21eebc331b5dfe0|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pycodestyle.Gutter.|region.redish markup.error.sublime_linter|dot",
|
||||
"SL.pycodestyle.Highlights.|75906588146890769784195d26580ba7325c750f2f20c6a7599912bc1693b59d|region.yellowish markup.warning.sublime_linter|32",
|
||||
"SL.pyflakes.Gutter.|region.redish markup.error.sublime_linter|dot",
|
||||
"SL.pyflakes.Highlights.|2d30fbcbb8da3b3e42b1c007af1f723404f134574da5e36d08f3194e4d7d0600|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pycodestyle.Highlights.|2bfb77b40486fe1af7f9a990459f9d02d791d548134e813124bb4df98936518f|region.redish markup.error.sublime_linter|32",
|
||||
"sublime_linter.protected_regions",
|
||||
"SL.pycodestyle.Gutter.|region.yellowish markup.warning.sublime_linter|dot"
|
||||
],
|
||||
"auto_complete_triggers":
|
||||
[
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - comment - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
}
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"syntax": "Packages/Python/Python.sublime-syntax"
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 0,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 51.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.497098677386,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.SublimeLinter":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"output.find_results":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.unsaved_changes":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"pinned_build_system": "Anaconda Python Builder",
|
||||
"project": "temp.sublime-project",
|
||||
"replace":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 500.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"",
|
||||
"~/projects/temp/temp.sublime-project"
|
||||
]
|
||||
],
|
||||
"width": 380.0
|
||||
},
|
||||
"select_symbol":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"selected_group": 1,
|
||||
"settings":
|
||||
{
|
||||
},
|
||||
"show_minimap": true,
|
||||
"show_open_files": true,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 212.0,
|
||||
"status_bar_visible": true,
|
||||
"template_settings":
|
||||
{
|
||||
"max_columns": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# import pandas
|
||||
|
||||
|
||||
def function():
|
||||
pass
|
||||
|
||||
|
||||
print("test")
|
||||
|
||||
|
||||
class testclass(object):
|
||||
"""docstring for testclass"""
|
||||
def __init__(self, arg):
|
||||
super(testclass, self).__init__()
|
||||
self.arg = arg
|
||||
@@ -0,0 +1,746 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"def",
|
||||
"def\tFunction"
|
||||
],
|
||||
[
|
||||
"fun",
|
||||
"function12\tfunction"
|
||||
],
|
||||
[
|
||||
"func",
|
||||
"function1\tfunction"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
{
|
||||
"file": "temp_1.py",
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 214,
|
||||
"encoding": "UTF-8",
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file": "temp_new.sublime-project",
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 605,
|
||||
"encoding": "UTF-8",
|
||||
"line_ending": "Unix"
|
||||
}
|
||||
}
|
||||
],
|
||||
"build_system": "Packages/Python/Python.sublime-build",
|
||||
"build_system_choices":
|
||||
[
|
||||
[
|
||||
[
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
"Syntax Check"
|
||||
]
|
||||
],
|
||||
[
|
||||
"Packages/Python/Python.sublime-build",
|
||||
""
|
||||
]
|
||||
]
|
||||
],
|
||||
"build_varint": "",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"packa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"virtual",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"vir",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"virtualen",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"install pa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"insta",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ins",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"brow",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"browse",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"remove",
|
||||
"Package Control: Remove Package"
|
||||
],
|
||||
[
|
||||
"Snippet: ",
|
||||
"Snippet: For Loop"
|
||||
],
|
||||
[
|
||||
"remo",
|
||||
"Package Control: Remove Channel"
|
||||
],
|
||||
[
|
||||
"show all",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"prefs",
|
||||
"Preferences: SublimeLinter Settings"
|
||||
],
|
||||
[
|
||||
"package in",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"install pack",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ayu: Activate theme",
|
||||
"ayu: Activate theme"
|
||||
],
|
||||
[
|
||||
"Browse Pack",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"Package Control: insta",
|
||||
"Package Control: Install Package"
|
||||
]
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 250.0,
|
||||
"history":
|
||||
[
|
||||
"sublime.cache_path()",
|
||||
"import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
|
||||
]
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"expanded_folders":
|
||||
[
|
||||
"/home/dtomlinson/projects",
|
||||
"/home/dtomlinson/projects/temp"
|
||||
],
|
||||
"file_history":
|
||||
[
|
||||
"/home/dtomlinson/projects/temp/temp_1.py",
|
||||
"/home/dtomlinson/projects/temp/temp.sublime-project",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-mirage.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-dark.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SideBarEnhancements/Side Bar.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Python.sublime-settings"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"~/.virtualenvs/temp",
|
||||
"space",
|
||||
"spaces",
|
||||
"indent",
|
||||
"tab",
|
||||
"Tab",
|
||||
"FreeMono",
|
||||
"Source Code Pro",
|
||||
"PragmataPro Mono Liga"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": false,
|
||||
"wrap": true
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"selected": 0,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 0,
|
||||
"file": "temp_1.py",
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 214,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
0,
|
||||
214
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"SL.14.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions"
|
||||
],
|
||||
"SL.20.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions",
|
||||
"SL.pyflakes.Highlights.|2d30fbcbb8da3b3e42b1c007af1f723404f134574da5e36d08f3194e4d7d0600|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Highlights.|40d384088be32979b28a61ef7a04937d07d959ad5140d0cdb21eebc331b5dfe0|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Gutter.|region.redish markup.error.sublime_linter|dot"
|
||||
],
|
||||
"SL.31.region_keys":
|
||||
[
|
||||
"sublime_linter.protected_regions",
|
||||
"SL.pycodestyle.Highlights.|7eb5b6ebf5e11481674d03076c4e6d3f389aed76d436514a4f70050c297b03aa|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pycodestyle.Highlights.|2bfb77b40486fe1af7f9a990459f9d02d791d548134e813124bb4df98936518f|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pycodestyle.Gutter.|region.redish markup.error.sublime_linter|dot",
|
||||
"SL.pyflakes.Highlights.|40d384088be32979b28a61ef7a04937d07d959ad5140d0cdb21eebc331b5dfe0|region.redish markup.error.sublime_linter|32",
|
||||
"SL.pyflakes.Gutter.|region.redish markup.error.sublime_linter|dot",
|
||||
"SL.pyflakes.Highlights.|2d30fbcbb8da3b3e42b1c007af1f723404f134574da5e36d08f3194e4d7d0600|region.redish markup.error.sublime_linter|32"
|
||||
],
|
||||
"SL.52.region_keys":
|
||||
[
|
||||
],
|
||||
"auto_complete_triggers":
|
||||
[
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - comment - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
},
|
||||
{
|
||||
"characters": ".",
|
||||
"selector": "source.python - string - constant.numeric"
|
||||
}
|
||||
],
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"syntax": "Packages/Python/Python.sublime-syntax",
|
||||
"translate_tabs_to_spaces": true
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 0,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"selected": 0,
|
||||
"sheets":
|
||||
[
|
||||
{
|
||||
"buffer": 1,
|
||||
"file": "temp_new.sublime-project",
|
||||
"semi_transient": false,
|
||||
"settings":
|
||||
{
|
||||
"buffer_size": 605,
|
||||
"regions":
|
||||
{
|
||||
},
|
||||
"selection":
|
||||
[
|
||||
[
|
||||
605,
|
||||
605
|
||||
]
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"bracket_highlighter.busy": false,
|
||||
"bracket_highlighter.clone": -1,
|
||||
"bracket_highlighter.clone_locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.clone_regions":
|
||||
[
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content"
|
||||
],
|
||||
"bracket_highlighter.locations":
|
||||
{
|
||||
"close":
|
||||
{
|
||||
},
|
||||
"icon":
|
||||
{
|
||||
},
|
||||
"open":
|
||||
{
|
||||
},
|
||||
"unmatched":
|
||||
{
|
||||
}
|
||||
},
|
||||
"bracket_highlighter.regions":
|
||||
[
|
||||
"bh_single_quote",
|
||||
"bh_single_quote_center",
|
||||
"bh_single_quote_open",
|
||||
"bh_single_quote_close",
|
||||
"bh_single_quote_content",
|
||||
"bh_double_quote",
|
||||
"bh_double_quote_center",
|
||||
"bh_double_quote_open",
|
||||
"bh_double_quote_close",
|
||||
"bh_double_quote_content",
|
||||
"bh_c_define",
|
||||
"bh_c_define_center",
|
||||
"bh_c_define_open",
|
||||
"bh_c_define_close",
|
||||
"bh_c_define_content",
|
||||
"bh_unmatched",
|
||||
"bh_unmatched_center",
|
||||
"bh_unmatched_open",
|
||||
"bh_unmatched_close",
|
||||
"bh_unmatched_content",
|
||||
"bh_regex",
|
||||
"bh_regex_center",
|
||||
"bh_regex_open",
|
||||
"bh_regex_close",
|
||||
"bh_regex_content",
|
||||
"bh_default",
|
||||
"bh_default_center",
|
||||
"bh_default_open",
|
||||
"bh_default_close",
|
||||
"bh_default_content",
|
||||
"bh_round",
|
||||
"bh_round_center",
|
||||
"bh_round_open",
|
||||
"bh_round_close",
|
||||
"bh_round_content",
|
||||
"bh_curly",
|
||||
"bh_curly_center",
|
||||
"bh_curly_open",
|
||||
"bh_curly_close",
|
||||
"bh_curly_content",
|
||||
"bh_square",
|
||||
"bh_square_center",
|
||||
"bh_square_open",
|
||||
"bh_square_close",
|
||||
"bh_square_content",
|
||||
"bh_tag",
|
||||
"bh_tag_center",
|
||||
"bh_tag_open",
|
||||
"bh_tag_close",
|
||||
"bh_tag_content",
|
||||
"bh_angle",
|
||||
"bh_angle_center",
|
||||
"bh_angle_open",
|
||||
"bh_angle_close",
|
||||
"bh_angle_content"
|
||||
],
|
||||
"syntax": "Packages/zzz A File Icon zzz/aliases/JSON (Sublime).sublime-syntax",
|
||||
"translate_tabs_to_spaces": false
|
||||
},
|
||||
"translation.x": 0.0,
|
||||
"translation.y": 0.0,
|
||||
"zoom_level": 1.0
|
||||
},
|
||||
"stack_index": 1,
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 51.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.5,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.SublimeLinter":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"output.find_results":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.unsaved_changes":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"pinned_build_system": "Packages/Virtualenv/Python + Virtualenv.sublime-build",
|
||||
"project": "temp_new.sublime-project",
|
||||
"replace":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 500.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"",
|
||||
"~/projects/temp/temp.sublime-project"
|
||||
]
|
||||
],
|
||||
"width": 380.0
|
||||
},
|
||||
"select_symbol":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"selected_group": 0,
|
||||
"settings":
|
||||
{
|
||||
},
|
||||
"show_minimap": true,
|
||||
"show_open_files": true,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 212.0,
|
||||
"status_bar_visible": true,
|
||||
"template_settings":
|
||||
{
|
||||
"max_columns": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
replace_chars = ['[', ']', '\'', ',']
|
||||
list_of_ips = ['list-items-in-here']
|
||||
new_list = []
|
||||
|
||||
|
||||
def split_ips(list):
|
||||
for sub_list in list:
|
||||
for ip in sub_list.split():
|
||||
for i in range(len(replace_chars)):
|
||||
ip = ip.replace(replace_chars[i], '')
|
||||
new_list.append(ip)
|
||||
|
||||
|
||||
split_ips(list_of_ips)
|
||||
|
||||
Reference in New Issue
Block a user