Skip to content

Instantly share code, notes, and snippets.

View ugo-nama-kun's full-sized avatar
🧠
@Homeostasis x Robots

naoto yoshida ugo-nama-kun

🧠
@Homeostasis x Robots
View GitHub Profile
@ugo-nama-kun
ugo-nama-kun / a.sh
Last active August 17, 2021 09:49
複数のセッションを開いてそれぞれに引数を渡して実行するやーつ
val=42
for i in $(seq 1 5); do
echo $1
echo $(($val+$2))
done
@ugo-nama-kun
ugo-nama-kun / centering_plots_in_jupyter.py
Last active August 10, 2021 08:03
Plot figure in the center of jupyter notebook
import numpy as np
from IPython.core.display import HTML
import matplotlib.pyplot as plt
# if you like seaborn:
import seaborn as sns
sns.set()
sns.set_context("talk")
HTML("""
@ugo-nama-kun
ugo-nama-kun / mujoco-py-marker.py
Last active December 6, 2021 05:55
How to use the marker util of mujoco-py
import numpy as np
import gym
from gym.envs.mujoco import mujoco_env
from mujoco_py.generated import const
from scipy.spatial.transform import Rotation
""" Marker types in const
GEOM_PLANE = 0
@ugo-nama-kun
ugo-nama-kun / number_print.py
Created August 4, 2021 07:12
python の有効数字
print('{:.3f}'.format(123.456))
# 123.456
print(f"{0.12345678:.3f}")
# 0.123
# Other Examples
print('{:.3e}'.format(123.456))
print('{:.3g}'.format(123.456))
print('{:.3}'.format(123.456))
@ugo-nama-kun
ugo-nama-kun / random_seeding.py
Last active August 2, 2021 10:50
A summary of seeding in some packages
import random
import functools
import numpy as np
import tensorflow as tf
import torch
import gym
import tianshou as ts
@ugo-nama-kun
ugo-nama-kun / plot_settings.py
Last active January 12, 2022 03:22
よくある matplotlib で plot してそれを保存する方法:heatmap/300 dpi/png
import seaborn as sns
import matplotlib.pyplot as plt
# load data
x_ticks = np.linspace(0, 1, 10)
y_ticks = np.linspace(0, 1, 10)
# ちなみに save は np.save("data_matrix.npy", data_matrix) みたいなかんじで
data_matrix = np.load("data_matrix.npy")
@ugo-nama-kun
ugo-nama-kun / get_logger.py
Last active April 25, 2022 04:39
Logger の取り方
import os
from datetime import datetime
import logging.config
from logging import StreamHandler, FileHandler, Formatter
from logging import INFO, DEBUG, NOTSET
def get_new_logger(name, file_path="./log"):
# ストリームハンドラの設定
import numpy as np
from sklearn import datasets
"""
8x8 tiny NIST image handler
NIST dataset: https://scikit-learn.org/stable/datasets/toy_dataset.html#digits-dataset
If you chose NistHandle(flat=True), you'll get 64-dim vector instead of 8x8 numpy array.
from datetime import datetime
s = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
print(s)
"""
You'll get something like.... 🍺
'2021-06-08-15-35-32'
"""
@ugo-nama-kun
ugo-nama-kun / qtoe_etoq.py
Last active May 29, 2021 10:50
Quarternion to Euler & Euler to Quarternion
# Reference: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
# Quaternion to Euler
def qtoeuler(q):
""" quaternion to Euler angle
:param q: quaternion
:return:
"""