the python files are obtained by running the following script:
bash << 'EOF'
current_date_time=$(date +"%Y-%m-%d %H:%M:%S")
output=$(ls /home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/*.py)
output=$'this command was run on '"${current_date_time}"$':\n------------------------\n'"${output}"
output=$'```\n'"${output}"$'\n```'
echo "$output"
echo "$output" | wl-copy
EOF
this command was run on 2026-03-15 13:15:57:
------------------------
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/get-kernel-id-in-progress.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/initial_analysis.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/jupytext-test1.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/lets-go-baby.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/open_spreadsheets.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/some-notes.py
/home/chris-jakoolit/christopherpaine_org/_code/bayesian-pca/watch.py
./get-kernel-id-in-progress.py
import os
import ipykernel
connection_file = os.path.basename(ipykernel.connect.get_connection_file())
kernel_id = connection_file.split('-', 1)[1].split('.')[0]
print(kernel_id)
./lets-go-baby.py
this is the file i edit to create ipynb jupyter notebooks
./some-notes.py
#
# ### Issues with np.log
# Using np.log on csv on the combined array without adjustment causes issues. These were not fully investigated however it is likely due to fact that csv imports notoriously bring in values with quotes and spaces and suchlike that don't get recognised as numberical values. (even though inspection on datatype is showing float64)
#
# we therefore use the .to_numeric dataframe function before passing into numpy
#
# ### Issues with to_numeric
# .to_numeric function works on the first row of dataframe since df.iloc[1,1:} returns a pandas series.
# .to_numeric function doesnt work on the whole dataframe however since df.iloc[:,1:] returns another dataframe and not a series
#
#
# ### .stack() and .unstack() solutions
# The DataFrame.stack() function pivots the columns of a DataFrame into the row index, producing a _Series with a MultiIndex_.
# It reshapes wide-form data into long-form data.
# Wide-form data is where each row is a single observation.
# Long-form data is where each row is a measurement.
# In this use case an observation represents the spot yields at multiple terms for a single date
# and a measurement is a single spot rate at a specific term at a specific date (measurements are more granular than observations)
#
# .stack() turns columns into rows
# it also converts the datatype from dataframe to series (which is necessary for our .to_numeric function to work)
#
./watch.py
import os
import subprocess
import time
def watch_directory(path='.'):
before = {f: os.path.getmtime(f) for f in os.listdir(path)}
while True:
time.sleep(5)
after = {f: os.path.getmtime(f) for f in os.listdir(path)}
added = [f for f in after if f not in before]
removed = [f for f in before if f not in after]
modified = [f for f in after if f in before and before[f] != after[f]]
if added:
print("Added: ", ", ".join(added))
if removed:
print("Removed: ", ", ".join(removed))
if modified:
print("Modified: ", ", ".join(modified))
if is_python_file(modified[0]) and modified[0] != 'notation.py' and modified[0] != 'functions.py':
print ("this was a python file")
run_bash_command("jupytext --sync "+str(modified[0]))
run_bash_command("jupyter nbconvert --to notebook --inplace --execute --allow-errors "+remove_file_extension(modified[0])+".ipynb")
run_bash_command("jupyter nbconvert --to html " + remove_file_extension(modified[0])+".ipynb" + " --output "+ remove_file_extension(modified[0])+ ".html")
run_bash_command("jupyter nbconvert --to html --no-input --no-prompt " +remove_file_extension(modified[0])+".ipynb" + " --output "+ remove_file_extension(modified[0]) + "-clean.html")
# print("done - in 15 seconds will take snapshots of timestamps")
time.sleep(15)
# run_bash_command("git add .")
# run_bash_command("git commit -m '.'")
# run_bash_command("git push")
after = {f: os.path.getmtime(f) for f in os.listdir(path)}
added = [f for f in after if f not in before]
removed = [f for f in before if f not in after]
modified = [f for f in after if f in before and before[f] != after[f]]
before = after
print("waiting...")
def run_bash_command(command):
result = subprocess.run(command, shell=True, capture_output=False, text=True)
def remove_file_extension(filename):
return '.'.join(filename.split('.')[:-1]) if '.' in filename else filename
def is_python_file(filename):
return filename.endswith('.py')
watch_directory()
one