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
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.path import Path | |
from matplotlib.patches import PathPatch | |
import mpl_toolkits.mplot3d.art3d as art3d | |
positions = np.random.random((3, 50)) * 10 | |
fig = plt.figure() |
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
A = [1, 2, 3, 4] | |
B = ['a', 'b', 'c'] | |
# saw this version on a Coursera Course | |
# If you actually use this crappy style, wat | |
print([a for b in B for a in A]) | |
# Equivilant | |
result = [] | |
for b in B: |
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 re | |
import freud | |
import numpy as np | |
import networkx as nx | |
from io import StringIO | |
from scipy.spatial.distance import squareform, pdist | |
def should_join(p1, p2): | |
return 0 in pdist(np.concatenate((p1, p2))[:, None]) |
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 numpy as np | |
from scipy.spatial.distance import pdist | |
import matplotlib.pyplot as plt | |
from scipy.stats import binned_statistic | |
from numba import njit | |
@njit | |
def pairwise_dot(x): | |
""" |
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 numpy as np | |
from scipy.spatial.distance import pdist, squareform | |
import matplotlib.pyplot as plt | |
def pdist_pbc(positions, box): | |
""" | |
Get the pair-wise distances of particles in a priodic boundary box | |
Args: |
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
""" | |
This module is a demonstartion of using scipy to solve LP problem | |
following this tutorial: https://realpython.com/linear-programming-python | |
The problem os as following | |
maximize z = x + 2 y, same as minimizing -z = -x - 2y | |
subject to 2x + y <= 20 | |
-4x + 5y <= 10 | |
-x + 2y >= -2, same as x - 2y <= 2 for scipy |
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 numpy as np | |
import matplotlib.pyplot as plt | |
from scipy import ndimage | |
from matplotlib.pyplot import plot, scatter, imshow | |
def simulate_2d(N): | |
theta = np.random.uniform(-np.pi, np.pi, (1000, N)) | |
x = np.cos(theta).mean(-1) # shape (1000,) | |
y = np.sin(theta).mean(-1) # shape (1000,) | |
order = np.linalg.norm((x, y), axis=0) |
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
import numpy as np | |
import re | |
def get_frames_from_xyz(filename, use_cols): | |
""" | |
Get all data from different frames from an xyz file | |
Args: | |
filename (str): the path of the xyz file to parse |