Skip to content

Commit

Permalink
improved handling of empty locs when extending arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Jun 6, 2023
1 parent 126bcfb commit 6e394f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions openpnm/_skgraph/operations/_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def add_nodes(network, new_coords):
Nnew = coords.shape[0]
for k, v in g.items():
if k.startswith(node_prefix):
blank = np.repeat(v[:1, ...], Nnew, axis=0)
dval = None
for t in settings.missing_values.keys():
if v.dtype == t:
dval = settings.missing_values[t]
blank = np.repeat(v[:1, ...], Nnew, axis=0)*dval
blank.fill(dval)
g[k] = np.concatenate((v, blank), axis=0)
g[k] = np.concatenate((v, blank), axis=0).astype(v.dtype)
# Lastly, overwrite the -Nnew elements of coords with the given values
g[node_prefix+'.coords'][-Nnew:] = np.array(coords)
return g
Expand Down Expand Up @@ -89,13 +89,13 @@ def add_edges(network, new_conns):
Nnew = conns.shape[0]
for k, v in g.items():
if k.startswith(edge_prefix):
blank = np.repeat(v[:1, ...], Nnew, axis=0)
dval = None
for t in settings.missing_values.keys():
if v.dtype == t:
dval = settings.missing_values[t]
blank = np.repeat(v[:1, ...], Nnew, axis=0)*dval
blank.fill(dval)
g[k] = np.concatenate((v, blank), axis=0)
g[k] = np.concatenate((v, blank), axis=0).astype(v.dtype)
# Lastly, overwrite the -Nnew elements of coords with the given values
g[edge_prefix+'.conns'][-Nnew:] = np.array(conns)
return g
Expand Down

0 comments on commit 6e394f7

Please sign in to comment.