Skip to content

Instantly share code, notes, and snippets.

View ckesanapalli's full-sized avatar

Chaitanya Kesanapalli ckesanapalli

View GitHub Profile
@ckesanapalli
ckesanapalli / rotation_matrix.py
Last active April 17, 2024 14:59
3D Body Motion Rotation Matrix and the Angular Velocity
"""
3D Body Motion Rotation Matrix and the Angular Velocity.
Author: Chaitanya Kesanapalli
"""
import sympy
# =============================================================================
# Define the symbols
# =============================================================================
@ckesanapalli
ckesanapalli / interp.py
Last active June 30, 2023 14:37
Interpolate NaN values in ND array.
import numpy as np
from scipy.interpolate import griddata
def interp_nan(data, **griddata_kwargs):
"""
Interpolate NaN values in ND array.
Parameters
----------
data : np.ndarray
@ckesanapalli
ckesanapalli / main.py
Last active March 9, 2023 19:15
Find local minima and maxima of a 1D polynomial
import numpy as np
def find_local_min_max(poly_coefs: np.ndarray, atol: float | None = 1e-6):
"""
Find the local minima and maxima of a polynomial function.
Parameters
----------
poly_coefs : np.ndarray
The coefficients of the polynomial, ordered from lowest degree to highest.
@ckesanapalli
ckesanapalli / log_conf.py
Last active March 28, 2022 14:13
Logging configuration code with wrapper that log entry, exit and runtime of functions with a decorator using logging module
import logging
from datetime import datetime
from pathlib import Path
import functools
from pprint import pformat
def get_func_name(func):
"""Return the name of the given function including module name"""
if func.__class__.__module__ == "builtins":
mod_name = func.__module__ if hasattr(func, '__module__') and \
@ckesanapalli
ckesanapalli / main.py
Last active March 19, 2022 23:15
Logging entry, exit and runtime of functions with a decorator using loguru module
import time
from loguru import logger
from more_loguru import logger_wraps
logger.add('test.log', mode='w')
@logger_wraps(debug_io=True)
def my_func(a, b, c=1, d="Text"):
"""A test function"""
time.sleep(1)