-
Notifications
You must be signed in to change notification settings - Fork 0
Description
In most scripts, the parent directory is simply appended to the system path
#-----------------------------------------
# I M P O R T S
#-----------------------------------------
import sys
sys.path.append("..")
If the kernel is not restarted, ".." is appended every time the script is run, leading to an overly long system path. A better alternative is
#-----------------------------------------
# I M P O R T S
#-----------------------------------------
import sys
import os
# Get the absolute path of the parent directory
parent_dir = os.path.abspath("..")
# Append the parent directory to sys.path if it is not already included
if parent_dir not in sys.path:
sys.path.append(parent_dir)
print("---------------------------------------")
print("System path:")
print(sys.path)
See benchmarks/potentials_D1_Quadratic.py
Add this improved system-path handling to all other benchmark scripts
Metadata
Metadata
Assignees
Labels
Type
Projects
Status