mac_os = "darwin" os_name = str(platform.system()).lower() if os_name == windows_os: clointfusion_directory = r"C:\Users\{}\ClointFusion".format( str(os.getlogin())) elif os_name == linux_os: clointfusion_directory = r"/home/{}/ClointFusion".format(str( os.getlogin())) elif os_name == mac_os: clointfusion_directory = r"/Users/{}/ClointFusion".format( str(os.getlogin())) cf_icon_cdt_file_path = os.path.join(clointfusion_directory, "Logo_Icons", "Cloint-ICON-CDT.ico") pi.install_traceback(hide_locals=True, relevant_only=True, enable_prompt=True) pretty.install() toaster = ToastNotifier() local_msg = "" local_url = "" local_date = datetime.datetime.now().strftime("%d/%m/%Y") server_date = "" def act_on_click(): global local_msg if "new version" in str(local_msg).lower():\ os.system('cf')
""" This tutorial shows how to use pyinspect to produce pretty and informative traceback stacks """ # import pyinspect and install the traceback handler import pyinspect import numpy as np pyinspect.install_traceback() # use hide_locals=True to hide locals panels # make some buggy code a = np.ones(5) b = "ignore this" # a local variable not being used c = np.zeros(4) # ooops, wrong size a + c # this will give an error """ Note: in the traceback a,b will be highlighted because they are in the line causing the error. 'b' will be shown as well though. To only show the variables in the error line pass relevant_only=True to `install_traceback` To only show relevant variables, pass 'only_relevant=True' to `pyinspect.install_traceback`. """
import numpy as np from pathlib import Path from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler from rich.progress import track import pandas as pd from myterial import cyan, teal, indigo, orange, salmon, grey_light, grey, grey_dark, blue_grey_darker from myterial import brown_dark, grey, blue_grey_dark, grey_darker, salmon_darker, orange_darker, blue_grey from scipy.stats import zscore from collections import namedtuple from pyrnn.analysis.dimensionality import get_n_components_with_pca from scipy.stats import ttest_ind, linregress from statsmodels.stats.multitest import multipletests from pyinspect import install_traceback install_traceback() from fcutils.plotting.utils import calc_nrows_ncols, clean_axes, save_figure from fcutils.maths.utils import rolling_mean, derivative from fcutils.plotting.plot_distributions import plot_kde from vgatPAG.database.db_tables import ManualBehaviourTags, Roi, Sessions from Analysis import get_session_data, get_session_tags, get_tags_sequences, speed_color, shelt_dist_color # %% pre_pos_s = 1.5 pre_pos = int(pre_pos_s * 30) n_s_pre, n_s_post = 5, 2 n_frames_pre = n_s_pre * 30
import os from pathlib import Path import sys import brainrender.default_variables from brainrender.Utils.data_io import save_yaml, load_yaml from brainrender.Utils.ruler import ruler import warnings import pyinspect pyinspect.install_traceback() __all__ = [ "DEFAULT_ATLAS", "BACKGROUND_COLOR", "DEFAULT_HDF_KEY", "DEFAULT_NEURITE_RADIUS", "DEFAULT_STRUCTURE_ALPHA", "DEFAULT_STRUCTURE_COLOR", "DISPLAY_INSET", "DISPLAY_ROOT", "HDF_SUFFIXES", "INJECTION_DEFAULT_COLOR", "INJECTION_VOLUME_SIZE", "NEURON_ALPHA", "NEURON_RESOLUTION", "ROOT_ALPHA", "ROOT_COLOR", "SHADER_STYLE", "SHOW_AXES", "SOMA_RADIUS",
from PIL import Image from pathlib import Path import click import pyinspect as pi import os pi.install_traceback() @click.command() @click.argument("fpath") def get(fpath): print(f"Extracting gif last frame: {fpath}") path = Path(fpath) # get last image im = Image.open(fpath) im.seek(im.n_frames - 1) # save fld, name = path.parent, path.name newname = name.replace(".gif", ".png") im.save(str(fld / newname), format="png") print(f"Saving image at : {str(fld / newname)}") if "intro" not in fpath: os.remove(fpath)
def test_traceback_args(): pi.install_traceback(hide_locals=True) raise_exception() pi.install_traceback(hide_locals=False) raise_exception() pi.install_traceback(all_locals=True) raise_exception() pi.install_traceback(all_locals=False) raise_exception() pi.install_traceback(relevant_only=True) raise_exception() pi.install_traceback(relevant_only=False) raise_exception() pi.install_traceback(keep_frames=0) raise_exception() pi.install_traceback(keep_frames=-1) raise_exception() pi.install_traceback(keep_frames=5) raise_exception()
def test_install(): pi.install_traceback() raise_exception() raise_exception_with_objs()
import os from loguru import logger import sys from pathlib import Path from rich.logging import RichHandler from brainrender import settings try: from pyinspect import install_traceback install_traceback(hide_locals=not settings.DEBUG) except ImportError: pass # fails in notebooks from brainrender.scene import Scene import brainrender.actors from brainrender.video import VideoMaker, Animation from brainrender.atlas import Atlas base_dir = Path(os.path.join(os.path.expanduser("~"), ".brainrender")) base_dir.mkdir(exist_ok=True) __version__ = "2.0.4.7" # set logger level def set_logging(level="INFO", path=None): """ Sets loguru to save all logs to a file i brainrender's base directory and to print
import sys sys.path.append("./") from pyinspect import install_traceback, search install_traceback(keep_frames=0, hide_locals=True) import pandas as pd import numpy as np import os from tqdm import tqdm from datetime import datetime import matplotlib.pyplot as plt from loguru import logger from pathlib import Path from rich.progress import track from fcutils.file_io.utils import check_file_exists, check_file_exists, check_create_folder from fcutils.file_io.io import load_csv_file, save_json from fcutils.maths.utils import rolling_mean from analysis.utils.analysis_utils import parse_folder_files from analysis.utils.utils import calibrate_sensors_data, correct_paw_used, compute_center_of_gravity, get_onset_offset from analysis import paths # ---------------------------------------------------------------------------- # # SETUP # # ---------------------------------------------------------------------------- # DEBUG = False # set as true to have extra plots to check everything's OK # --------------------------------- Variables -------------------------------- # CONDITIONS = ('WT', ) # keep only data from these conditions
import datajoint as dj import numpy as np from pathlib import Path from rich.prompt import IntPrompt from scipy import signal from scipy.stats import zscore from rich.progress import track import pandas as pd import matplotlib.pyplot as plt from vgatPAG.database.dj_config import start_connection, dbname, manual_insert_skip_duplicate from pyinspect import install_traceback install_traceback(keep_frames=2, relevant_only=True) from fcutils.file_io.io import open_hdf from fcutils.maths.utils import derivative, rolling_mean from fcutils.video.utils import get_cap_from_file, get_video_params from fcutils.plotting.utils import save_figure from behaviour.tracking.tracking import prepare_tracking_data schema = start_connection() fld = Path( 'D:\\Dropbox (UCL)\\Project_vgatPAG\\analysis\\doric\\VGAT_summary\\temp_tagged-mp4' ) @schema class Mouse(dj.Manual): definition = """ mouse: varchar(64) """