adding all files done so far

This commit is contained in:
2019-07-10 20:18:31 +01:00
parent 13c0e9cb4d
commit e3ac390e8b
76 changed files with 8644 additions and 0 deletions

Binary file not shown.

175
temp/markov.py Normal file
View File

@@ -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)

172
temp/numpy_test.py Normal file
View File

@@ -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()

791
temp/temp.sublime-workspace Normal file
View File

@@ -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
}
}

15
temp/temp_1.py Normal file
View File

@@ -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

View File

@@ -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
}
}

17
temp/test.py Normal file
View File

@@ -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)