Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark committed Oct 4, 2024
1 parent 1a3edd3 commit 9a43e63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
5 changes: 4 additions & 1 deletion vitessce/file_def_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def gen_obs_sets_schema(options: dict, paths: Optional[list[str]] = None, names:
})
return options


def gen_sdata_obs_sets_schema(options: dict, paths: Optional[list[str]] = None, names: Optional[list[str]] = None, table_path: Optional[str] = None, region: Optional[str] = None):
if paths is not None:
options["obsSets"] = { "obsSets": [] }
options["obsSets"] = {"obsSets": []}
if names is not None:
names = names
else:
Expand Down Expand Up @@ -114,6 +115,7 @@ def gen_path_schema(key: str, path: Optional[str], options: dict):
gen_obs_points_schema = partial(gen_path_schema, "obsPoints")
gen_feature_labels_schema = partial(gen_path_schema, "featureLabels")


def gen_sdata_image_schema(options, path: str, coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None) -> dict:
if path is not None:
options["image"] = {
Expand All @@ -125,6 +127,7 @@ def gen_sdata_image_schema(options, path: str, coordinate_system: Optional[str]
options["image"]['coordinateSystem'] = coordinate_system
return options


def gen_sdata_labels_schema(options, path: str, table_path: str = "tables/table", coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None) -> dict:
if path is not None:
options["labels"] = {
Expand Down
1 change: 0 additions & 1 deletion vitessce/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ def get_initial_coordination_scope_prefix(dataset_uid, data_type):
def get_initial_coordination_scope_name(dataset_uid, data_type, i=None):
prefix = get_initial_coordination_scope_prefix(dataset_uid, data_type)
return f"{prefix}{0 if i is None else i}"

23 changes: 13 additions & 10 deletions vitessce/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ def raise_error_if_zero_or_more_than_one(inputs):
)
return True


def raise_error_if_any(inputs):
num_inputs = sum([1 for x in inputs if x is not None])
if num_inputs > 0:
Expand All @@ -1076,6 +1077,7 @@ def raise_error_if_any(inputs):
)
return True


def raise_error_if_more_than_one(inputs):
num_inputs = sum([1 for x in inputs if x is not None])
if num_inputs > 1:
Expand All @@ -1084,6 +1086,7 @@ def raise_error_if_more_than_one(inputs):
)
return True


class AnnDataWrapper(AbstractWrapper):
def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_artifact=None, ref_path=None, ref_url=None, ref_artifact=None, obs_feature_matrix_path=None, feature_filter_path=None, initial_feature_filter_path=None, obs_set_paths=None, obs_set_names=None, obs_locations_path=None, obs_segmentations_path=None, obs_embedding_paths=None, obs_embedding_names=None, obs_embedding_dims=None, obs_spots_path=None, obs_points_path=None, feature_labels_path=None, obs_labels_path=None, convert_to_dense=True, coordination_values=None, obs_labels_paths=None, obs_labels_names=None, **kwargs):
"""
Expand Down Expand Up @@ -1303,23 +1306,23 @@ def __init__(self, sdata_path: Optional[str] = None, sdata_url: Optional[str] =
:param coordinate_system: Name of a target coordinate system.
:type coordinate_system: Optional[str]
:param affine_transformation: Transformation to be applied to the image. By default, None. Prefer coordinate_system.
:type affine_transformation: Optional[np.ndarray]
:type affine_transformation: Optional[np.ndarray]
:param shapes_elem: location of the shapes, by default None
:type shapes_elem: Optional[str]
:param labels_elem: location of the labels, by default None
:type labels_elem: Optional[str]
"""
raise_error_if_zero_or_more_than_one([
sdata_path,
sdata_url,
sdata_store,
sdata_artifact,
sdata_path,
sdata_url,
sdata_store,
sdata_artifact,
])
raise_error_if_any([
kwargs.get('adata_path', None),
kwargs.get('adata_url', None),
kwargs.get('adata_store', None),
kwargs.get('adata_artifact', None)
kwargs.get('adata_path', None),
kwargs.get('adata_url', None),
kwargs.get('adata_store', None),
kwargs.get('adata_artifact', None)
])
super().__init__(adata_path=sdata_path, adata_url=sdata_url, adata_store=sdata_store, adata_artifact=sdata_artifact, **kwargs)
self.local_dir_uid = make_unique_filename(".sdata.zarr")
Expand Down Expand Up @@ -1402,7 +1405,7 @@ def from_object(cls: Type[SpatialDataWrapperType], sdata: SpatialData, table_key
spot_shapes_path=str(spot_shapes_elem) if spot_shapes_elem is not None else None,
initial_feature_filter_path=initial_feature_filter_elem,
obs_set_paths=obs_set_elems,
coordination_values={"obsType": "spot"} # TODO: should we remove?
coordination_values={"obsType": "spot"} # TODO: should we remove?
)
]
return wrappers
Expand Down

0 comments on commit 9a43e63

Please sign in to comment.