g = nx.complete_graph([
"playground equipment", "evanescent champagne", "curved spacetime",
"magic flute", "market returns", "spotty memory",
"languid feeling", "include numpy as np", "acidic chemical",
"downton abbey", "tumble weeds", "precede the cause"])
node_locs = nx.circular_layout(g)
theta = {k: np.arctan2(v[1], v[0]) * 180/np.pi for k, v in node_locs.items() }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_python_identifier(string, namespace=None, reserved_words=None, | |
convert='drop', handle='force'): | |
""" | |
Takes an arbitrary string and creates a valid Python identifier. | |
If the python identifier created is already in the namespace, | |
or if the identifier is a reserved word in the reserved_words | |
list, or is a python default reserved word, | |
adds _1, or if _1 is in the namespace, _2, etc. | |
Parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Scraping with xpath | |
Here's a basic demo on how I scraped a page using xpath to get specific pieces of info. | |
While I've only accessed a few single pieces of info on the page, xpath can also | |
get you a list of all the elements that meet a specific path, and will return them as | |
a list or iterable. | |
A tool you might like for debugging your xpath expressions is: xpath-helper | |
https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MinModel(object): | |
########## boilerplate stuff from the existing pysd ######### | |
def __init__(self): | |
self._stocknames = [name[:-5] for name in dir(self) if name[-5:] == '_init'] | |
self._stocknames.sort() #inplace | |
self._dfuncs = [getattr(self, 'd%s_dt'%name) for name in self._stocknames] | |
self.state = dict(zip(self._stocknames, [None]*len(self._stocknames))) | |
self.reset_state() | |
self.functions = functions.Functions(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zipfile import ZipFile | |
def unpack_zip(zipfile='', path_from_local=''): | |
filepath = path_from_local+zipfile | |
extract_path = filepath.strip('.zip')+'/' | |
parent_archive = ZipFile(filepath) | |
parent_archive.extractall(extract_path) | |
namelist = parent_archive.namelist() | |
parent_archive.close() | |
for name in namelist: |