Conversation
| # EMPIRICKÝ VARIOGRAM gamma(h) = 0.5 * E[(f(x)-f(x+h))^2] | ||
| # ============================================================================= | ||
|
|
||
| def empirical_variogram(x, field, n_bins=30, n_sample=300): |
There was a problem hiding this comment.
Přesuňte do samostatného souboru diagnostic.py.
V tomto modulu by zůstalo pouze generování.
| # BOD 3: GRF 1D | ||
| # ============================================================================= | ||
|
|
||
| x_reg = np.linspace(0, L, N) |
There was a problem hiding this comment.
Zkuste refaktorovat do podoby numerického a grafického testu.
pole generované pomocí NFFT by se porovnalo s polem generovaným FFT
testovala by se L2 norma np.linalg.norm(nfft_grf - interpolate(fft_grf, ..)) +
grafy.
Soubory přejmenujte na test_... a přesuňte do podadresáře 'tests'.
Následně se testy spustí pomocí nástroje 'pytest'
| C(r) = sigma^2 * exp(-|r|^2 / 2*phi^2) | ||
| S(w) = sigma^2 * (sqrt(2pi)*phi)^dim * exp(-|w|^2*phi^2/2) | ||
| """ | ||
| def __init__(self, L, N_freq, phi, sigma=1.0, dim=1): |
There was a problem hiding this comment.
Use @DataClass or @attrs.class to simplify the constructor.
Use type anotations for function parameters and return type.
Document string for functions/metods (here spectral density)
In particular:
- Does self.L mean correlation length?
- Meaning of self.phi?
- Is omega_mag array of points in Fourier space, what shape it has?
There was a problem hiding this comment.
Done in commit 4766aae - both classes use @DataClass, f_points computed in post_init via field(init=False). Type annotations and NumPy-style docstrings added throughout.
| # ============================================================================= | ||
|
|
||
| def make_hermitian_nd(f_hat): | ||
| """nD hermitovská symetrie v centrovaném pořadí (DC uprostřed na indexu N//2).""" |
There was a problem hiding this comment.
Better doc string, shape and format of the input; shape of the output.
There was a problem hiding this comment.
Done in commit 4766aae – docstring now documents input shape (N,)^dim, DC index convention, and output guarantee (real-valued IFFT).
- @DataClass on both correlation classes, f_points via field(init=False) - type annotations on all functions (np.ndarray, int | None, bool) - NumPy-style docstrings with Parameters / Returns / Raises - empirical_variogram: vectorized triu_indices, works for 1D and 2D - removed unused scipy.fft imports
No description provided.