Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

David Ojeda dojeda

🏠
Working from home
  • Paris, France
View GitHub Profile
@dojeda
dojeda / riemann_euclid_plot.py
Created Jun 8, 2020
Comparison of distance functions on covariance matrices
View riemann_euclid_plot.py
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from pyriemann.utils.distance import distance_riemann
@partial(np.vectorize, excluded=['ref'])
def distance_riemann_v(c_xx, c_yy, ref):
""" Vectorized version of distance_riemann projected in 2D
@dojeda
dojeda / openapi.yaml
Created Feb 17, 2019
Example OpenAPI specification for inline model bug reproduction
View openapi.yaml
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
@dojeda
dojeda / epoching.py
Last active Mar 22, 2018
Epoching of 2D array on its last dimension using a view (not a copy)
View epoching.py
""" Small proof of concept of an epoching function using NumPy strides
License: BSD-3-Clause
Copyright: David Ojeda <david.ojeda@gmail.com>, 2018
"""
import numpy as np
from numpy.lib import stride_tricks
View eigen_mwe.cpp
#include <iostream>
#include <vector>
#include <Eigen/Dense>
int main(int argc, char *argv[]) {
Eigen::MatrixXd X = Eigen::MatrixXd::Random(3, 3);
// PCA = EVD of the covariance matrix
Eigen::SelfAdjointEigenSolver < Eigen::MatrixXd > solver(X.selfadjointView<Eigen::Lower>());
@dojeda
dojeda / trigraphs-c++
Created Apr 15, 2015
TIL about trigraphs in C and C++. Wat the fk!
View trigraphs-c++
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int main(int , char *[]) {
vector<int> v1 = {0,1,2};
View square root 2
#!/usr/bin/env python
def sqrt(x):
begin = 0
end = x
while begin <= end:
mid = begin + (end - begin) // 2
You can’t perform that action at this time.