|
32 | 32 | as it is the first one found idle. |
33 | 33 | """ |
34 | 34 |
|
35 | | -import inspect |
36 | | -import time |
| 35 | +from abc import ABC, abstractmethod |
37 | 36 | import copy |
38 | | -import threading |
| 37 | +import inspect |
39 | 38 | import logging |
40 | | -from abc import abstractmethod, ABC |
| 39 | +import threading |
| 40 | +import time |
| 41 | + |
41 | 42 | import joblib |
42 | 43 | import numpy as np |
43 | 44 | import tensorflow as tf |
| 45 | + |
44 | 46 | from vegasflow.configflow import ( |
45 | | - MAX_EVENTS_LIMIT, |
46 | 47 | DEFAULT_ACTIVE_DEVICES, |
47 | 48 | DTYPE, |
48 | 49 | DTYPEINT, |
| 50 | + MAX_EVENTS_LIMIT, |
49 | 51 | TECH_CUT, |
50 | 52 | float_me, |
51 | | - int_me, |
52 | 53 | fone, |
53 | 54 | fzero, |
| 55 | + int_me, |
54 | 56 | ) |
55 | 57 |
|
56 | | - |
57 | 58 | logger = logging.getLogger(__name__) |
58 | 59 |
|
59 | 60 |
|
@@ -304,7 +305,8 @@ def _apply_integration_limits(self, rand): |
304 | 305 |
|
305 | 306 | def _can_run_vectorial(self, expected_shape=None): |
306 | 307 | """Accepting vectorial integrands depends on the algorithm, |
307 | | - if an algorithm can run on vectorial algorithms it should implement this method and return True""" |
| 308 | + if an algorithm can run on vectorial algorithms it should implement this method and return True |
| 309 | + """ |
308 | 310 | return self._CAN_RUN_VECTORIAL |
309 | 311 |
|
310 | 312 | #### Integration management |
@@ -561,7 +563,7 @@ def compile(self, integrand, compilable=True, signature=None, trace=False, check |
561 | 563 | signature = False |
562 | 564 |
|
563 | 565 | compile_options = { |
564 | | - "experimental_autograph_options": tf.autograph.experimental.Feature.ALL, |
| 566 | + "experimental_autograph_options": tf.autograph.experimental.Feature.ALL |
565 | 567 | } |
566 | 568 | if signature is None: |
567 | 569 | signature = autodiscover_signature |
@@ -606,14 +608,14 @@ def batch_events(**kwargs): |
606 | 608 | ) |
607 | 609 | test_array = tf.random.uniform((event_size, self.n_dim), dtype=DTYPE) |
608 | 610 | wgt = tf.random.uniform((event_size,), dtype=DTYPE) |
609 | | - res_tmp = new_integrand(test_array, weight=wgt)#.numpy() |
| 611 | + res_tmp = new_integrand(test_array, weight=wgt) # .numpy() |
610 | 612 | res_shape = res_tmp.shape |
611 | 613 |
|
612 | 614 | expected_shape = (event_size,) |
613 | 615 |
|
614 | 616 | if len(res_shape) == 2: |
615 | 617 | self._vectorial = True |
616 | | - expected_shape = res_tmp.reshape(event_size, -1).shape |
| 618 | + expected_shape = tf.reshape(res_tmp, (event_size, -1)).shape |
617 | 619 | if not self._can_run_vectorial(expected_shape): |
618 | 620 | raise NotImplementedError( |
619 | 621 | f"""The {self.__class__.__name__} algorithm does not support vectorial integrands |
|
0 commit comments