Skip to content

Instantly share code, notes, and snippets.

View Alexander-Barth's full-sized avatar

Alexander Barth Alexander-Barth

View GitHub Profile
@Alexander-Barth
Alexander-Barth / pcolor_NaN.jl
Last active December 12, 2016 21:28
Simple example how to make a pcolor plot with missing values (equal to NaN) in Julia
# pcolor plot with missing values (equal to NaN) in Julia
using PyCall
@pyimport numpy.ma as ma
# some random data
A = randn(10,10);
A[2,2] = NaN;
# created a Masked Array
# see also
@Alexander-Barth
Alexander-Barth / test_diffusion.jl
Last active October 10, 2019 14:16
1d diffusion in Julia (0.6) and Python (3.5)
using BenchmarkTools
# jmax iterations of a Laplacian smoother
function smooth!(x,jmax)
imax = length(x)
for j = 1:jmax
xm = x[1]
@Alexander-Barth
Alexander-Barth / gist:d07c20746f77c607de5a2f71f5ba4e6b
Last active April 26, 2019 14:39
jupyter notebook desktop launcher
mkdir ~/.local/share/applications
cd ~/.local/share/applications
cat > jupyter.desktop <<EOF
[Desktop Entry]
Name=Jupyter
Exec=jupyter-notebook
Terminal=false
Type=Application
Icon=jupyter.svg
Categories=GNOME;GTK;
@Alexander-Barth
Alexander-Barth / GeoRefDatasets.jl
Last active October 10, 2019 14:18
GeoRefDatasets
"""
Example module for georeferenced datasets
"""
module GeoRefDatasets
using Test
import Base: getindex, size, view
using BinaryBuilder
# Collection of sources required to build HDF5
name = "HDF5"
version = v"1.12.0"
sources = [
GitSource("https://github.com/steven-varga/hdf5.git",
"b49b22d6882d97b1ec01d482822955bd8e923203"),
# Crib MacOS binaries from PyPI
JULIA_VERSION=1.8.3
USER=student
# array with major, minor and revision number
JULIA_VERSION_PARTS=( ${JULIA_VERSION//./ } )
# just major and minor number
JULIA_VERSION_SHORT=${JULIA_VERSION_PARTS[0]}.${JULIA_VERSION_PARTS[1]}
mkdir -p /opt
@Alexander-Barth
Alexander-Barth / flux_vae.jl
Created June 2, 2021 16:21
convolutional varitional autoencoder in Flux.jl
# adapted from
# Keras_code_sample_for_Google_IO_2021
# Modern Keras design patterns | Session
# https://www.youtube.com/watch?v=FCz9m4T0DI0
# code: https://goo.gle/3t0rSpo
# by Martin Gorner, François Chollet
using Flux
using MLDatasets
using Random
@Alexander-Barth
Alexander-Barth / profile-julia-1.7.0-rc1-resblock5.log
Created September 24, 2021 10:54
profile-julia-1.7.0-rc1-resblock5.log
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
╎80490 @Base/client.jl:495; _start()
╎ 80490 @Base/client.jl:292; exec_options(opts::Base.JLOpt...
╎ 80490 @Base/Base.jl:420; include(mod::Module, _path::...
╎ 80490 @Base/loading.jl:1253; _include(mapexpr::Function,...
╎ 80490 @Base/loading.jl:1196; include_string(mapexpr::typ...
4╎ 80490 @Base/boot.jl:373; eval
45╎ ╎ 80486 ...ler/interface.jl:343; pullback(f::Function, ps::...
╎ ╎ 28 ...ler/typeinfer.jl:938; typeinf_ext_toplevel(mi::...
@Alexander-Barth
Alexander-Barth / profile-julia-1.5.3-resblock5.log
Created September 24, 2021 10:55
profile-julia-1.5.3-resblock5.log
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
╎423 @Base/client.jl:506; _start()
╎ 423 @Base/client.jl:296; exec_options(::Base.JLOptions)
╎ 423 @Base/Base.jl:368; include(::Module, ::String)
10╎ 423 @Base/Base.jl:380; include(::Function, ::Module, ...
╎ 4 ...mpiler/typeinfer.jl:601; typeinf_ext(::Core.MethodInsta...
╎ 4 ...piler/typeinfer.jl:570; typeinf_ext(::Core.MethodInst...
╎ ╎ 4 ...piler/typeinfer.jl:67; typeinf(::Core.Compiler.Infer...
3╎ ╎ 3 ...iler/typeinfer.jl:122; cache_result(::Core.Compiler...
@Alexander-Barth
Alexander-Barth / test_resnet.jl
Created February 7, 2022 15:40
PyTorch-resnet-for-flux
# needs julia 1.6 as long as this issue is open:
# https://github.com/JuliaIO/BSON.jl/issues/107
# License MIT
using Flux
import Metalhead
using DataStructures
using Statistics
using BSON