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

Fix divide-by-zero, deprecation, and futurewarnings #236

Merged
merged 4 commits into from
Oct 8, 2021
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
9 changes: 5 additions & 4 deletions kmapper/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Cover:

limits: Numpy Array (n_dim,2)
(lower bound, upper bound) for every dimension
If a value is set to `np.float('inf')`, the bound will be assumed to be the min/max value of the dimension
If a value is set to `float('inf')`, the bound will be assumed to be the min/max value of the dimension
Also, if `limits == None`, the limits are defined by the maximum and minimum value of the lens for all dimensions.
i.e. `[[min_1, max_1], [min_2, max_2], [min_3, max_3]]`

Expand Down Expand Up @@ -108,8 +108,8 @@ def _compute_bounds(self, data):
limits_array = np.zeros(self.limits.shape)
limits_array[:, 0] = np.min(data, axis=0)
limits_array[:, 1] = np.max(data, axis=0)
limits_array[self.limits != np.float("inf")] = 0
self.limits[self.limits == np.float("inf")] = 0
limits_array[self.limits != float("inf")] = 0
self.limits[self.limits == float("inf")] = 0
bounds_arr = self.limits + limits_array
""" bounds_arr[i,j] = self.limits[i,j] if self.limits[i,j] == inf
bounds_arr[i,j] = max/min(data[i]) if self.limits == inf """
Expand Down Expand Up @@ -188,7 +188,8 @@ def fit(self, data):
inset = (ranges - inner_range) / 2

# |range| / (2n ( 1 - p))
radius = ranges / (2 * (n_cubes) * (1 - perc_overlap))
with np.errstate(divide='ignore'):
radius = ranges / (2 * (n_cubes) * (1 - perc_overlap))

# centers are fixed w.r.t perc_overlap
zip_items = list(bounds) # work around 2.7,3.4 weird behavior
Expand Down
Loading