Skip to content

Commit

Permalink
Merge pull request PMEAL#2841 from PMEAL/bug_fixes_in_voronoi_generators
Browse files Browse the repository at this point in the history
Fixed dtype bug in isoutside function, and passing f to reflect basepoints #bug
  • Loading branch information
jgostick authored Oct 5, 2023
2 parents 0e3a4ba + daff76f commit 551252f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openpnm/_skgraph/generators/_voronoi_delaunay_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def voronoi_delaunay_dual(
points=points,
shape=shape,
reflect=reflect,
f=1,
f=f,
)

# Generate mask to remove any dims with all 0's
Expand Down
2 changes: 1 addition & 1 deletion openpnm/_skgraph/generators/tools/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def parse_points(shape, points, reflect=False, f=1):
"""
# Deal with input arguments
shape = np.array(shape, dtype=int)
shape = np.array(shape, dtype=float)
if isinstance(points, int):
points = generate_base_points(num_points=points,
domain_size=shape,
Expand Down
11 changes: 11 additions & 0 deletions openpnm/models/misc/_neighbor_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def from_neighbor_throats(target, prop, mode='min', ignore_nans=True):
neighboring throats
'mean' Returns the value of the mean property of the
neighboring throats
'sum' Returns the sum of the property of the neighboring
throats
=========== =====================================================
Returns
Expand Down Expand Up @@ -69,6 +71,11 @@ def from_neighbor_throats(target, prop, mode='min', ignore_nans=True):
if ignore_nans:
np.subtract.at(counts, im.row, nans[im.col])
values = values/counts
if mode == 'sum':
if ignore_nans:
data[nans] = 0
values = np.zeros((network.Np, ))
np.add.at(values, im.row, data[im.col])
return values


Expand Down Expand Up @@ -98,6 +105,8 @@ def from_neighbor_pores(target, prop, mode='min', ignore_nans=True):
neighboring pores
'mean' Returns the value of the mean property of the
neighboring pores
'sum' Returns the sum of the property of the neighrboring
pores
=========== =====================================================
ignore_nans : bool (default is ``True``)
Expand All @@ -122,6 +131,8 @@ def from_neighbor_pores(target, prop, mode='min', ignore_nans=True):
value = np.amax(pvalues, axis=1)
if mode == 'mean':
value = np.mean(pvalues, axis=1)
if mode == 'sum':
value = np.sum(pvalues, axis=1)
except np.AxisError: # Handle case of empty pvalues
value = []
return np.array(value)

0 comments on commit 551252f

Please sign in to comment.