Skip to content

Variable type mixup for channel_source #129

@ehrenfeu

Description

@ehrenfeu

Parameter channel_source in duplicate_transformations() is stated to be of type int in the docstring, but defaults to None (which is of type NoneType):

def duplicate_transformations(
project_path,
transformation_type="channel",
channel_source=None,
tile_source=None,
transformation_to_use="[Replace all transformations]",
):
"""Duplicate / propagate transformation parameters to other channels.
Propagate the transformation parameters generated by a previously performed
registration of a single channel to the other channels.
Parameters
----------
project_path : str
Path to the `.xml` project.
transformation_type : str, optional
Transformation mode, one of `channel` (to propagate from one channel to
all others) and `tiles` (to propagate from one tile to all others).
channel_source : int, optional
Reference channel nummber (starting at 1), by default None.
tile_source : int, optional
Reference tile, by default None.
transformation_to_use : str, optional
One of `[Replace all transformations]` (default) and `[Add last
transformation only]` to specify which transformations to propagate.
"""

Looking at line 1415 in the function body, this has the potential to fail as operator "-" is not supported for "None":

source = str(channel_source - 1)

The obvious option would be to use an int-type default, e.g. channel_source=0 or channel_source=-1 depending on what makes more sense, and then adjust the conditional here to e.g. if channel_source >=0:

if channel_source:

Metadata

Metadata

Labels

invalidThis doesn't seem right

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions