-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add command-line interface (train/predict/fit/info) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- luminare train: Train NMF model from spectral grid - luminare predict: Generate spectrum from parameters - luminare fit: Fit parameters to observed spectrum - luminare info: Inspect model metadata Also: - Updated pyproject.toml with proper metadata and entry point - Expanded README with usage examples - Added click and optimistix dependencies - Bumped version to 0.1.5
Pull Request Test Coverage Report for Build 21591372365Details
💛 - Coveralls |
New options for controlling the training grid: - --slice/-s: Fix dimension at value or index (e.g., -s Teff=5000 or -s Teff=5) - --bounds/-b: Restrict dimension range (e.g., -b logg=3.0:5.0) - --valid-only: Only use spectra with finite, positive flux - --require-converged: Only use converged spectra (if flag exists) - --flip: Reverse dimension order (e.g., --flip Teff) - --list-dims: Show available dimensions and exit - --spectra-key: Override auto-detection of spectra dataset Also improved: - Auto-detect n_modes if not specified (~half grid points, min 3) - Auto-detect parameter dimensions from HDF5 structure - Save stellar_label_names and ranges in model for downstream use - Better validation of n_modes vs grid dimensions - More informative progress output
- Fix gram_diagonal mask dimension bug: reshape 1D mask to N-D grid - Fix type hint errors: jnp.array is a function, use Optional[jnp.ndarray] - Add missing typing imports (Optional, Tuple) - Add jaxopt and equinox to dependencies All 95 tests now pass.
- Add separate lint job with ruff check and format verification - Enable uv dependency caching for faster builds - Consolidate Python matrix to 3.11 and 3.12 - Switch to Codecov for coverage reporting - Add publish.yml for PyPI publishing on version tags - Update README badge to use Codecov
- Test all help commands - Test info command with model file - Test option parsing (slice, bounds) - Test error handling for missing files Total: 108 tests passing
- Add test_utils.py: Tests for air_to_vacuum and parse_marcs_photosphere_path - Add test_initial.py: Tests for estimate_vsini function - Add test_integration.py: Integration tests for create_stellar_spectrum_model - Expand test_emulator.py: Tests for convolved_flux, StellarSpectrumModel class - Expand test_fourier.py: Edge cases, matdiag, hvag_inverse, gram_diagonal with mask Coverage improved from 33% to 64%: - utils.py: 12% -> 100% - fourier.py: 73% -> 100% - emulator.py: 36% -> 85% - continuum.py: 100% - scalers.py: 100% - nmf.py: 97% Total: 185 tests passing
- Replace bare except with except Exception in cli.py - Add noqa: E402 comments for intentional late imports in tests - Remove unused imports (Tuple, reduce, pytest, random, numpy) - Remove unused local variables in test functions - Apply ruff format to all files
- Add comprehensive CLI tests for train command (slice, bounds, valid-only, require-converged, flip, pixel-subsampling, precision options) - Add tests for nmf_weights_and_coefficients function in initial.py (98% coverage) - Add tests for create_stellar_spectrum_model in emulator.py (96% coverage) - Add tests for continuum model, wavelength interpolation, air/vacuum conversion - Fix GPU detection error in CLI train command (handle missing GPU backend) Test coverage improvements: - cli.py: 36% -> 71% - emulator.py: 85% -> 96% - initial.py: 44% -> 98% - Overall: 64% -> 85%
- Add tests for predict command: basic usage, CSV output, FITS output, models without wavelength or label names, empty/partial params - Add tests for fit command: CSV and FITS spectrum input, various continuum region configurations, models without label names - Add tests for FITS file variants: 2D arrays, missing ivar, HDU index 3, invalid structures - Add edge case tests for both commands Coverage increased from 71% to 90% for cli.py module. Uses mocking to avoid expensive JAX computations in tests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive improvements to luminare including CLI, tests, bug fixes, and documentation.
Changes
🖥️ CLI Commands
luminare trainTrain models from HDF5 spectral grids with extensive control options:
Grid Control:
-s/--slice DIM=VAL: Fix dimension at value/index-b/--bounds DIM=MIN:MAX: Restrict dimension range--valid-only: Only valid (finite, positive) spectra--require-converged: Only converged spectra--flip DIM: Reverse dimension order--list-dims: Inspect grid structureluminare predictGenerate spectra from parameters:
luminare fitFit parameters to observed spectra:
luminare infoInspect trained models with label ranges and metadata.
🧪 Test Suite (95 tests)
🐛 Bug Fixes
jnp.arrayis a function, useOptional[jnp.ndarray]📚 Documentation
🔧 Other
Testing