def _set_all(self, enable: bool = True): new_values = {k: enable for k in self._get_allowed()} def getter(): return self._get_allowed().copy() def setter(jit_types): self._update_allowed(jit_types) return TemporarilySet(getter=getter, setter=setter, value=new_values)
def sort_by_axes(self, axes, allow_superset: bool = False): axes = convert_to_container(axes) new_reorder_list = [self._reorder_indices_list[self.space.axes.index(ax)] for ax in axes] value = self.space.with_axes(axes=axes), new_reorder_list getter = lambda: (self.space, self._reorder_indices_list) def setter(value): self._space, self._reorder_indices_list = value return TemporarilySet(value=value, getter=getter, setter=setter)
def sort_by_obs(self, obs, allow_superset: bool = False): obs = convert_to_container(obs) new_reorder_list = [self._reorder_indices_list[self.space.obs.index(ob)] for ob in obs] value = self.space.with_obs(obs=obs), new_reorder_list getter = lambda: (self.space, self._reorder_indices_list) def setter(value): self._space, self._reorder_indices_list = value return TemporarilySet(value=value, getter=getter, setter=setter)
def _set_default(self): from zfit import z new_values = z.zextension.FunctionWrapperRegistry._DEFAULT_DO_JIT_TYPES.copy( ) for key in self._get_allowed(): if key not in new_values: new_values[key] = new_values[ key] # default dict will explicitly set the default value def getter(): return self._get_allowed().copy() def setter(jit_types): self._update_allowed(jit_types) return TemporarilySet(getter=getter, setter=setter, value=new_values)
def set_sess(self, sess: tf.Session): """Set the session (temporarily) for this instance. If None, the auto-created default is taken. Args: sess (tf.Session): """ if not isinstance(sess, tf.Session): raise TypeError( "`sess` has to be a TensorFlow Session but is {}".format(sess)) def getter(): return self._sess # use private attribute! self.sess creates default session def setter(value): self.sess = value return TemporarilySet(value=sess, setter=setter, getter=getter)
def set_x(self, x): return TemporarilySet(value=x, setter=self._set_x, getter=self.get_x)