Skip to content

Instantly share code, notes, and snippets.

View rahulbhadani's full-sized avatar
🎯
Panda boy! 🍫

Rahul Bhadani rahulbhadani

🎯
Panda boy! 🍫
View GitHub Profile
@rahulbhadani
rahulbhadani / custom_ring.py
Created March 30, 2021 01:34
Custom Ring Network in Flow
from flow.core.params import VehicleParams
from flow.controllers import IDMController, ContinuousRouter
from flow.core.params import SumoParams, EnvParams, InitialConfig, NetParams
from flow.envs.ring.accel import AccelEnv, ADDITIONAL_ENV_PARAMS
from flow.core.experiment import Experiment
from flow.networks import Network
from numpy import pi, sin, cos, linspace
vehicles = VehicleParams()
@rahulbhadani
rahulbhadani / OSM_network.py
Created March 30, 2021 02:02
Import OSM network in Sumo
# the TestEnv environment is used to simply simulate the network
from flow.envs import TestEnv
# the Experiment class is used for running simulations
from flow.core.experiment import Experiment
# all other imports are standard
from flow.core.params import VehicleParams
from flow.core.params import NetParams
from flow.core.params import InitialConfig
@rahulbhadani
rahulbhadani / osm_daisy.py
Created March 30, 2021 07:04
From OSM Web Wizard
# the TestEnv environment is used to simply simulate the network
from flow.envs import TestEnv
import os
# the Experiment class is used for running simulations
from flow.core.experiment import Experiment
# all other imports are standard
from flow.core.params import VehicleParams
from flow.core.params import NetParams
@rahulbhadani
rahulbhadani / nvidia.md
Last active May 1, 2021 04:26
NVIDIA Installation

Installation

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb

sudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pub
@rahulbhadani
rahulbhadani / CARLA_0.9.12_diff.diff
Created September 2, 2021 06:39
Diff of CARLA repo incorporating changes to install it on Ubuntu 20.04
diff --git a/LibCarla/source/test/common/test_streaming.cpp b/LibCarla/source/test/common/test_streaming.cpp
index ad4f35c3..e5183e43 100644
--- a/LibCarla/source/test/common/test_streaming.cpp
+++ b/LibCarla/source/test/common/test_streaming.cpp
@@ -55,12 +55,12 @@ TEST(streaming, low_level_sending_strings) {
io_context_running io;
- Server<tcp::Server> srv(io.service, TESTING_PORT);
+ carla::streaming::low_level::Server<tcp::Server> srv(io.service, TESTING_PORT);
@rahulbhadani
rahulbhadani / eigen_polyfit.cpp
Last active February 22, 2025 21:28
Least Square Polynomial Fit
#include <Eigen/Dense>
#include <iostream>
#include <cmath>
#include <vector>
#include <Eigen/QR>
void polyfit( const std::vector<double> &t,
const std::vector<double> &v,
std::vector<double> &coeff,
int order
@rahulbhadani
rahulbhadani / gw-1.py
Created January 27, 2022 03:10
GW Distance
import scipy as sp
import numpy as np
import matplotlib.pylab as pl
from mpl_toolkits.mplot3d import Axes3D # noqa
import ot
n_samples = 50 # nb samples
mu_s = np.array([0, 0])
@rahulbhadani
rahulbhadani / gw-2.py
Created January 27, 2022 03:13
The GW distance
C1 = sp.spatial.distance.cdist(xs, xs)
C2 = sp.spatial.distance.cdist(xt, xt)
C1 /= C1.max()
C2 /= C2.max()
pl.figure()
pl.subplot(121)
pl.imshow(C1)
pl.subplot(122)
@rahulbhadani
rahulbhadani / gw-3.py
Created January 27, 2022 03:16
The GW Distance
p = ot.unif(n_samples)
q = ot.unif(n_samples)
gw0, log0 = ot.gromov.gromov_wasserstein(
C1, C2, p, q, 'square_loss', verbose=True, log=True)
print('Gromov-Wasserstein distances: ' + str(log0['gw_dist']))
pl.figure(1, (10, 5))
pl.imshow(gw0, cmap='jet')
pl.title('Gromov Wasserstein')
pl.colorbar()
@rahulbhadani
rahulbhadani / louvain_clustering.py
Created February 21, 2022 19:11
Louvain Clustering
import scanpy as sc
import pandas as pd
datafolder = "scRNAseqData/GSE146590"
adata = anndata.read_mtx(datafolder+'/GSM4396313_Ctrl_matrix.mtx.gz')
adata = adata1.T
adata.obs.index = pd.read_csv(datafolder+'/GSM4396313_Ctrl_barcodes.tsv.gz', header=None, index_col=0).index
genes = pd.read_csv(datafolder+'/GSM4396313_Ctrl_features.tsv.gz', header=None, index_col=0, sep='\t')[1].values