Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2f86f5a
Add DataFrame input support for non-factorial parametric designs
yannrichet Oct 18, 2025
8162c48
try force unix eol
yannrichet Oct 18, 2025
3b3f830
Fix Windows compatibility in DataFrame input tests
yannrichet Oct 18, 2025
d2837b2
Fix Windows compatibility by matching test_fzo_fzr_coherence pattern
yannrichet Oct 18, 2025
1c1e871
fix path separator for bash on windows
Oct 19, 2025
b2c84bb
avoid issues for EOL chars on windows
Oct 19, 2025
72c096c
keep visible when finished, and add total time
yannrichet Oct 21, 2025
c753b55
.
yannrichet Oct 21, 2025
23b2bd9
parsing melted string in md, html, kv, json, ...
yannrichet Oct 21, 2025
d21508d
spec of design algorithms support
yannrichet Oct 21, 2025
fe5c304
impl algorithm
yannrichet Oct 21, 2025
ff1730e
impl. fzd
yannrichet Oct 21, 2025
647e62a
claude.ai spec
Oct 23, 2025
88702c3
Windows bash availability (#41)
yannrichet Oct 23, 2025
6481aac
mv dev doc
yannrichet Oct 23, 2025
d44b46f
fix path separator for bash on windows
Oct 19, 2025
ca00364
try setup unified shell for win/lin/macos
Oct 24, 2025
5435735
.
Oct 24, 2025
4107b4c
Windows bash availability (#41)
yannrichet Oct 23, 2025
2c01b58
mv dev doc
yannrichet Oct 23, 2025
c388341
Fix DataFrame input support for fzr
yannrichet Oct 24, 2025
f509d61
Remove _raw field from fzd analysis results
yannrichet Oct 24, 2025
5677b46
Add analysis_dir renaming and caching for fzd
yannrichet Oct 24, 2025
0b2ccde
Update FZD docs to reflect _raw field removal
yannrichet Oct 24, 2025
5beed8d
Make fzd cache behavior match fzr pattern
yannrichet Oct 24, 2025
7ca516e
cache policy for fzd
yannrichet Oct 24, 2025
94e2c0c
.
Oct 24, 2025
1ca9456
impl. fzd
yannrichet Oct 21, 2025
325a3bf
Windows bash availability (#41)
yannrichet Oct 23, 2025
0112a8c
.
Oct 24, 2025
ac8f5e5
impl. fzd
yannrichet Oct 21, 2025
4fb3fdf
Windows bash availability (#41)
yannrichet Oct 23, 2025
e0c081b
.
Oct 24, 2025
97400e2
impl. fzd
yannrichet Oct 21, 2025
d3226f5
Windows bash availability (#41)
yannrichet Oct 23, 2025
8e9e691
Windows bash availability (#41)
yannrichet Oct 23, 2025
93b465e
Clean up unused imports and code
yannrichet Oct 24, 2025
d4c6cd9
cleanup
yannrichet Oct 25, 2025
5f6225d
refactor display -> analysis
yannrichet Oct 25, 2025
7c7a60f
rm _raw from fzd output
yannrichet Oct 25, 2025
8075708
up doc
yannrichet Oct 25, 2025
97dca70
impl. R algorithms
yannrichet Oct 25, 2025
1787489
impl algorithm plugin
yannrichet Oct 25, 2025
4fa347b
fix algo loading on win
Oct 25, 2025
c67055a
more consistent args
yannrichet Oct 30, 2025
ba2cb57
use install_model, install_algorithm instead of unclear names like in…
yannrichet Oct 30, 2025
1339b34
auto flatten output dicts if any
yannrichet Oct 30, 2025
4a4c9c0
some refactoring
yannrichet Oct 31, 2025
f131a5e
fix api
yannrichet Oct 31, 2025
bd6008e
working notebook with modelica, fzr, fzd, ...
yannrichet Oct 31, 2025
64e8172
format md
yannrichet Oct 31, 2025
dbb2d67
fix input_path/input_file
yannrichet Nov 3, 2025
c0baaac
enhance args interpretation: raw json, thant json file, then json fil…
Nov 21, 2025
4010a43
Fix rebase issues and add algorithm validation
yannrichet Nov 22, 2025
28d619f
Fix missing imports after rebase
yannrichet Nov 22, 2025
160110c
Make pandas a required dependency
yannrichet Nov 22, 2025
cc6e36d
Remove PANDAS_AVAILABLE and HAS_PANDAS checks from tests
yannrichet Nov 22, 2025
eb855a5
Fix pandas import issues after making it required
yannrichet Nov 22, 2025
e3ed67d
Add comprehensive LLM context documentation (#45)
yannrichet Nov 22, 2025
82b575a
Fix Windows file deletion issue in test_dict_flattening.py (#46)
yannrichet Nov 23, 2025
59f8a76
Merge main into implement-algorithms
yannrichet Nov 26, 2025
877028c
.
yannrichet Nov 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.claude
claude
*fz.egg-info
*.egg-info
venv
build
.vscode
Expand All @@ -21,4 +21,4 @@ build
*.sh
.coverage
results*/
output/
output/
90 changes: 83 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- Reading and parsing output results
- Smart caching and retry mechanisms

The four core functions are:
The five core functions are:
1. **`fzi`** - Parse input files to identify variables
2. **`fzc`** - Compile input files by substituting variables
3. **`fzo`** - Parse output files from calculations
4. **`fzr`** - Run complete parametric calculations end-to-end
5. **`fzd`** - Run iterative design of experiments with adaptive algorithms

## Development Setup

Expand Down Expand Up @@ -63,13 +64,14 @@ python -m pytest tests/test_cli_commands.py::test_fzi_parse_variables -v

## Architecture

The codebase is organized into functional modules (~5700 lines total):
The codebase is organized into functional modules (~7300 lines total):

### Core Modules

- **`fz/core.py`** (913 lines) - Public API functions (`fzi`, `fzc`, `fzo`, `fzr`)
- **`fz/core.py`** (1277 lines) - Public API functions (`fzi`, `fzc`, `fzo`, `fzr`, `fzd`)
- Entry points for all parametric computing operations
- Orchestrates input compilation, calculation execution, and result parsing
- Implements iterative design of experiments (`fzd`) with algorithm integration
- Handles signal interruption and graceful shutdown

- **`fz/interpreter.py`** (387 lines) - Variable parsing and formula evaluation
Expand Down Expand Up @@ -108,15 +110,34 @@ The codebase is organized into functional modules (~5700 lines total):
- Structured logging with levels (DEBUG, INFO, WARNING, ERROR)
- UTF-8 encoding handling for Windows

- **`fz/cli.py`** (395 lines) - Command-line interface
- Entry points: `fz`, `fzi`, `fzc`, `fzo`, `fzr`
- **`fz/cli.py`** (509 lines) - Command-line interface
- Entry points: `fz`, `fzi`, `fzc`, `fzo`, `fzr`, `fzd`
- Argument parsing for all commands
- Output formatting (JSON, table, CSV, markdown, HTML)

- **`fz/algorithms.py`** (513 lines) - Algorithm framework for design of experiments
- Base interface for iterative algorithms used by `fzd`
- Algorithm loading from Python files with dynamic import
- Support for initial design, adaptive sampling, and result analysis
- Automatic dependency checking (e.g., numpy, scipy)
- Content detection for analysis results (HTML, JSON, Markdown, key-value)

- **`fz/shell.py`** (505 lines) - Shell utilities and binary path resolution
- Cross-platform shell command execution with Windows bash detection
- Binary path resolution with `FZ_SHELL_PATH` support
- Caching of binary locations for performance
- Windows .exe extension handling
- Short path conversion for Windows paths with spaces

### Supporting Modules

- **`fz/spinner.py`** (225 lines) - Progress indication for long-running operations
- **`fz/installer.py`** (354 lines) - Model installation from GitHub/URL/zip
- **`fz/installer.py`** (598 lines) - Model and algorithm installation from GitHub/URL/zip
- Install models: `fz install model <source>` or `fz.install_model(model)`
- Install algorithms: `fz install algorithm <source>` or `fz.install_algorithm(algorithm)`
- Supports GitHub repositories (`fz-<name>` convention), full URLs, and local zip files
- Project-level (`.fz/models/`, `.fz/algorithms/`) and global (`~/.fz/models/`, `~/.fz/algorithms/`) installation
- Priority system: project-level overrides global

## Key Design Patterns

Expand Down Expand Up @@ -159,6 +180,18 @@ The codebase is organized into functional modules (~5700 lines total):
- Prevents redundant computation when resuming interrupted runs
- Glob patterns supported: `cache://archive/*/results`

### 6. Algorithm-Based Design of Experiments (fzd)
- **Iterative adaptive sampling**: Algorithms decide what points to evaluate next based on previous results
- **Algorithm interface**: Each algorithm class implements:
- `get_initial_design()`: Returns initial design points
- `get_next_design()`: Returns next points to evaluate (empty list when done)
- `get_analysis()`: Returns final analysis results
- `get_analysis_tmp()`: [Optional] Returns intermediate progress at each iteration
- **Flexible analysis output**: Algorithms can return text, HTML, JSON, Markdown, or key-value pairs
- **Content detection**: Automatically processes analysis results based on content type
- **Examples**: Monte Carlo sampling, BFGS optimization, Brent's method, random sampling
- **Requires pandas**: fzd returns results as pandas DataFrames

## Windows-Specific Considerations

### Bash Availability
Expand All @@ -178,7 +211,7 @@ The codebase is organized into functional modules (~5700 lines total):
- All tests in `tests/` directory following pytest conventions
- Test files prefixed with `test_` (e.g., `test_cli_commands.py`)
- Use pytest fixtures in `conftest.py` for common setup
- Examples: `test_parallel.py`, `test_interrupt_handling.py`, `test_examples_*.py`
- Examples: `test_parallel.py`, `test_interrupt_handling.py`, `test_fzd.py`, `test_examples_*.py`

### Test Patterns
1. Create temporary directory with `tempfile.TemporaryDirectory()`
Expand Down Expand Up @@ -221,6 +254,16 @@ Each case creates a directory with:
- `err.txt` - Standard error
- `.fz_hash` - Input file MD5 hashes (for cache matching)

### Example Algorithms
- Location: `examples/algorithms/` directory
- Available algorithms:
- **`montecarlo_uniform.py`** - Uniform random sampling for Monte Carlo integration
- **`randomsampling.py`** - Simple random sampling with configurable iterations
- **`bfgs.py`** - BFGS optimization algorithm (requires scipy)
- **`brent.py`** - Brent's method for 1D optimization (requires scipy)
- Each algorithm demonstrates the standard interface and can serve as a template
- Algorithms can be referenced by file path: `algorithm="examples/algorithms/montecarlo_uniform.py"`

## Environment Variables

```bash
Expand Down Expand Up @@ -329,8 +372,41 @@ All public functions and methods must have docstrings with:
- Host key validation with interactive fingerprint checking
- Timeout and keepalive configurable via environment

### Algorithm Loading and Execution (fzd)
- **Dynamic import**: Algorithms loaded from Python files using `importlib.machinery`
- **Dependency checking**: `__require__` list checked at load time; warns if missing
- **Fixed vs variable inputs**: Separates fixed values from ranges for optimization
- Fixed: `{"x": "5.0"}` → always x=5.0
- Variable: `{"y": "[0;10]"}` → y varies between 0 and 10
- Algorithm only controls variable inputs; fixed values merged automatically
- **Analysis content processing**: Detects and processes multiple content types:
- HTML: Saved to `analysis.html` and `iteration_N.html`
- JSON: Parsed and made available as structured data
- Markdown: Saved to `analysis.md` files
- Key-value pairs: Parsed into dictionaries
- **Progress tracking**: Progress bar shows iteration count, evaluations, and ETA
- **Result structure**: Returns dict with:
- `XY`: pandas DataFrame with all input and output values
- `analysis`: Processed analysis results (HTML, plots, metrics, etc.) - excludes internal `_raw` data
- `algorithm`: Algorithm path
- `iterations`: Number of iterations completed
- `total_evaluations`: Total number of function evaluations
- `summary`: Human-readable summary text

## Common Development Tasks

### Adding a New Algorithm for fzd
1. Create a new Python file in `examples/algorithms/` or any directory
2. Implement a class with required methods:
- `__init__(self, **options)` - Accept algorithm-specific options
- `get_initial_design(self, input_vars, output_vars)` - Return initial design points
- `get_next_design(self, previous_input_vars, previous_output_values)` - Return next points (or empty list when done)
- `get_analysis(self, input_vars, output_values)` - Return final analysis results
- `get_analysis_tmp(self, input_vars, output_values)` [Optional] - Return intermediate results
3. Add optional `__require__` list for dependencies (e.g., `["numpy", "scipy"]`)
4. Test with `fzd()` function
5. See `examples/algorithms/` for reference implementations

### Adding a New Calculator Type
1. Add runner function to `runners.py` following `_run_*_calculator()` pattern
2. Register in calculator resolution logic
Expand Down
Loading
Loading