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
using PyCall | |
ImageDataGenerator = pyimport("keras").preprocessing.image.ImageDataGenerator | |
train = ImageDataGenerator(rescale = 1/255) | |
train_generator = train.flow_from_directory(train_dir, target_size = (150, 150), batch_size = 20, class_mode = "binary") |
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
function ideal_rows_cols(N::Int) | |
root = max(1.0, sqrt(N)) | |
nrows, ncols = ceil(Int, root), ceil(Int, root) | |
end | |
function gridify!(gridlayout) | |
nrows, ncols = ideal_rows_cols(length(gridlayout.content)) | |
contentcopy = copy(gridlayout.content) | |
for (i, c) in enumerate(contentcopy) | |
row = ceil(Int, i / ncols) | |
col = (i - 1) % ncols + 1 |
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
import numpy | |
import dolfin | |
def SyncSum(vec): | |
""" Returns sum of vec over all mpi processes. | |
Each vec vector must have the same dimension for each MPI process """ | |
comm = dolfin.MPI.comm_world | |
NormalsAllProcs = numpy.zeros(comm.Get_size()*len(vec), dtype=vec.dtype) |
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 dolfin import * | |
import dolfin.cpp.function | |
mesh = UnitSquareMesh(1, 1) | |
V = FunctionSpace(mesh, 'DG', 0) | |
# Create boundary mesh: | |
boundary = BoundaryMesh(mesh, "exterior") | |
# Get initial configuration as CG1 vector-valued Function: | |
d = mesh.geometry().dim() |
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 dolfin import * | |
def solve_linear_elasticity(mesh, boundaries, d): | |
c = Constant(d) | |
V = VectorFunctionSpace(mesh, "Lagrange", 1) | |
u = TrialFunction(V) | |
v = TestFunction(V) | |
E, nu = 10.0, 0.3 |
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
MeshVeloc ; // computation of mesh velocity (cx,cy) | |
Th = movemesh(Th,[x+dt*cx,y+dt*cy]); // The mesh is moved | |
tmp=ux[]; pux=0; pux[]=tmp ; // the variable are pushed forward |
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
import matplotlib.pyplot as plt | |
from dolfin import * | |
class Problem(NonlinearProblem): | |
def __init__(self, J, F, bcs): | |
self.bilinear_form = J | |
self.linear_form = F | |
self.bcs = bcs | |
NonlinearProblem.__init__(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
# on juno_satartup.jl | |
if isdefined(Main, :Revise) && isdefined(Main, :Atom) | |
getfield(Main, :Revise).setup_atom(getfield(Main, :Atom)) | |
end | |
# on startup.jl | |
atreplinit() do repl | |
try | |
@eval using Revise | |
@async Revise.wait_steal_repl_backend() | |
catch |
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
installation: | |
# Install package | |
sudo apt install -y ccache | |
# Update symlinks | |
sudo /usr/sbin/update-ccache-symlinks | |
# Prepend ccache into the PATH | |
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |