Skip to content

Tests - #8

Merged
PauTorru merged 3 commits into
mainfrom
tests
Jul 27, 2026
Merged

PauTorru merged 3 commits into
mainfrom
tests

Conversation

@perrymok

@perrymok perrymok commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

I have asked Gemini to create some tests. They look reasonable.

Added Test Modules in tests

  1. test_base.py
    • test_eelsnmf_basic: EELSNMF object initialization, G matrix building, and default NMF decomposition.
    • test_eelsnmf_metadata_init: Auto-extraction of beam parameters ($E_0,\alpha,\beta$) from HyperSpy signal metadata.
    • test_change_dtype: Changing internal array dtypes (e.g. float32).
    • test_temp_arrays: Dynamic array allocation and cleanup (create_temp_array, delete_temp_arrays).
    • test_save_and_load: Pickling/unpickling model objects using save() and load().
  2. test_utils.py
    • Array & Grid utilities: norm(), find_2factors(), find_index(), convolve(), moving_average(), all_arrays_equal(), and match_axis().
    • Physics helpers: $\theta_E$, convergent_factor(), convergent_psi(), integral_over_th(), psi().
  • ListOfSI dataset aggregation: Spatial unfolding/folding and save/load_ListOfSI.
  1. test_modelG.py
    • Delta model G matrix construction with Kohl and Zezhong cross-sections.
    • Background exponent specifications (int, array, None, invalid types).
    • available_models property checks.
  2. test_decompositions.py
    • NMF initialization algorithms (nndsvd, random with random seed).
    • Fixed matrix constraints (W_fixed_bool, W_fixed_values).
    • Custom initial matrices (W_init, H_init).
    • KL-divergence decomposition (default_kl_decomposition).
    • Matrix reconstruction (get_model()) and enforce_dtype().
  3. test_analysis.py
    • Spatial loading shape computation (calculate_loadings()).
    • Component ELNES spectrum extraction (get_edge_from_component()).
    • Chemical quantification (quantify_components(), spatial_standard_q(), get_chemical_maps()).
    • Figures of merit evaluation (evaluate_comp_contributions() for leave-out loss, power, and explained variance).
  4. test_plot.py
    • Non-interactive rendering verification for all plot utilities (plot_factors, plot_loadings, plot_edges, plot_chemical_maps, plot_average_model, plot_energy_ranges).

@perrymok
perrymok requested a review from PauTorru July 23, 2026 09:18
@perrymok perrymok self-assigned this Jul 23, 2026
@perrymok perrymok linked an issue Jul 23, 2026 that may be closed by this pull request
3 tasks done
@PauTorru
PauTorru merged commit 4adf3a6 into main Jul 27, 2026
12 checks passed
@perrymok
perrymok deleted the tests branch August 10, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create tests

2 participants