Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes in voronoi generators #2841

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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])

Check warning on line 78 in openpnm/models/misc/_neighbor_lookups.py

View check run for this annotation

Codecov / codecov/patch

openpnm/models/misc/_neighbor_lookups.py#L75-L78

Added lines #L75 - L78 were not covered by tests
return values


Expand Down Expand Up @@ -98,6 +105,8 @@
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 @@
value = np.amax(pvalues, axis=1)
if mode == 'mean':
value = np.mean(pvalues, axis=1)
if mode == 'sum':
value = np.sum(pvalues, axis=1)

Check warning on line 135 in openpnm/models/misc/_neighbor_lookups.py

View check run for this annotation

Codecov / codecov/patch

openpnm/models/misc/_neighbor_lookups.py#L135

Added line #L135 was not covered by tests
except np.AxisError: # Handle case of empty pvalues
value = []
return np.array(value)