mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-04-30 09:38:38 -05:00
Refactors code to use constants and formulas
Replaces hardcoded numerical values with symbolic Python variables derived from defined constants and formulas. This improves code maintainability and consistency, ensuring calculations are based on accurate and up-to-date physical values.
This commit is contained in:
@@ -3,13 +3,13 @@ import sys
|
||||
import os
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Setup path to import from quarto/calc
|
||||
# Setup path to import from quarto/physx
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(os.path.join(project_root, 'quarto'))
|
||||
|
||||
from calc import viz
|
||||
from calc import ch_hw_acceleration
|
||||
from calc import ch_appendix_algorithm
|
||||
from physx import viz
|
||||
from physx import ch_hw_acceleration
|
||||
from physx import ch_appendix_algorithm
|
||||
|
||||
def generate_preview_assets():
|
||||
output_dir = os.path.join(project_root, "quarto/assets/images/generated")
|
||||
|
||||
@@ -2,9 +2,10 @@ import sys
|
||||
import os
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Add calc directory to path
|
||||
sys.path.append(os.path.abspath('book/quarto/calc'))
|
||||
import viz
|
||||
# Add physx directory to path
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(os.path.join(project_root, 'quarto'))
|
||||
from physx import viz
|
||||
|
||||
# Output directory
|
||||
OUTPUT_DIR = "book/quarto/assets/preview_plots"
|
||||
|
||||
@@ -2,9 +2,10 @@ import sys
|
||||
import os
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Add calc directory to path
|
||||
sys.path.append(os.path.abspath('book/quarto/calc'))
|
||||
import viz
|
||||
# Add physx directory to path
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(os.path.join(project_root, 'quarto'))
|
||||
from physx import viz
|
||||
|
||||
# Output directory
|
||||
OUTPUT_DIR = "book/quarto/assets/preview_plots"
|
||||
|
||||
Reference in New Issue
Block a user