Skip to content

Commit

Permalink
Merge pull request #76 from moshi4/develop
Browse files Browse the repository at this point in the history
Bump to v1.7.1
  • Loading branch information
moshi4 authored Sep 20, 2024
2 parents ce31361 + 23bfe7f commit d9e4756
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/pycirclize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pycirclize.circos import Circos

__version__ = "1.7.0"
__version__ = "1.7.1"

__all__ = [
"Circos",
Expand Down
10 changes: 5 additions & 5 deletions src/pycirclize/circos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pycirclize/parser/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions src/pycirclize/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)),
Expand All @@ -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)))
Expand Down
6 changes: 3 additions & 3 deletions src/pycirclize/sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d9e4756

Please sign in to comment.