From 2e2d8649bd2c3681fb0300e93faa528587a2352b Mon Sep 17 00:00:00 2001 From: Joyce Yan <5653616+joyceyan@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:42:31 -0800 Subject: [PATCH] reduce duplicate errors --- cellxgene_schema_cli/cellxgene_schema/validate.py | 4 +++- cellxgene_schema_cli/tests/test_schema_compliance.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cellxgene_schema_cli/cellxgene_schema/validate.py b/cellxgene_schema_cli/cellxgene_schema/validate.py index 2795069c..6b62f796 100644 --- a/cellxgene_schema_cli/cellxgene_schema/validate.py +++ b/cellxgene_schema_cli/cellxgene_schema/validate.py @@ -960,7 +960,6 @@ def _validate_dataframe(self, df_name: str): f"Column '{column_name}' in dataframe '{df_name}' contains a category '{category}' with " f"zero observations. These categories will be removed when `--add-labels` flag is present." ) - self._validate_genetic_ancestry() categorical_types = {type(x) for x in column.dtype.categories.values} # Check for columns that have illegal categories, which are not supported by anndata 0.8.0 # TODO: check if this can be removed after upgading to anndata 0.10.0 @@ -2059,6 +2058,9 @@ def _deep_check(self): # Checks spatial self._check_spatial() + # Validate genetic ancestry + self._validate_genetic_ancestry() + # Checks each component for component_name, component_def in self.schema_def["components"].items(): logger.debug(f"Validating component: {component_name}") diff --git a/cellxgene_schema_cli/tests/test_schema_compliance.py b/cellxgene_schema_cli/tests/test_schema_compliance.py index 85baab4b..bf83c97b 100644 --- a/cellxgene_schema_cli/tests/test_schema_compliance.py +++ b/cellxgene_schema_cli/tests/test_schema_compliance.py @@ -1740,7 +1740,7 @@ def test_genetic_ancestry_same_donor_id(self, validator_with_adata): validator.adata.obs["genetic_ancestry_South_Asian"] = [0.0, 0.0] validator.reset(None, 2) validator.validate_adata() - assert len(validator.errors) > 0 + assert len(validator.errors) == 1 # Change the donor id back to two different donor id's. Now, this should pass validation validator.adata.obs["donor_id"] = original_donor_id_column