Lattice kronecker - #556
AndersPride wants to merge 80 commits into
Conversation
…into kronecker_search
…e rule search method
…Software into lattice_kronecker
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
I have the following six comments and would appreciate your follow-up.
- Help us debug the following case in which computed wssd is negative. Add a fast unit test case after fixing the issue.
k = lambda x: 3 * (x * (x - 1) + 1 / 6)
_, wssd, _, _ = kronecker_vector_search_mobius_transform(8, 3, 3, kernel=k, coord_weights=np.ones(3)) # -1.57909
- The doctest in lines 35 to 36 of
qmcpy/discrete_distribution/lattice/lattice_vector_wssd_search.pyfailed in my Mac machine, even though it passes in GitHub Actions. The documentation mentions that the results are sensitive to platforms. Could we create doctest that check invariant properties or change the algorithm to a deterministic one?
>>> bernoulli6 = lambda x: x * (x * (-1/2 + x * (x * (5/2 + x * (-3 + x))))) + 1/42
>>> lattice_vector_wssd_search(n_max=2**15, d_max=10, coord_weights=None,
... kernel=bernoulli6)
array([ 1, 15963, 13939, 483, 14713, 6423, 12021, 521, 2283,
1177])
- How to understand the following error?
>>> Lattice(2, randomize=False).wssd(8, sample_weights=np.ones(9))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Lattice(2, randomize=False).wssd(8, sample_weights=np.ones(9))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/terrya/Documents/ProgramData/QMCSoftware_local/qmcpy/discrete_distribution/lattice/lattice.py", line 479, in wssd
wssd = np.dot(sample_weights, discs)
ValueError: shapes (9,) and (8,) not aligned: 9 (dim 0) != 8 (dim 0)
- The folloiwng example also failed with an exception. Please debug.
>>> kvs, lvs = kronecker_vector_search_mobius_transform, lattice_vector_wssd_search
>>> lvs(3,3)
/Users/terrya/Documents/ProgramData/QMCSoftware_local/qmcpy/discrete_distribution/lattice/lattice_vector_wssd_search.py:175: RuntimeWarning: invalid value encountered in subtract
best_indices = np.where(np.abs(wssd - min_wssd) <= rtol * np.abs(min_wssd))[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
lvs(3,3)
~~~^^^^^
File "/Users/terrya/Documents/ProgramData/QMCSoftware_local/qmcpy/discrete_distribution/lattice/lattice_vector_wssd_search.py", line 176, in lattice_vector_wssd_search
bestIdx = int(best_indices[0])
-
Please replace the user interactive prompt lines 58 to 63 in
qmcpy/discrete_distribution/kronecker/kronecker_search_methods.pywithhas_sympy = False. The current implementation fails in non-interactive environments (CI/pytest) because the use of input() when sympy is missing causes an EOFError or hangs. -
Add an empty line before
Args:,Returns:,Note:, etc. in the docstrings in your Python files.
- Kronecker search wssd now works for other kernels, added unit test case - Lattice search doctest now checks invariant properties - Lattice.wssd can now handle coord_weights longer than the dimension - Lattice search minimum n_max value corrected - Removed user interactive prompt in Kronecker search - Fixed docstring formatting - Updated demo notebook with more interesting Kronecker comparison
|
@sou-cheng-choi On point 1, there was a single line of code that had not been updated to use a general kernel. On point 2, I'm still working on improving the stability of the algorithm. For now I've used your suggestion to check easier invariants in the doctest. On point 3, I have now ensured that the dimensions agree for the dot product On point 4, that example will still fail, but it throws the proper error as the minimum allowed value of n_max has been corrected. |
|
Thank you for the quick turn around. We should be close to finishing. I have merged a PR into this branch where I resolved merged conflicts, test failures and address some of the issues more fully. Please review. |
* Min Python version >= 3.9 for users & >= 3.10 for developers (#606) * Min Python version * Pass Python version to environment * Pre-release tests * Get more info * Security Fix * requires-python = ">= 3.9" in pyproject.toml * Python 3.9 Compatibility * Fix versions * Fix windows test failures * Installs the missing l3backend MiKTeX package * Update demo notebook dependencies and initialization cells (#531) * Update demo notebook initialization cells * Notebooks have been moved * Add Colab dependency install cells * Fix Colab notebook install cells * Fix spelling in Colab notebooks * Remove unused os import from Colab cells * Use capture for Colab install output * Automating Colab/notebook consistency * Update * Update makefile * Add make target for Colab bootstrap classification * Debugged `harden_colab_notebook.py` and add unit tests for badge handling * Add branch notebook execution script * Skip Colab bootstrap during branch notebook execution * Download Dakota Genz points in notebook * Remove Dakota Genz generation fallback * Use gdown for Dakota Genz data download * Add local notebook execution script * Comment out gdown in Dakota notebook * Fix Windows notebook CI LaTeX setup * Address Colab readiness review feedback * Reconcile Colab tooling with develop * Refresh safe Colab bootstrap cells * Preserve notebook serialization during hardening * Better Colab notebook handling: more dependencies support and improved smoke tests * Fix CodeQL check errors * Add title to notebook and update kernel name and version * Fix errors after manually testing in Google Colab * Fix problems after manually running in Google Colab * Minor enhancements * Fix colab error * Fix typo * Simplify Colab smoke tests: drop dead PR scoping, fix diagnostics * Add harden_colab_notebook to format target * Add tools to open in Colab (for developers) * Attempt to fix Colab errors * Correct Colab notebook manifest and build process * Fix unit test failure --------- Co-authored-by: sou-cheng-choi <[email protected]> * Remove unreferenced file * Add notebook to documentation * Remove trailing spaces * Make LVS deterministic * Optimized k_const computations. Reduce memory usage. Add custom kernel input to wssd method. * Resolved UnboundLocalError when calculating WSSD for d_max = 1. Improved warning for missing sympy. Better format. * Add unit tests * Change ParameterWarngin to UserWarning * Fix GitHub Action failures * Another attempt to fix * make harden_colab_notebook * Fix windows test failure --------- Co-authored-by: Joshua Herman <[email protected]>
| try: | ||
| return _tg_radius_graph(x, r=r, batch=batch, loop=loop) | ||
| except (ImportError, AttributeError, RuntimeError, OSError): | ||
| _tg_radius_graph_ok = False # backend missing/broken -- use native from now on |
|
@AndersPride, could you please update this branch with your latest work and the current |
This reverts commit 17702a3.
Resolve notebook, Colab, CI, build, and Kronecker conflicts while preserving generator-search behavior. Align branch tests and API annotations with develop's validation rules. Validation: 699 unit tests and 275 subtests; focused numerical doctests; Lattice/Kronecker and GBM notebooks; strict Colab and test-style checks; documentation baseline gate; focused MkDocs build.
|
Independently re-verified this fixes #612: checked out All 4 tests pinning the NaN / shift-dependence bug now report unexpected success:
No other regressions observed against this branch alone (the separate shape issue in #629 was specific to the state at the time and is being handled in PR #633). Good to merge from my side. |
Adds search methods for generators for lattice and kronecker sequences. Also adds and updates methods for finding discrepancies and weighted sum of squared discrepancies for arbitrary sample size, dimension, and coordinate weights. Currently the search methods live in their respective folders in discrete_distribution, but they may belong elsewhere. There is a new demo illustrating these features. Right now, this is not integrated into the kernel class, but that can be future work.