Skip to content

Commit

Permalink
revert vectorized assignment: loop is faster
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuen committed Sep 6, 2020
1 parent 033d7e4 commit 18a32eb
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions ic3_data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,44 +321,25 @@ def _fill_dnn_container(self, om_key, bin_values_list, bin_indices_list,
self._container.bin_values[om_key] = bin_values_list
self._container.bin_indices[om_key] = bin_indices_list

if self._is_str_dom_format:
self._container.x_dom[self._batch_index,
string - 1, dom - 1, index] = value
else:
if string > 78:
# deep core
self._container.x_deepcore[
self._batch_index, string - 78 - 1, dom - 1,
bin_indices_list] = bin_values_list
for value, index in zip(bin_values_list, bin_indices_list):
if self._is_str_dom_format:
self._container.x_dom[self._batch_index,
string - 1, dom - 1, index] = value
else:
# IC78
a, b = detector.string_hex_coord_dict[string]
# Center of Detector is a,b = 0,0
# a goes from -4 to 5
# b goes from -5 to 4
self._container.x_ic78[
self._batch_index, a + 4, b + 5, dom - 1,
bin_indices_list] = bin_values_list

# for value, index in zip(bin_values_list, bin_indices_list):
# if self._is_str_dom_format:
# self._container.x_dom[self._batch_index,
# string - 1, dom - 1, index] = value
# else:
# if string > 78:
# # deep core
# self._container.x_deepcore[self._batch_index,
# string - 78 - 1, dom - 1,
# index] = value
# else:
# # IC78
# a, b = detector.string_hex_coord_dict[string]
# # Center of Detector is a,b = 0,0
# # a goes from -4 to 5
# # b goes from -5 to 4
# self._container.x_ic78[self._batch_index,
# a + 4, b + 5, dom - 1,
# index] = value
if string > 78:
# deep core
self._container.x_deepcore[self._batch_index,
string - 78 - 1, dom - 1,
index] = value
else:
# IC78
a, b = detector.string_hex_coord_dict[string]
# Center of Detector is a,b = 0,0
# a goes from -4 to 5
# b goes from -5 to 4
self._container.x_ic78[self._batch_index,
a + 4, b + 5, dom - 1,
index] = value

# Add bin exclusions if non-empty
if bin_exclusions_list:
Expand Down

0 comments on commit 18a32eb

Please sign in to comment.