← Về thư mục
tests/matchms/test_scripts.py
- metric_choices · function · L98-L108 — def metric_choices() -> list[str]
- score_record · function · L111-L114 — def score_record(score: float, matches: int)
- FakeSpectrum · class · L117-L124 — class FakeSpectrum
- init · method · L120-L121 — def init(self, **metadata) -> None
- get · method · L123-L124 — def get(self, key)
- FakeScores · class · L127-L140 — class FakeScores
- init · method · L132-L135 — def init(self, ranked) -> None
- scores_by_query · method · L137-L140 — def scores_by_query(self, query, name, sort)
- search_namespace · function · L143-L172 — def search_namespace(**overrides) -> argparse.Namespace
- MetricTableTests · class · L175-L254 — class MetricTableTests(unittest.TestCase)
- test_every_advertised_metric_builds_a_similarity_object · method · L178-L184 — def test_every_advertised_metric_builds_a_similarity_object(self) -> None: # A choice the parser accepts but create_metric cannot build would only # fail after both spectrum files have been loaded and processed.
- test_each_metric_name_selects_the_documented_matchms_class · method · L186-L206 — def test_each_metric_name_selects_the_documented_matchms_class(self) -> None
- test_the_three_flash_metrics_differ_in_score_type_and_matching_mode · method · L208-L227 — def test_the_three_flash_metrics_differ_in_score_type_and_matching_mode(self) -> None: # All three build a FlashSimilarity; the distinction is entirely in the # constructor arguments, so a copy-paste slip would silently give the # user the wrong similarity.
- test_an_unknown_metric_is_refused · method · L229-L231 — def test_an_unknown_metric_is_refused(self) -> None
- test_blink_receives_the_intensity_and_score_cutoffs · method · L233-L243 — def test_blink_receives_the_intensity_and_score_cutoffs(self) -> None
- test_the_metric_sets_only_name_metrics_the_parser_offers · method · L245-L254 — def test_the_metric_sets_only_name_metrics_the_parser_offers(self) -> None
- SuffixPolicyTests · class · L257-L272 — class SuffixPolicyTests(unittest.TestCase)
- test_pickle_suffixes_are_never_also_supported · method · L258-L264 — def test_pickle_suffixes_are_never_also_supported(self) -> None: # Refusing pickles is a security decision; the two sets overlapping # would quietly re-enable arbitrary code execution on load.
- test_every_suffix_is_lowercase_and_dotted · method · L266-L272 — def test_every_suffix_is_lowercase_and_dotted(self) -> None: # validate_args lowercases the suffix before the lookup, so an entry # spelled ".MGF" here would never match.
- ValidationTests · class · L275-L388 — class ValidationTests(unittest.TestCase)
- setUp · method · L278-L286 — def setUp(self) -> None
- args · method · L288-L293 — def args(self, **overrides) -> argparse.Namespace
- test_a_valid_invocation_passes_silently · method · L295-L298 — def test_a_valid_invocation_passes_silently(self) -> None: # Without this the rest of the class only proves the validator can say # no -- not that it ever says yes.
- test_every_supported_suffix_is_accepted_in_both_positions · method · L300-L305 — def test_every_supported_suffix_is_accepted_in_both_positions(self) -> None
- test_uppercase_suffixes_are_accepted · method · L307-L310 — def test_uppercase_suffixes_are_accepted(self) -> None
- test_a_missing_input_is_reported_by_role · method · L312-L318 — def test_a_missing_input_is_reported_by_role(self) -> None
- test_pickle_input_is_refused_with_the_reason · method · L320-L326 — def test_pickle_input_is_refused_with_the_reason(self) -> None
- test_an_unsupported_suffix_lists_the_formats · method · L328-L332 — def test_an_unsupported_suffix_lists_the_formats(self) -> None
- test_an_existing_output_needs_force · method · L334-L339 — def test_an_existing_output_needs_force(self) -> None
- test_a_missing_output_directory_is_refused · method · L341-L343 — def test_a_missing_output_directory_is_refused(self) -> None
- test_numeric_bounds_are_enforced_at_the_boundary · method · L345-L364 — def test_numeric_bounds_are_enforced_at_the_boundary(self) -> None
- test_the_inclusive_ends_of_each_range_are_accepted · method · L366-L372 — def test_the_inclusive_ends_of_each_range_are_accepted(self) -> None: # 0 disables the peak filters and 0/1 are legal similarity scores, so # rejecting them would make documented invocations unusable.
- test_an_inverted_mz_window_is_refused_but_one_sided_is_fine · method · L374-L380 — def test_an_inverted_mz_window_is_refused_but_one_sided_is_fine(self) -> None
- test_min_matches_is_refused_for_metrics_that_report_no_matches · method · L382-L388 — def test_min_matches_is_refused_for_metrics_that_report_no_matches(self) -> None: # Silently ignoring --min-matches would look like a filter that ran.
- ProcessingChainTests · class · L391-L473 — class ProcessingChainTests(unittest.TestCase)
- step_names · method · L395-L397 — def step_names(args: argparse.Namespace) -> list[str]
- test_metadata_filters_run_before_the_peak_filters · method · L399-L411 — def test_metadata_filters_run_before_the_peak_filters(self) -> None: # SpectrumProcessor keeps registered filters in their canonical order # but appends unknown callables; the script expands default_filters by # hand precisely so precursor m/z is derived before it is required.
- test_precursor_metrics_require_a_precursor_and_others_do_not · method · L413-L423 — def test_precursor_metrics_require_a_precursor_and_others_do_not(self) -> None: # A modified-cosine score is meaningless without precursor m/z, so the # requirement must switch on with the metric.
- test_a_precursor_window_forces_the_precursor_requirement · method · L425-L430 — def test_a_precursor_window_forces_the_precursor_requirement(self) -> None
- test_the_optional_filters_are_absent_by_default · method · L432-L440 — def test_the_optional_filters_are_absent_by_default(self) -> None
- test_each_switch_adds_exactly_its_own_filter · method · L442-L450 — def test_each_switch_adds_exactly_its_own_filter(self) -> None
- test_the_disabling_flags_actually_remove_steps · method · L452-L460 — def test_the_disabling_flags_actually_remove_steps(self) -> None
- test_zero_thresholds_disable_their_filters · method · L462-L467 — def test_zero_thresholds_disable_their_filters(self) -> None: #
--relative-intensity 0 and --min-peaks 0 are documented as "off", # not as "keep everything above zero".
- test_the_same_chain_is_used_for_queries_and_references · method · L469-L473 — def test_the_same_chain_is_used_for_queries_and_references(self) -> None: # Comparing differently processed collections biases every score, so # the processor is built once from one namespace.
- ScoreRecordTests · class · L476-L505 — class ScoreRecordTests(unittest.TestCase)
- test_the_score_field_is_the_one_ending_in_score · method · L479-L485 — def test_the_score_field_is_the_one_ending_in_score(self) -> None
- test_a_metric_without_a_score_suffix_falls_back_to_the_first_field · method · L487-L491 — def test_a_metric_without_a_score_suffix_falls_back_to_the_first_field(self) -> None
- test_a_structured_record_is_read_field_by_field · method · L493-L496 — def test_a_structured_record_is_read_field_by_field(self) -> None
- test_a_scalar_score_is_read_directly_and_reports_no_matches · method · L498-L502 — def test_a_scalar_score_is_read_directly_and_reports_no_matches(self) -> None
- test_a_field_the_record_does_not_carry_is_not_invented · method · L504-L505 — def test_a_field_the_record_does_not_carry_is_not_invented(self) -> None
- SpectrumIdentityTests · class · L508-L554 — class SpectrumIdentityTests(unittest.TestCase)
- test_the_preferred_field_wins_over_every_default · method · L509-L516 — def test_the_preferred_field_wins_over_every_default(self) -> None
- test_the_default_order_prefers_spectrum_id_over_a_name · method · L518-L523 — def test_the_default_order_prefers_spectrum_id_over_a_name(self) -> None
- test_an_empty_value_is_skipped_rather_than_used · method · L525-L531 — def test_an_empty_value_is_skipped_rather_than_used(self) -> None: # An MGF with
TITLE= yields "", which would produce a blank id column.
- test_an_unidentified_spectrum_falls_back_to_prefix_and_index · method · L533-L539 — def test_an_unidentified_spectrum_falls_back_to_prefix_and_index(self) -> None
- test_a_numeric_identifier_is_stringified · method · L541-L547 — def test_a_numeric_identifier_is_stringified(self) -> None
- test_missing_metadata_becomes_an_empty_cell_not_the_word_none · method · L549-L554 — def test_missing_metadata_becomes_an_empty_cell_not_the_word_none(self) -> None
- HitWritingTests · class · L557-L664 — class HitWritingTests(unittest.TestCase)
- setUp · method · L560-L569 — def setUp(self) -> None
- write · method · L571-L581 — def write(self, ranked, **overrides) -> list[dict[str, str]]
- ranked · method · L583-L587 — def ranked(self, *scores)
- test_hits_are_numbered_from_one_and_carry_reference_metadata · method · L589-L601 — def test_hits_are_numbered_from_one_and_carry_reference_metadata(self) -> None
- test_top_k_truncates_after_the_filters_not_before · method · L603-L610 — def test_top_k_truncates_after_the_filters_not_before(self) -> None: # 0.4 is dropped by --min-score, so the third-ranked survivor must # still be reported when --top-k is 2.
- test_a_score_exactly_at_the_threshold_is_kept · method · L612-L616 — def test_a_score_exactly_at_the_threshold_is_kept(self) -> None
- test_the_match_count_threshold_is_inclusive · method · L618-L620 — def test_the_match_count_threshold_is_inclusive(self) -> None
- test_a_scalar_score_survives_a_match_threshold · method · L622-L629 — def test_a_scalar_score_survives_a_match_threshold(self) -> None: # Metrics with no match count must not be filtered to nothing by a # threshold they cannot answer; validate_args already refuses that # combination, so write_hits must not silently drop the rows either.
- test_a_non_finite_score_is_dropped · method · L631-L636 — def test_a_non_finite_score_is_dropped(self) -> None: # A NaN comparison is neither above nor below the threshold, so it has # to be excluded explicitly or it would rank first after sorting.
- test_an_empty_ranking_still_writes_a_header · method · L638-L641 — def test_an_empty_ranking_still_writes_a_header(self) -> None
- test_a_reference_outside_the_library_is_an_error_not_a_blank_row · method · L643-L646 — def test_a_reference_outside_the_library_is_an_error_not_a_blank_row(self) -> None
- test_the_writer_asks_for_a_sorted_ranking_by_the_score_field · method · L648-L660 — def test_the_writer_asks_for_a_sorted_ranking_by_the_score_field(self) -> None
- test_scores_are_written_with_enough_precision_to_be_reproducible · method · L662-L664 — def test_scores_are_written_with_enough_precision_to_be_reproducible(self) -> None
- EndToEndSearchTests · class · L667-L745 — class EndToEndSearchTests(unittest.TestCase)
- setUp · method · L670-L678 — def setUp(self) -> None
- args · method · L680-L688 — def args(self, **overrides) -> argparse.Namespace
- rows · method · L690-L692 — def rows(self) -> list[dict[str, str]]
- test_an_identical_reference_is_reported_with_a_perfect_score · method · L694-L708 — def test_an_identical_reference_is_reported_with_a_perfect_score(self) -> None
- test_top_k_limits_the_reported_hits · method · L710-L714 — def test_top_k_limits_the_reported_hits(self) -> None
- test_a_match_threshold_above_the_peak_count_reports_nothing · method · L716-L720 — def test_a_match_threshold_above_the_peak_count_reports_nothing(self) -> None: # Six matched peaks are impossible for a five-peak spectrum, so this # proves the filter is applied rather than merely accepted.
- test_the_pair_budget_stops_the_search_before_it_starts · method · L722-L726 — def test_the_pair_budget_stops_the_search_before_it_starts(self) -> None
- test_a_library_that_processing_empties_is_reported · method · L728-L731 — def test_a_library_that_processing_empties_is_reported(self) -> None: # Requiring more peaks than any spectrum has leaves nothing to search.
- test_main_turns_a_validation_error_into_exit_code_two · method · L733-L745 — def test_main_turns_a_validation_error_into_exit_code_two(self) -> None
- VersionPinTests · class · L748-L759 — class VersionPinTests(unittest.TestCase)
- test_the_installed_version_is_reported_rather_than_assumed · method · L749-L754 — def test_the_installed_version_is_reported_rather_than_assumed(self) -> None: #
run compares this against TARGET_VERSION to warn about drift, so it # must be a real version string and not the "unknown" fallback.
- test_the_documented_target_matches_the_skill_metadata · method · L756-L759 — def test_the_documented_target_matches_the_skill_metadata(self) -> None: # SKILL.md tells the agent which release the script was verified on.