Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed ValueError for MST and fixed SnytaxErrors #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mistree/mst/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def get_branch_index(edge_index, edge_degree, branch_cutting_frequency=1000):
done = 1.
else:
check_end[condition] = 0.
_twig.append(index_branch_end[condition])
_twig.append(index_branch_end[condition][0])
done = 1.
mask_end[condition] = False
branch_index.append(np.ndarray.tolist(np.ndarray.flatten(np.array(_twig))))
else:
if len(condition) == 1:
check_mid[condition] = 0.
_twig.append(index_branch_mid[condition])
_twig.append(index_branch_mid[condition][0])
if index_branch_mid1[condition] == node_index:
node_index = index_branch_mid2[condition]
elif index_branch_mid2[condition] == node_index:
Expand Down Expand Up @@ -241,7 +241,7 @@ def get_branch_index_sub_divide(sub_divisions, edge_index, edge_degree, box_size
branch_index_cut_corrected = [np.ndarray.tolist(condition[i]) for i in branch_index_cut]
branch_index_total = branch_index_total + branch_index_cut_corrected
total_mask[[item for sublist in branch_index_total for item in sublist]] = 0.
if len(branch_index_rejected_cut) is not 0:
if len(branch_index_rejected_cut) != 0:
branch_index_rejected_total = branch_index_rejected_total + \
np.ndarray.tolist(condition[branch_index_rejected_cut])
total_mask[branch_index_rejected_total] = 0.
Expand Down
8 changes: 4 additions & 4 deletions mistree/mst/get_mst_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ def get_branches(self, box_size=None, sub_divisions=1):
The number of divisions used to divide the data set in each axis. Used for speeding up the branch
finding algorithm when using many points (> 100000).
"""
if sub_divisions is 1:
if sub_divisions == 1:
branch_index, rejected_branch_index = branches.get_branch_index(self.edge_index, self.edge_degree)
else:
if self._mode is '2D':
if self._mode == '2D':
branch_index, rejected_branch_index = \
branches.get_branch_index_sub_divide(sub_divisions, self.edge_index, self.edge_degree,
box_size=box_size, edge_x=self.edge_x, edge_y=self.edge_y,
mode='Euclidean', two_dimension=True)
elif self._mode is '3D':
elif self._mode == '3D':
branch_index, rejected_branch_index = \
branches.get_branch_index_sub_divide(sub_divisions, self.edge_index, self.edge_degree,
box_size=box_size, edge_x=self.edge_x, edge_y=self.edge_y,
Expand All @@ -213,7 +213,7 @@ def get_branches(self, box_size=None, sub_divisions=1):
box_size=None, phi=self.phi, theta=self.theta,
edge_phi=self.edge_phi, edge_theta=self.edge_theta, mode='spherical')
self.branch_index = branch_index
if len(rejected_branch_index) is not 0:
if len(rejected_branch_index) != 0:
if self.do_print is True:
print(str(float(len(rejected_branch_index))) + ' branches were incompleted.')
branch_length = [np.sum(self.edge_length[i]) for i in branch_index]
Expand Down