Skip to content

Commit

Permalink
Fix circuilar imports
Browse files Browse the repository at this point in the history
  • Loading branch information
eleftherioszisis committed Feb 16, 2022
1 parent 6314bd7 commit 8cbf683
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions vascpy/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import numpy as np
import pandas as pd

import vascpy.point_vasculature
import vascpy.section_vasculature
from vascpy import specs
from vascpy.point_vasculature import PointVasculature
from vascpy.section_vasculature import SectionVasculature
from vascpy.utils.geometry import unique_points

# from vascpy.section_graph.io import save_section_graph_data
Expand Down Expand Up @@ -83,7 +83,7 @@ def convert_section_to_point_vasculature(section_vasculature):
columns=[t.name for t in SPEC.EDGE_PROPERTIES],
)

return PointVasculature(node_properties, edge_properties)
return vascpy.point_vasculature.PointVasculature(node_properties, edge_properties)


def convert_point_to_section_vasculature(point_vasculature): # pylint: disable=R0914,R0915
Expand Down Expand Up @@ -169,7 +169,7 @@ def _section_point_indices(edge_list):
h5f.create_dataset("structure", data=structure, dtype=SPEC.STRUCTURE)
h5f.create_dataset("connectivity", data=chain_connectivity, dtype=SPEC.CONNECTIVITY)

section_vasculature = SectionVasculature.load(filename)
section_vasculature = vascpy.section_vasculature.SectionVasculature.load(filename)

return section_vasculature

Expand Down
16 changes: 9 additions & 7 deletions vascpy/point_vasculature.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
import pandas as pd

import vascpy.conversion
from vascpy.exceptions import VasculatureAPIError
from vascpy.point_graph import features, io
from vascpy.utils.adjacency import AdjacencyMatrix
Expand Down Expand Up @@ -130,11 +131,12 @@ def n_edges(self):
@property
def adjacency_matrix(self):
"""Returns sparse adjacency matrix of the nodes"""

return AdjacencyMatrix(self.edges, n_vertices=self.n_nodes)

def remove(
self, node_indices: Optional[np.ndarray] = None, edge_indices: Optional[np.ndarray] = None
self,
node_indices: Optional[np.ndarray] = None,
edge_indices: Optional[np.ndarray] = None,
):
"""
Remove node and edge indices from the point graph.
Expand Down Expand Up @@ -291,10 +293,7 @@ def volume(self):

def as_section_graph(self):
"""Converts the point graph to a section graph"""
# pylint: disable=import-outside-toplevel
from vascpy.conversion import convert_point_to_section_vasculature

return convert_point_to_section_vasculature(self)
return vascpy.conversion.convert_point_to_section_vasculature(self)


def add_section_annotation(point_vasculature, annotation_name, section_ids, segment_ids):
Expand Down Expand Up @@ -329,7 +328,10 @@ def add_section_annotation(point_vasculature, annotation_name, section_ids, segm
old_index = edge_properties.index

edge_properties.index = pd.MultiIndex.from_arrays(
(edge_properties["section_id"].to_numpy(), edge_properties["segment_id"].to_numpy())
(
edge_properties["section_id"].to_numpy(),
edge_properties["segment_id"].to_numpy(),
)
)

# initialze with -1 if the column doesn't exist
Expand Down
14 changes: 6 additions & 8 deletions vascpy/section_vasculature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from morphio.vasculature import Vasculature
import morphio.vasculature

from vascpy.section_graph import io
import vascpy.conversion
import vascpy.section_graph.io


class SectionVasculature:
"""Section representation of graphs"""

def __init__(self, filepath):
self._graph = Vasculature(filepath)
self._graph = morphio.vasculature.Vasculature(filepath)

@classmethod
def load(cls, filepath):
Expand Down Expand Up @@ -56,11 +57,8 @@ def as_point_graph(self):
Returns:
Point graph
"""
# pylint: disable=import-outside-toplevel
from vascpy.conversion import convert_section_to_point_vasculature

return convert_section_to_point_vasculature(self)
return vascpy.conversion.convert_section_to_point_vasculature(self)

def save(self, filepath):
"""Write morphology to file"""
io.HDF5.write(filepath, self.points, self.diameters, self.sections)
vascpy.section_graph.io.HDF5.write(filepath, self.points, self.diameters, self.sections)

0 comments on commit 8cbf683

Please sign in to comment.