Skip to content

Instantly share code, notes, and snippets.

View jan-matthis's full-sized avatar

jan-matthis jan-matthis

View GitHub Profile
# test.py
from abc import ABC, abstractmethod
class Parent(ABC):
def __init__(self, arg):
"""Parent __init__
Args:
arg: Arg
============================= test session starts =============================
platform win32 -- Python 3.7.7, pytest-5.4.3, py-1.8.2, pluggy-0.13.1 -- c:\users\user\anaconda3\envs\sbi_env\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\User\sbi\sbi-master, inifile: setup.cfg
collecting ... collected 149 items
tests/inference_with_NaN_simulator_test.py::test_handle_invalid_x[x_shape0] PASSED [ 0%]
tests/inference_with_NaN_simulator_test.py::test_handle_invalid_x[x_shape1] PASSED [ 1%]
tests/inference_with_NaN_simulator_test.py::test_handle_invalid_x[x_shape2] PASSED [ 2%]
tests/inference_with_NaN_simulator_test.py::test_handle_invalid_x[x_shape3] PASSED [ 2%]
@jan-matthis
jan-matthis / transform_posterior.py
Created July 16, 2019 22:23
transform_posterior
def transform_posterior(posterior, lower, upper):
rescale = lambda x: (x - lower) / (upper - lower)
inverse_rescale = lambda x: x*(upper - lower) + lower
bijection = lambda x: expit(x) * (upper - lower) + lower
inverse_bijection = lambda x: logit(rescale(x))
# log abs determinant of jacobian
bijection_jac_logD = lambda x: np.log(np.abs((expit(x) * (1-expit(x)) * (p.upper - p.lower)).prod(axis=-1)))
# gradients based on http://bsou.io/posts/color-gradients-with-python
def hex_to_RGB(hex):
''' "#FFFFFF" -> [255,255,255] '''
# Pass 16 to the integer function for change of base
return [int(hex[i:i+2], 16) for i in range(1,6,2)]
def RGB_to_hex(RGB):
''' [255,255,255] -> "#FFFFFF" '''
@jan-matthis
jan-matthis / mdn_demo.ipynb
Created November 20, 2017 10:40
MDN in PyTorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am jan-matthis on github.
  • I am janmatthis (https://keybase.io/janmatthis) on keybase.
  • I have a public key whose fingerprint is AA9E 3AAD 49B1 AC62 5DDE F7AF 1B85 B50C 639D DDFE

To claim this, I am signing this object:

@jan-matthis
jan-matthis / font-awesome.json
Last active August 28, 2015 14:53 — forked from jabney/font-awesome.json
Font Awesome JSON Entity Reference
{"cc": "\uf20a", "bookmark": "\uf02e", "venus-mars": "\uf228", "arrow-circle-o-down": "\uf01a", "comment-o": "\uf0e5", "long-arrow-left": "\uf177", "arrow-right": "\uf061", "delicious": "\uf1a5", "chevron-circle-left": "\uf137", "bullhorn": "\uf0a1", "outdent": "\uf03b", "jpy": "\uf157", "drupal": "\uf1a9", "hdd-o": "\uf0a0", "hand-o-left": "\uf0a5", "pinterest": "\uf0d2", "plane": "\uf072", "question": "\uf128", "child": "\uf1ae", "circle-o": "\uf10c", "italic": "\uf033", "meanpath": "\uf20c", "subway": "\uf239", "google-plus": "\uf0d5", "angle-up": "\uf106", "star": "\uf005", "star-half-empty": "\uf123", "facebook-official": "\uf230", "youtube-square": "\uf166", "rss": "\uf09e", "toggle-off": "\uf204", "list-ol": "\uf0cb", "dot-circle-o": "\uf192", "copyright": "\uf1f9", "user": "\uf007", "key": "\uf084", "minus-square-o": "\uf147", "mobile": "\uf10b", "table": "\uf0ce", "columns": "\uf0db", "bolt": "\uf0e7", "fighter-jet": "\uf0fb", "share-square-o": "\uf045", "file-archive-o": "\uf1c6", "retweet": "\uf079
@jan-matthis
jan-matthis / calcDiff.js
Created August 21, 2015 13:22
diff() in JS
var calcDiff = function(arr) {
var calc = function(n, i) { return n - arr[i]; }
return arr.slice(1).map(calc);
}
@jan-matthis
jan-matthis / findConnectedRegions.js
Created August 21, 2015 13:20
JS to find connected regions
/* JS to find connected regions */
var findConnectedRegions = function(arr) {
var distinct = [];
var durations = [];
var labels = [];
var idx = 0;
var calcCumSum = function(arr) {
var calc = function(acc, n) {
# IPython magic to check for PEP8 compliance.
# Author: Juan Luis Cano <juanlu001@gmail.com>
"""IPython magic to check for PEP8 compliance.
To use it, type
```%load_ext pep8magic```
and then