Skip to content

Instantly share code, notes, and snippets.

View skim0119's full-sized avatar
🌺
I may be slow to respond.

Seung Hyun Kim skim0119

🌺
I may be slow to respond.
  • Urbana Champaign
View GitHub Profile
@skim0119
skim0119 / PythonLazyImport
Last active September 5, 2025 16:30
Lazy import: Create alias or shortcut in package without loading entire folder. Reduce chance for circular import
Better way to create alias/shortcut in python package than `from .module import *`
## purpose
When a module is loaded with `from .module import ...` and if `module` is placed within some nested directory structure, python tends to load all hierarchy of modules upstream, even when user only need this single module. This hinders if different modules in the package is supposed to operate independently, and significantly increase the loading time. In addition, adding alias and shortcut in `__init__.py` requires careful management to avoid circular import.
The script dynamically load the module upon request, and the request happens at the file-level such that it does not load the entire modules in parent trees.
## import order
- pre-defined dictionary
- regular import
- ImportError
@skim0119
skim0119 / large_mpi_gather.py
Last active April 8, 2024 13:41
To resolve the case for running Gatherv with large size array.
import numpy
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
root = 0
data = ... # Some large array, flattened
total_size = data.size
np_type = data.dtype
@skim0119
skim0119 / main.py
Last active January 13, 2024 06:52
Run batch spike detection using MiV-OS
"""
Main is called from other runfile.
This script parse the configuration yaml file and push the task into some `func`.
"""
import pathlib
import os
from omegaconf import DictConfig, OmegaConf
import hydra
import os
import glob
import h5py
import logging
import numpy as np
from tqdm import tqdm
from mpi4py import MPI
@skim0119
skim0119 / Two-step spikestamps conversion to continuous event function test.ipynb
Last active November 5, 2022 08:46
Test to match event-base stepping vs analytical solution
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skim0119
skim0119 / build_elastica.sh
Created August 29, 2022 22:08 — forked from tp5uiuc/build_elastica.sh
Build Elastica on systems
#!/usr/bin/env bash
declare -A compilers
# compilers[gcc]="/home/linuxbrew/.linuxbrew/opt/gcc@8/bin/g++-8"
compilers[gcc10]=g++-10
# compilers[gcc11]=g++-11
# compilers[clang]=clang++-8
declare -A cmake_build_types
# cmake_build_types[debug]="Debug"
@skim0119
skim0119 / Storing-Images-On-Github.md
Created February 7, 2022 05:55 — forked from joncardasis/Storing-Images-On-Github.md
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets

@skim0119
skim0119 / moviepy_record_gym.py
Created January 21, 2022 21:18
Export video of gym episode using moviepy.
import gym
import gym_softrobot
from moviepy.editor import VideoClip
def main():
fps = 30
env = gym.make('OctoFlat-v0', recording_fps=fps)
# env is created, now we can use it:
@skim0119
skim0119 / pypi-release-checklist.md
Last active December 29, 2021 04:34 — forked from audreyfeldroy/pypi-release-checklist.md
My PyPI Release Checklist

Release Checklist

  • Update RELEASE.md - It should be in based on milestone description.
  • Commit the changes:
git add RELEASE.md
git commit -m "Changelog for upcoming release <version>"
  • Final check README and CONTRIBUTING.

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a