In Pyspark, you can use:
persisted_RDDs = spark.sparkContext._jsc.getPersistentRDDs()
for (i, rdd_) in persisted_RDDs.items():
rdd_.unpersist()
spark
is of type pyspark.sql.session.SparkSession
.
In Pyspark, you can use:
persisted_RDDs = spark.sparkContext._jsc.getPersistentRDDs()
for (i, rdd_) in persisted_RDDs.items():
rdd_.unpersist()
spark
is of type pyspark.sql.session.SparkSession
.
Github can render LaTeX equations in jupyter notebooks but directly embedding equations in markdown files don't work. Solution is to embed URL correspondingto LaTeX equation. The page below shows how to convert LaTeX to URL. All the credit goes to this gist and its comments.
# Create a triangle + label of vertices | |
import numpy as np | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
fig, ax = plt.subplots(1,1,figsize=(5,5)) | |
ax.plot(*coordinates[bonds].T, '-o', lw=3); | |
for i, p in enumerate(coordinates): |
def isFlipped(sites1, sites2, bonds): | |
""" | |
Check if neighbors of a vertex | |
have changed the cyclic order. | |
""" | |
def sortClockwiseAroundVertex(coordinates, root, neighbors): | |
''' | |
Sort the neighbors of a vertex, | |
such that the one with lowest index |
""" | |
Mahd Sadjadi (2018) | |
This is a set of functions to compute the | |
energy barrier between two spring networks. | |
The morphing is done using the linear interpolation. | |
Example: | |
------- | |
s1 = np.random.rand(10,2) | |
s2 = np.random.rand(10,2) |
def pointAlignment(ref, move): | |
""" | |
Mahd Sadjadi (2017) | |
This is a function which takes two sets of | |
points each with N points (both inputs are assumd to be | |
numpy arrays of N*2 shape). The first input is | |
the reference grid and the second is the point set to | |
be aligned with the reference. | |
This function shifts and rotate points to | |
make the two sets aligned and returns the |
# A simple implementation of Stack data structure in python | |
# LIFO: last (item) in, first (item) out | |
# Insert at the end, pop the front of the list | |
class Stack(): | |
def __init__(self): | |
self.items = [] | |
def isEmpty(self): |
# A simple implementation of Queue data structure in python | |
# FIFO: first (item) in, first (item) out | |
# Insert at the front, pop at the end of the list | |
class Queue(): | |
def __init__(self): | |
self.items = [] | |
def isEmpty(self): |
''' | |
This code generates a picture of the specific | |
heat of a two-level system. It also shows | |
the limits in low- and high-temperatures | |
regions, in addition to the location of | |
the maximum specific heat. | |
Mahdi Sadjadi, 2017. | |
''' | |
import numpy as np |
''' | |
This code generates a picture of a symmetric | |
one-dimensional double-well pontetial. | |
Mahdi Sadjadi, 2017. | |
''' | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FuncFormatter, MaxNLocator | |
for param in ['axes.labelsize','xtick.labelsize','ytick.labelsize']: |