This file contains hidden or 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
import copy | |
from metadict import MetaDict | |
''' define data structure using dict Metadict''' | |
tl_dict=MetaDict ({f'L{n}': 0 for n in range (4)}) | |
''' use dot access . Can create array of these | |
data structure built using dict (MetaDIct allows dot access) | |
''' | |
def set_dict(d,values): | |
d=copy.deepcopy(d) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 hidden or 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 IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = "all" | |
from quantiphy import Quantity | |
a=Quantity('30MHz') | |
print (a) # 30 MHz | |
a.as_tuple()[0] | |
a.render() # '30 MHz' | |
float(a) # 30000000.0 |
This file contains hidden or 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
# importing packages | |
# IF errors replace line 30 in cipher.py as follows | |
# var_regex = re.compile(r"^\$*\w+\W") | |
import sys | |
import os | |
ytpath=r'https://www.youtube.com/watch?v=2SCOYFkvXWQ' | |
!{sys.executable} -m pip install pytube | |
import pytube | |
from pytube import YouTube | |
This file contains hidden or 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 y_interpolate (xnew,x,y): | |
from scipy.interpolate import interp1d | |
y_interpolate_function = interp1d(x, y) | |
return (y_interpolate_function(xnew)) |
This file contains hidden or 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
#https://notebook.community/redlegjed/cheatsheets/holoviews_cheatsheet | |
#bokeh figure from holoview | |
bf=hv.render(p) #bf is bokeh figure object | |
bf | |
def formatter(value): | |
return str(value) + ' days' | |
curve.relabel('Tick formatters').opts(xformatter=formatter, yformatter='$%.2f', width=500) |
This file contains hidden or 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
#force reload of specific module without restarting kernel. Useful for debug | |
import importlib | |
importlib.reload(<module name>) | |
# get path of python exe jupyter lab is using | |
!python --version | |
!jupyter kernelspec list | |
!jupyter --version | |
!{sys.executable} -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple jjutil |
This file contains hidden or 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 shelve_multiple(list_of_objects=[],fname=''): | |
""" not providing filename, uses default current notebook name but slow ipynbname function | |
shelve files are fname.shelf.dir,.data, and .bak(?) | |
copy these files with ipynb files to save restore objects without re-running | |
""" | |
import ipynbname | |
if fname =='': | |
fname=ipynbname.name() #use note book name but way too slow so best to pass filename | |
This file contains hidden or 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
# output html without code only outputs. Use in ipynb file | |
# | |
#!pip install ipynbname | |
try : | |
import ipynbname #utility to get current notebook name and path | |
except: | |
!pip install ipynbname | |
import ipynbname #utility to get current notebook name and path | |
nb_fname_full= ipynbname.name()+'.ipynb' | |
!jupyter nbconvert "{nb_fname_full}" --no-input --to html |
NewerOlder