Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceyan committed Sep 22, 2023
1 parent ee167df commit 72fadff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cellxgene_schema_cli/cellxgene_schema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,12 @@ def _validate_colors_in_uns_dict(self, uns_dict: dict) -> None:
continue

if column_def.get("type") == "categorical":
column = getattr(df, column_name)
getattr(df, column_name)
category_mapping[column_name] = df[column_name].nunique()
print(f"category mapping: {category_mapping}")

for column_name, num_unique_vals in category_mapping.items():
colors_options = uns_dict.get(f"{column_name}_colors", [])
color_column = f"{column}_colors"
print(f"column name: {column_name} # unique: {num_unique_vals} colors options: {colors_options}")
if len(colors_options) != num_unique_vals:
self.errors.append(
Expand Down
5 changes: 2 additions & 3 deletions cellxgene_schema_cli/tests/test_schema_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import fixtures.examples_validate as examples
import numpy
import pytest
import pandas as pd
from cellxgene_schema.utils import getattr_anndata
from cellxgene_schema.validate import Validator
Expand Down Expand Up @@ -1370,7 +1369,7 @@ def test_not_enough_color_options(self):
"ERROR: Annotated categorical field suspension_type must have 2 color options in uns[suspension_type_colors]. Found: ['green']"
],
)

def test_too_many_color_options(self):
self.validator.adata.uns["suspension_type_colors"] = ["green", "blue", "purple"]
self.validator.validate_adata()
Expand All @@ -1380,7 +1379,7 @@ def test_too_many_color_options(self):
"ERROR: Annotated categorical field suspension_type must have 2 color options in uns[suspension_type_colors]. Found: ['green', 'blue', 'purple]"
],
)

def invalid_color_options(self):
self.validator.adata.uns["suspension_type_colors"] = ["#000", "pynk"]
self.validator.validate_adata()
Expand Down

0 comments on commit 72fadff

Please sign in to comment.