EXAMPLES / COMPLETE WORKFLOWS
From measurements to a question you can test
Inspect every input, follow each step and change the question in runnable code.
01 / SPECTRAL ANALYSIS
Find a feature, then inspect its source.
Generate four Lorentzian spectra on 257 energy samples each. Calculate the peak-to-peak contrast at each site, then inspect site 2 on a denser 513-sample curve. These are synthetic model data, not measurements.
| Contract | Both complete programs |
|---|---|
| Axes | 4 sites × 257 analysis samples; 513 plotted samples for site 2 |
| Coordinates | Energy from −1 to 1 inclusive, with both grids including zero |
| Data | Generated Lorentzian: baseline 1, amplitude 1+p, center 0, width 0.1 |
| Operation | Maximum minus minimum along the energy dimension; retain site p |
| Console | Four contrast values, then selected intensity at energy zero |
| Rendering | Generated coordinate curves; VKF rendered vertices use float32 |
| File I/O and timing | In memory; no speed, memory or file-access advantage claimed |
Python / complete program
import numpy as np
import matplotlib.pyplot as plt
site = np.arange(4, dtype=np.float64)
energy = np.linspace(-1., 1., 257)
profile = 1 / (1 + 100 * energy ** 2)
spectra = 1 + (1 + site[:, None]) * profile[None, :]
contrast = np.ptp(spectra, axis=1)
curve_energy = np.linspace(-1., 1., 513)
selected_site = 2
selected = 1 + (1 + selected_site) / (1 + 100 * curve_energy ** 2)
print(contrast)
print(selected[256])
fig, ax = plt.subplots()
ax.plot(curve_energy, selected, color=(.25, .72, 1., 1.))
ax.set(xlim=(-1, 1), ylim=(0, 5),
xlabel="Energy coordinate", ylabel="Generated intensity")
plt.show()VKF / complete editable program below
The runnable editor below contains all imports, generated data, analysis and plot calls.
NumPy's ptp already states the reduction concisely. VKF makes the selected dimension part of calling an ordinary span function. These are two readable ways to express the same numerical task; the plots are not claimed to be pixel-identical.
Run to inspect the selected generated Lorentzian spectrum with 513 plotted samples.
Change selected_site from 2 to 1 to inspect another generated spectrum. Both analysis grids include the peak and endpoints, so the sampled peak-to-peak contrasts are exact for this model.
02 / PARAMETER BINDING
Carry a decision into the next calculation.
When a model parameter is fixed, keep the resulting function as a value. Python provides this through functools.partial; VKF places parameter binding in the language syntax. Both examples below produce 8.
Python / complete program
from functools import partial
def power(x, n):
return x ** n
cube = partial(power, n=3)
print(cube(2))VKF / complete program
power(x,n):x^n
cube:power[n:3]
::cube(2)03 / LARGE-DATA BOUNDARY
Request a region without inventing an API.
For a dataset already stored in HDF5, idiomatic h5py can select a scalar or a region directly. It does not require reading the complete dataset. Physical reads still depend on chunking, compression and caches.
The scalar selection reads intensity 8; the selected 2 × 2 input region is [[2,3],[3,8]]. NumPy applies sine after each selection. Inspect one and region in Python to see the transformed values. File setup stays separate from the selected-read task.
VKF's goal is a language-level path from selected demand to a bounded working set. This site supplies no runnable VKF HDF5 equivalent and makes no out-of-core performance claim. The working spectral example above is in memory.
import h5py
import numpy as np
site = np.arange(4, dtype=np.float64)
energy = np.linspace(-1., 1., 257)
profile = 1 / (1 + 100 * energy ** 2)
spectra = 1 + (1 + site[:, None]) * profile[None, :]
with h5py.File("spectra.h5", "w") as file:
file.create_dataset("intensity", data=spectra)
with h5py.File("spectra.h5", "r") as file:
dataset = file["intensity"]
one = np.sin(dataset[2, 128])
region = np.sin(dataset[1:3, 100:157])
print(one)
print(region.shape)04 / A CONSTRAINED MODEL
Solve the path. Inspect its rate of change.
Choose a cubic path that begins at 0, ends at 1 and has selected endpoint slopes. Solve its four coefficients as a linear system, derive its slope, then inspect both time curves and a phase view.
The default endpoint slope is zero. At the midpoint the program prints position 0.5 and slope 1.5. Change exit_slope to explore how the solution changes.
The parameter t spans 0 to 1 in 257 samples. These are static position, derivative and phase plots; t is the model coordinate, not a live playback clock.
Your model, two views
From constraints to a curve
p(0) = 0p(1) = 1p′(0) = 0p′(1) = exit_slope
Run to see the compiler’s output here.
Blue · position over time
Orange · velocity over time
Green · position against velocity
Change the endpoint slope in the source, then run again to compare the motion.
This is a sampled model with two retained views. It is not a benchmark or a qualification of large animated scenes. Inspect the linear-algebra source →