Skip to content

Commit

Permalink
Merge pull request #13414 from pmla/spherical-voronoi-region-dtypes
Browse files Browse the repository at this point in the history
BUG: maintain dtype of SphericalVoronoi regions
  • Loading branch information
tylerjereddy committed Jan 22, 2021
2 parents 0ec3c2f + 93b02e5 commit ed24f99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scipy/spatial/_voronoi.pyx
Expand Up @@ -75,4 +75,4 @@ def sort_vertices_of_regions(int[:,::1] simplices, regions):
remaining_count += 1
remaining_filter(remaining, current_simplex)
regions_arr = np.asarray(sorted_vertices)
regions[n] = regions_arr[regions_arr > ARRAY_FILLER].tolist()
regions[n] = list(regions_arr[regions_arr > ARRAY_FILLER])
10 changes: 10 additions & 0 deletions scipy/spatial/tests/test_spherical_voronoi.py
Expand Up @@ -347,3 +347,13 @@ def test_attribute_types(self, radius, center):
assert sv.points.dtype is np.dtype(np.float64)
assert sv.center.dtype is np.dtype(np.float64)
assert isinstance(sv.radius, float)

def test_region_types(self):
# Tests that region integer type does not change
# See Issue #13412
sv = SphericalVoronoi(self.points)
dtype = type(sv.regions[0][0])
sv.sort_vertices_of_regions()
assert type(sv.regions[0][0]) == dtype
sv.sort_vertices_of_regions()
assert type(sv.regions[0][0]) == dtype

0 comments on commit ed24f99

Please sign in to comment.