diff --git a/src/pycirclize/__init__.py b/src/pycirclize/__init__.py index 47fedc3..0b258e1 100644 --- a/src/pycirclize/__init__.py +++ b/src/pycirclize/__init__.py @@ -1,6 +1,6 @@ from pycirclize.circos import Circos -__version__ = "1.7.0" +__version__ = "1.7.1" __all__ = [ "Circos", diff --git a/src/pycirclize/circos.py b/src/pycirclize/circos.py index b07293f..f86cdc0 100644 --- a/src/pycirclize/circos.py +++ b/src/pycirclize/circos.py @@ -426,7 +426,7 @@ def initialize_from_matrix( colors = utils.ColorCycler.get_color_list(len(names)) name2color = dict(zip(names, colors)) else: - if type(cmap) == defaultdict: + if isinstance(cmap, defaultdict): name2color = cmap else: name2color: dict[str, str] = defaultdict(lambda: "grey") @@ -444,10 +444,10 @@ def initialize_from_matrix( outer_track.xticks_by_interval(ticks_interval, **ticks_kws) # Plot links - fromto_label2color = {f"{t[0]}{t[1]}": t[2] for t in link_cmap} + fromto_label2color = {f"{t[0]}--->{t[1]}": t[2] for t in link_cmap} for link in matrix.to_links(): from_label, to_label = link[0][0], link[1][0] - fromto_label = f"{from_label}{to_label}" + fromto_label = f"{from_label}--->{to_label}" # Set link color if fromto_label in fromto_label2color: color = fromto_label2color[fromto_label] @@ -1061,7 +1061,7 @@ def plotfig( for plot_func in self._get_all_plot_funcs(): plot_func(ax) - return fig + return fig # type: ignore def savefig( self, @@ -1164,7 +1164,7 @@ def _initialize_figure( """ fig = plt.figure(figsize=figsize, dpi=dpi, tight_layout=True) ax = fig.add_subplot(projection="polar") - return fig, ax + return fig, ax # type: ignore def _initialize_polar_axes(self, ax: PolarAxes) -> None: """Initialize polar axes params diff --git a/src/pycirclize/parser/matrix.py b/src/pycirclize/parser/matrix.py index 9692225..18af35d 100644 --- a/src/pycirclize/parser/matrix.py +++ b/src/pycirclize/parser/matrix.py @@ -103,7 +103,7 @@ def parse_fromto_table( for row in fromto_table.itertuples(): from_label, to_label, value = str(row[1]), str(row[2]), row[3] if float(value) > 0: - fromto = f"{from_label}{to_label}" + fromto = f"{from_label}-->{to_label}" fromto2value[fromto] = value label2value_sum[from_label] += value label2value_sum[to_label] += value @@ -134,7 +134,7 @@ def parse_fromto_table( for row_label in all_labels: row_data = [] for col_label in all_labels: - row_data.append(fromto2value[f"{row_label}{col_label}"]) + row_data.append(fromto2value[f"{row_label}-->{col_label}"]) matrix_data.append(row_data) matrix_df = pd.DataFrame(matrix_data, index=all_labels, columns=all_labels) diff --git a/src/pycirclize/patches.py b/src/pycirclize/patches.py index e0151ae..403fb1e 100644 --- a/src/pycirclize/patches.py +++ b/src/pycirclize/patches.py @@ -241,7 +241,7 @@ def __init__( def arc_paths( rad1: float, rad2: float, r: float - ) -> list[tuple[Path.code_type, tuple[float, float]]]: + ) -> list[tuple[np.uint8, tuple[float, float]]]: # If rad1 == rad2, return blank list arc_paths = [] step = config.ARC_RADIAN_STEP if rad1 <= rad2 else -config.ARC_RADIAN_STEP @@ -251,7 +251,7 @@ def arc_paths( def arrow_paths( rad1: float, rad2: float, r_side: float, r_top: float - ) -> list[tuple[Path.code_type, tuple[float, float]]]: + ) -> list[tuple[np.uint8, tuple[float, float]]]: return [ (Path.LINETO, (rad1, r_side)), (Path.LINETO, ((rad1 + rad2) / 2, r_top)), @@ -260,7 +260,7 @@ def arrow_paths( def bezier_paths( rad1: float, rad2: float, r1: float, r2: float, height_ratio: float = 0.5 - ) -> list[tuple[Path.code_type, tuple[float, float]]]: + ) -> list[tuple[np.uint8, tuple[float, float]]]: if height_ratio >= 0.5: # Example1: height_ratio: 0.50 => r_ctl_pos: 0 # Example2: height_ratio: 0.75 => r_ctl_pos: 25 @@ -389,7 +389,7 @@ def bezier_paths( r1: float, r2: float, height_ratio: float = 0.5, - ) -> list[tuple[Path.code_type, tuple[float, float]]]: + ) -> list[tuple[np.uint8, tuple[float, float]]]: if height_ratio >= 0.5: # Example1: height_ratio: 0.50 => r_ctl_pos: 0 # Example2: height_ratio: 0.75 => r_ctl_pos: 25 @@ -412,7 +412,7 @@ def arrow_line_paths( r_pos: float, arrow_rad_width: float, arrow_r_height: float, - ) -> list[tuple[Path.code_type, tuple[float, float]]]: + ) -> list[tuple[np.uint8, tuple[float, float]]]: arrow_r_pos = r_pos - arrow_r_height return [ (Path.MOVETO, (rad_pos + (arrow_rad_width / 2), arrow_r_pos)), @@ -421,7 +421,7 @@ def arrow_line_paths( ] arrow_rad_width = np.radians(arrow_width) - path_data: list[tuple[Path.code_type, tuple[float, float]]] = [] + path_data: list[tuple[np.uint8, tuple[float, float]]] = [] if direction in (config.Direction.REVERSE, config.Direction.BIDIRECTIONAL): path_data.extend(arrow_line_paths(rad1, r1, arrow_rad_width, arrow_height)) path_data.append((Path.MOVETO, (rad1, r1))) diff --git a/src/pycirclize/sector.py b/src/pycirclize/sector.py index 5408cc3..c120ce0 100644 --- a/src/pycirclize/sector.py +++ b/src/pycirclize/sector.py @@ -449,8 +449,8 @@ def raster( # Calculate x, y image set position max_r_lim = config.MAX_R + config.R_PLOT_MARGIN - im_x = np.cos((np.pi / 2) - rad) * (r / max_r_lim) - im_y = np.sin((np.pi / 2) - rad) * (r / max_r_lim) + im_x: float = np.cos((np.pi / 2) - rad) * (r / max_r_lim) + im_y: float = np.sin((np.pi / 2) - rad) * (r / max_r_lim) # Normalize (-1, 1) to (0, 1) axis range im_x = (im_x + 1) / 2 im_y = (im_y + 1) / 2 @@ -463,7 +463,7 @@ def raster( def plot_raster(ax: PolarAxes) -> None: # Set inset axes & plot raster image - bounds = [im_x - (size / 2), im_y - (size / 2), size, size] + bounds = (im_x - (size / 2), im_y - (size / 2), size, size) axin = ax.inset_axes(bounds, transform=ax.transAxes) axin.axis("off") axin.imshow(im, **imshow_kws) # type: ignore