Skip to content

Commit 4731a0b

Browse files
committed
more accurate dtype
1 parent 80b3c70 commit 4731a0b

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

spynnaker/pyNN/models/neural_projections/connectors/convolution_connector.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ def __init__(self, kernel_weights: _Weights,
165165
self.__padding_shape = self.__decode_padding(padding)
166166
self.__filter_edges = filter_edges
167167

168+
self.__strides: NDArray[integer]
168169
if strides is None:
169-
self.__strides = numpy.array((1, 1), dtype=integer)
170+
self.__strides = numpy.array((1, 1), dtype=numpy.uint32)
170171
else:
171172
self.__strides = self.__to_2d_shape(strides, "strides")
172173
self.__pool_shape = self.__to_2d_shape(pool_shape, "pool_shape")
@@ -261,20 +262,20 @@ def __to_2d_shape(shape: _Shape, param_name: str) -> Optional[
261262
if shape is None:
262263
return None
263264
if numpy.isscalar(shape):
264-
return numpy.array([shape, shape], dtype=integer)
265+
return numpy.array([shape, shape], dtype=uint32)
265266
assert isinstance(shape, tuple)
266267
if len(shape) == 1:
267-
return numpy.array([shape[0], 1], dtype=integer)
268+
return numpy.array([shape[0], 1], dtype=uint32)
268269
elif len(shape) == 2:
269-
return numpy.array(shape, dtype=integer)
270+
return numpy.array(shape, dtype=uint32)
270271
raise SynapticConfigurationException(
271272
f"{param_name} must be an int or a tuple(int, int)")
272273

273274
def __decode_padding(self, padding: _Padding) -> NDArray[integer]:
274275
if isinstance(padding, (int, Iterable)):
275276
return self.__to_2d_shape(padding, "padding")
276277
elif padding is None or padding is False:
277-
return numpy.zeros(2, dtype=integer)
278+
return numpy.zeros(2, dtype=uint32)
278279
elif padding:
279280
return self.__kernel_weights.shape // 2
280281
else:

spynnaker/pyNN/models/neural_projections/connectors/fixed_number_post_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __build_post_neurons(
133133
self, synapse_info: SynapseInformation) -> List[NDArray[integer]]:
134134
rng = self.__rng or NumpyRNG()
135135
post_neurons: List[NDArray[integer]] = \
136-
[numpy.empty([0], dtype=integer)] * synapse_info.n_pre_neurons
136+
[numpy.empty([0], dtype=uint32)] * synapse_info.n_pre_neurons
137137
# Loop over all the pre neurons
138138
for m in range(synapse_info.n_pre_neurons):
139139
if post_neurons[m] is None:

spynnaker/pyNN/models/neural_projections/connectors/fixed_number_pre_connector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ def get_delay_minimum(self, synapse_info: SynapseInformation) -> float:
133133
def __build_pre_neurons(self, synapse_info: SynapseInformation) -> List[
134134
NDArray[integer]]:
135135
rng = self.__rng or NumpyRNG()
136-
pre_neurons = [
137-
numpy.zeros([0], dtype=integer)] * synapse_info.n_post_neurons
136+
pre_neurons: List[NDArray[integer]] = [
137+
numpy.zeros([0], dtype=uint32)] * synapse_info.n_post_neurons
138138
# Loop over all the post neurons
139139
for m in range(synapse_info.n_post_neurons):
140140
# If the pre and post populations are the same

spynnaker/pyNN/utilities/neo_buffer_database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
TYPE_CHECKING, Union)
2525

2626
import numpy
27-
from numpy import floating, integer, uint8, uint32
27+
from numpy import float64, floating, integer, uint8, uint32
2828
from numpy.typing import NDArray
2929
import quantities
3030
import neo # type: ignore[import]
@@ -892,7 +892,7 @@ def __get_matrix_data(
892892
pop_neurons.extend(neurons)
893893
else:
894894
indexes.append(index)
895-
neurons = numpy.array([index], dtype=integer)
895+
neurons = numpy.array([index], dtype=uint32)
896896
times, data = self.__get_matrix_data_by_region(
897897
region_id, neurons, data_type)
898898
if signal_array is None or pop_times is None:
@@ -904,7 +904,7 @@ def __get_matrix_data(
904904
else:
905905
raise NotImplementedError("times differ")
906906
if signal_array is None:
907-
signal_array = numpy.zeros((0,), dtype=floating)
907+
signal_array = numpy.zeros((0,), dtype=float64)
908908

909909
if len(indexes) > 0:
910910
assert (len(pop_neurons) == 0)
@@ -993,7 +993,7 @@ def __get_rewires(self, rec_id: int,
993993
rewire_preids, rewire_times, sampling_interval_ms)
994994

995995
if len(rewire_values) == 0:
996-
return numpy.zeros((0, 4), dtype=integer)
996+
return numpy.zeros((0, 4), dtype=uint32)
997997

998998
result = numpy.column_stack(
999999
(rewire_times, rewire_preids, rewire_postids, rewire_values))

spynnaker/pyNN/utilities/struct.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ def read_data(
371371
:type array_size: int or None
372372
"""
373373
n_items = 1
374-
ids = numpy.zeros([0], dtype=integer)
375374
if vertex_slice is None:
376375
if self.__repeat_type != StructRepeat.GLOBAL:
377376
raise ValueError(

spynnaker/pyNN/utilities/utility_calls.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import neo
2626
from neo.io.baseio import BaseIO # type: ignore[import]
2727
import numpy
28-
from numpy import uint32, floating
28+
from numpy import uint32, float64, floating
2929
from numpy.typing import NDArray
3030
from pyNN.random import AbstractRNG, RandomDistribution
3131
from scipy.stats import binom
@@ -104,12 +104,12 @@ def convert_param_to_numpy(
104104
# that it is an array
105105
param_value = param.next(n=no_atoms)
106106
if hasattr(param_value, '__iter__'):
107-
return numpy.array(param_value, dtype=floating)
108-
return numpy.array([param_value], dtype=floating)
107+
return numpy.array(param_value, dtype=float64)
108+
return numpy.array([param_value], dtype=float64)
109109

110110
# Deal with a single value by exploding to multiple values
111111
if not hasattr(param, '__iter__'):
112-
return numpy.array([param] * no_atoms, dtype=floating)
112+
return numpy.array([param] * no_atoms, dtype=float64)
113113

114114
# Deal with multiple values, but not the correct number of them
115115
if len(cast(Sized, param)) != no_atoms:
@@ -118,7 +118,7 @@ def convert_param_to_numpy(
118118
" the vertex")
119119

120120
# Deal with the correct number of multiple values
121-
return numpy.array(param, dtype=floating)
121+
return numpy.array(param, dtype=float64)
122122

123123

124124
def convert_to(value: float, data_type: DataType) -> uint32:

0 commit comments

Comments
 (0)