Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.group_label_position == "beginning":
for idx in node_idcs[:-1]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "middle":
node_idcs = node_idcs.reshape(len(node_idcs), 1)
node_idcs = np.concatenate((node_idcs[:-1], node_idcs[1:]), axis=1)
for idx in node_idcs:
theta1 = group_theta(node_length, idx[0])
theta2 = group_theta(node_length, idx[1] - 1)
x, y = get_cartesian(r=radius, theta=(theta1 + theta2) / 2)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "end":
for idx in node_idcs[1::]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx - 1)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
for idx in node_idcs[:-1]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "middle":
node_idcs = node_idcs.reshape(len(node_idcs), 1)
node_idcs = np.concatenate((node_idcs[:-1], node_idcs[1:]), axis=1)
for idx in node_idcs:
theta1 = group_theta(node_length, idx[0])
theta2 = group_theta(node_length, idx[1] - 1)
x, y = get_cartesian(r=radius, theta=(theta1 + theta2) / 2)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "end":
for idx in node_idcs[1::]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx - 1)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
node_idcs = node_idcs.reshape(len(node_idcs), 1)
node_idcs = np.concatenate((node_idcs[:-1], node_idcs[1:]), axis=1)
for idx in node_idcs:
theta1 = group_theta(node_length, idx[0])
theta2 = group_theta(node_length, idx[1] - 1)
x, y = get_cartesian(r=radius, theta=(theta1 + theta2) / 2)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "end":
for idx in node_idcs[1::]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx - 1)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
self.group_label_coords = {"x": xs, "y": ys}
self.group_label_aligns = {"has": has, "vas": vas}
self.groups = groups.keys()
node_length = len(data)
groups = items_in_groups(data)
edge_of_plot = self.plot_radius + self.nodeprops["radius"]
# The 1.02 serves as padding
radius = 1.02 * edge_of_plot + self.group_label_offset
xs = []
ys = []
has = []
vas = []
node_idcs = np.cumsum(list(groups.values()))
node_idcs = np.insert(node_idcs, 0, 0)
if self.group_label_position == "beginning":
for idx in node_idcs[:-1]:
x, y = get_cartesian(
r=radius, theta=group_theta(node_length, idx)
)
ha, va = text_alignment(x, y)
xs.append(x)
ys.append(y)
has.append(ha)
vas.append(va)
elif self.group_label_position == "middle":
node_idcs = node_idcs.reshape(len(node_idcs), 1)
node_idcs = np.concatenate((node_idcs[:-1], node_idcs[1:]), axis=1)
for idx in node_idcs:
theta1 = group_theta(node_length, idx[0])
theta2 = group_theta(node_length, idx[1] - 1)
x, y = get_cartesian(r=radius, theta=(theta1 + theta2) / 2)
ha, va = text_alignment(x, y)
xs.append(x)