コード例 #1
0
 def _build_more_args(func_settings: tp.Kwargs, func_kwargs: tp.Kwargs) -> tp.Args:
     pass_kwargs = func_settings.get('pass_kwargs', [])
     more_args = ()
     for key in pass_kwargs:
         value = None
         if isinstance(key, tuple):
             key, value = key
         else:
             if key.startswith('temp_idx_arr'):
                 value = np.empty((input_shape[0],), dtype=np.int_)
         value = func_kwargs.get(key, value)
         more_args += (value,)
     return more_args
コード例 #2
0
 def _get_func_names(func_settings: tp.Kwargs, setting: str, all_names: tp.Sequence[str]) -> tp.List[str]:
     func_input_names = func_settings.get(setting, None)
     if func_input_names is None:
         return []
     else:
         for name in func_input_names:
             checks.assert_in(name, all_names)
     return func_input_names
コード例 #3
0
ファイル: plots_builder.py プロジェクト: jingmouren/vectorbt
 def _getattr_func(
     obj: tp.Any,
     attr: str,
     args: tp.ArgsLike = None,
     kwargs: tp.KwargsLike = None,
     call_attr: bool = True,
     _final_kwargs: tp.Kwargs = final_kwargs,
     _opt_arg_names: tp.Set[str] = opt_arg_names,
     _custom_arg_names: tp.
     Set[str] = custom_arg_names,
     _arg_cache_dct: tp.Kwargs = arg_cache_dct
 ) -> tp.Any:
     if attr in final_kwargs:
         return final_kwargs[attr]
     if args is None:
         args = ()
     if kwargs is None:
         kwargs = {}
     if obj is custom_reself and _final_kwargs.pop(
             'resolve_path_' + attr, True):
         if call_attr:
             return custom_reself.resolve_attr(
                 attr,
                 args=args,
                 cond_kwargs={
                     k: v
                     for k, v in
                     _final_kwargs.items()
                     if k in _opt_arg_names
                 },
                 kwargs=kwargs,
                 custom_arg_names=_custom_arg_names,
                 cache_dct=_arg_cache_dct,
                 use_caching=use_caching,
                 passed_kwargs_out=passed_kwargs_out
             )
         return getattr(obj, attr)
     out = getattr(obj, attr)
     if callable(out) and call_attr:
         return out(*args, **kwargs)
     return out