Skip to content

Commit 2fb4430

Browse files
committed
Adding dtype to all numpy arrays
1 parent 55e686b commit 2fb4430

File tree

12 files changed

+16
-15
lines changed

12 files changed

+16
-15
lines changed

prefsampling/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__author__ = "Simon Rey and Stanisław Szufa"
22
__email__ = "[email protected]"
3-
__version__ = "0.1.14"
3+
__version__ = "0.1.15"
44

55
from enum import Enum
66
from itertools import chain

prefsampling/approval/euclidean.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ def euclidean_constant_size(
298298
[
299299
np.linalg.norm(voter_pos - candidates_pos[c])
300300
for c in range(num_candidates)
301-
]
301+
],
302+
dtype=float
302303
)
303304
arg_sort_distances = distances.argsort()
304305
votes.append(set(arg_sort_distances[:num_approvals]))

prefsampling/core/euclidean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _sample_points(
2323
sampler_args["num_points"] = num_points
2424
positions = sampler(**sampler_args)
2525
else:
26-
positions = np.array(positions)
26+
positions = np.array(positions, dtype=float)
2727
if len(positions) != num_points:
2828
raise ValueError(
2929
f"The provided number of points does not match the number of "

prefsampling/ordinal/didi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ def didi(
6363
points = rng.dirichlet(alphas)
6464
votes[i] = np.flip(points.argsort())
6565

66-
return np.array(votes)
66+
return votes

prefsampling/ordinal/identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ def identity(num_voters: int, num_candidates: int, seed: int = None) -> np.ndarr
2525
Ordinal votes.
2626
"""
2727

28-
return np.array([np.arange(num_candidates) for _ in range(num_voters)])
28+
return np.array([np.arange(num_candidates) for _ in range(num_voters)], dtype=int)

prefsampling/ordinal/plackettluce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def plackett_luce(
4848

4949
rng = np.random.default_rng(seed)
5050

51-
alphas = np.array(alphas)
51+
alphas = np.array(alphas, dtype=float)
5252

5353
votes = np.zeros((num_voters, num_candidates), dtype=int)
5454

prefsampling/ordinal/singlecrossing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def single_crossing_impartial(num_voters, num_candidates, seed=None):
207207
vote_node_map = {top_node.vote_as_tuple: top_node}
208208

209209
def graph_builder(node):
210-
vote = np.array(node.vote)
210+
vote = np.array(node.vote, dtype=int)
211211
for j in range(num_candidates - 1):
212212
if vote[j] < vote[j + 1]:
213213
new_vote = vote.copy()
@@ -226,4 +226,4 @@ def graph_builder(node):
226226
top_node.count_elections(num_voters)
227227

228228
votes = top_node.sample_votes(num_voters)
229-
return np.array(votes)
229+
return np.array(votes, dtype=int)

prefsampling/point/ball.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ def ball_resampling(
149149
for _ in range(num_points):
150150
point = inner_sampler(**inner_sampler_args)
151151
if isinstance(point, Iterable):
152-
point = np.array(point)
152+
point = np.array(point, dtype=float)
153153
else:
154-
point = np.array([point])
154+
point = np.array([point], dtype=float)
155155
if len(point) != num_dimensions:
156156
raise ValueError(
157157
f"The inner sampler did not return a point with the suitable number "
@@ -160,4 +160,4 @@ def ball_resampling(
160160
while np.linalg.norm(point - center_point) > (width / 2):
161161
point = inner_sampler(**inner_sampler_args)
162162
points.append(point)
163-
return np.array(points)
163+
return np.array(points, dtype=float)

prefsampling/point/gaussian.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ def gaussian(
7575
point = rng.normal(loc=center_point, scale=sigmas, size=num_dimensions)
7676
points.append(point)
7777

78-
return np.array(points)
78+
return np.array(points, dtype=float)

prefsampling/point/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def validate_center_point(
2525
The coordinates of the center point to be used by the point samplers.
2626
"""
2727
if center_point is None:
28-
center_point = np.array([0 for _ in range(num_dimensions)])
28+
center_point = np.array([0 for _ in range(num_dimensions)], dtype=float)
2929
else:
3030
if not isinstance(center_point, Iterable):
3131
raise TypeError(

0 commit comments

Comments
 (0)