Move tutte_embedding to lib, add bash completion, and fix NixOS setup

- Replace iterative tutte_embedding in lib with numpy direct-solve version from example.py
- Import tutte_embedding into example.py from lib instead of defining it locally
- Fix g._embedding -> g.get_embedding() in outer_face
- Add bash completion to run.sh alongside existing zsh completion
- Use nix-shell -p gcc for plantri build step on NixOS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 21:02:22 -04:00
parent 52ba816a90
commit 03f92494f1
3 changed files with 87 additions and 93 deletions
+43 -3
View File
@@ -55,7 +55,11 @@ with open("$SCRIPT_DIR/.vscode/settings.json", "w") as f:
f.write("\n")
EOF
make -C "$SCRIPT_DIR/plantri"
if command -v nix-shell &>/dev/null; then
nix-shell -p gcc --run "make -C \"$SCRIPT_DIR/plantri\""
else
make -C "$SCRIPT_DIR/plantri"
fi
"$sage_python_path" -m venv "$SCRIPT_DIR/.venv"
"$VENV_PYTHON" -m pip install -r "$SCRIPT_DIR/requirements.txt"
@@ -116,7 +120,7 @@ _run_sh() {
_files
;;
completion)
_values 'shell' 'zsh'
_values 'shell' 'zsh' 'bash'
;;
esac
;;
@@ -124,10 +128,46 @@ _run_sh() {
}
compdef _run_sh run.sh
EOF
;;
bash)
cat <<'EOF'
_run_sh() {
local cur prev words cword
_init_completion || return
local subcmds='init_paper setup sage lint completion'
if [[ $cword -eq 1 ]]; then
COMPREPLY=( $(compgen -W "$subcmds" -- "$cur") )
return
fi
case ${words[1]} in
init_paper)
# free-form paper title, no completion
;;
setup)
case $((cword - 1)) in
1) COMPREPLY=( $(compgen -f -- "$cur") ) ;;
2) COMPREPLY=( $(compgen -d -- "$cur") ) ;;
3) COMPREPLY=() ;; # system name, free-form
esac
;;
sage|lint)
COMPREPLY=( $(compgen -f -- "$cur") )
;;
completion)
COMPREPLY=( $(compgen -W 'zsh bash' -- "$cur") )
;;
esac
}
complete -F _run_sh run.sh
EOF
;;
*)
echo "Unsupported shell: $shell. Supported: zsh" >&2
echo "Unsupported shell: $shell. Supported: zsh bash" >&2
exit 1
;;
esac