Skip to content

Commit

Permalink
Allow from_gsd constructor to build from dirs other than Binarized, a…
Browse files Browse the repository at this point in the history
…nd test accordingly
  • Loading branch information
AlainKadar committed Jan 22, 2025
1 parent dbf8973 commit c985fba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion StructuralGT/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ def from_gsd(cls, filename, frame=0, depth=None, dim=2):
assert os.path.exists(filename)
_dir = os.path.abspath(filename)
_dir = os.path.split(os.path.split(filename)[0])[0]
N = cls(_dir, depth=depth, dim=dim)
binarized_dir = os.path.split(os.path.split(filename)[0])[-1]
N = cls(_dir, depth=depth, dim=dim, binarized_dir=binarized_dir)
if dim==2: N._2d = True
else: N._2d = False

Expand Down
4 changes: 2 additions & 2 deletions StructuralGT/pytest/test_Networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ def test_unweighted_network(self, test_crop):
return test_crop

def test_from_gsd(self):
writeNetwork = Network(Small_path)
writeNetwork = Network(Small_path, binarized_dir='HighThresh')
writeNetwork.binarize(options=options.agnwn)
writeNetwork.img_to_skel()
writeNetwork.set_graph()

testNetwork = Network.from_gsd(Small_path + 'Binarized/network.gsd')
testNetwork = Network.from_gsd(Small_path + 'HighThresh/network.gsd')

testNetwork.Gr.vs['o'][0]

Expand Down

0 comments on commit c985fba

Please sign in to comment.