Skip to content

Commit

Permalink
Merge pull request #203 from jGaboardi/__init_docs
Browse files Browse the repository at this point in the history
improved in-line comments in network.Network.__init__
  • Loading branch information
jGaboardi committed Dec 12, 2018
2 parents 4a9ca6b + d91de10 commit 8931a0c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spaghetti/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,24 @@ class Network:
def __init__(self, in_data=None, vertex_sig=11, unique_arcs=True,
extractgraph=True, w_components=True, weightings=False):

# do this when creating a clean network instance from a
# shapefile or a geopandas.GeoDataFrame, otherwise a shell
# network instance is created (see `split_arcs()` method)
if in_data is not None:

# set parameters as attributes
self.in_data = in_data
self.vertex_sig = vertex_sig
self.unique_arcs = unique_arcs

self.adjacencylist = defaultdict(list)
self.vertices = {}

# initialize network arcs and arc_lengths
self.arcs = []
self.arc_lengths = {}

# initialize pointpatterns
self.pointpatterns = {}

# spatial representation of the network
Expand All @@ -190,13 +197,18 @@ def __init__(self, in_data=None, vertex_sig=11, unique_arcs=True,
as_graph = False
network_weightings = False
if weightings is True:
# set network arc weights to length if weights are
# desired, but no other input in given
weightings = self.arc_lengths
network_weightings = True
# extract contiguity weights from libpysal
self.w_network = self.contiguityweights(graph=as_graph,
weightings=weightings)
# extract connected components from the `w_network`
self.extract_components(self.w_network, graph=as_graph)

# extract the graph
# extract the graph -- repeat similar as above
# for extracting the network
if extractgraph:
self.extractgraph()
if w_components:
Expand All @@ -207,7 +219,8 @@ def __init__(self, in_data=None, vertex_sig=11, unique_arcs=True,
graph=as_graph,
weightings=weightings)
self.extract_components(self.w_graph, graph=as_graph)


# sorted list of vertex ids
self.vertex_list = sorted(self.vertices.values())


Expand Down

0 comments on commit 8931a0c

Please sign in to comment.