@@ -196,27 +196,44 @@ def __init__(self, api_util, **kwargs):
196196 return
197197
198198 idx = kwargs .get ('idx' )
199- if regexp is not None :
200- idx , idx_ptr , idx_cnt = self ._prepare_int32_array (idx )
199+ if idx is not None :
200+ idx , idx_ptr , idx_cnt = self ._prepare_int32_array (np . asarray ( idx ) + 1 )
201201 self ._lib .Batch_CreateByIndex (ptrptr , countptr , self ._cls_idx , idx_ptr , idx_cnt )
202202 self ._wrap_ptr (ptrptr , countptr )
203203 self ._check_for_error ()
204204 return
205205
206- (prop_name , intval ), = kwargs .items ()
206+ (prop_name , val ), = kwargs .items ()
207207 prop_idx = self ._obj_cls ._cls_prop_idx .get (prop_name .lower ())
208208 if prop_idx is None :
209- raise ValueError ('Invalid property name "{}"' .format (prop_name ))
210- self ._lib .Batch_CreateByInt32Property (ptrptr , countptr , self ._cls_idx , prop_idx , intval )
209+ raise ValueError (f'Invalid property name "{ prop_name } "' )
210+
211+ if isinstance (val , int ) and prop_idx in self ._obj_cls ._cls_int_idx :
212+ # Single integer value for an integer property
213+ self ._lib .Batch_CreateByInt32Property (ptrptr , countptr , self ._cls_idx , prop_idx , val )
214+ kwargs = None
215+ elif prop_idx in self ._obj_cls ._cls_float_idx :
216+ if isinstance (val , LIST_LIKE ) and len (val ) == 2 and isinstance (val [0 ], (int , float )):
217+ # Range of values for a float property
218+ self ._lib .Batch_CreateByFloat64PropertyRange (ptrptr , countptr , self ._cls_idx , prop_idx , * val )
219+ kwargs = None
220+ elif isinstance (val , (int , float )):
221+ # Single value for a float property
222+ self ._lib .Batch_CreateByFloat64PropertyRange (ptrptr , countptr , self ._cls_idx , prop_idx , val , val )
223+ kwargs = None
224+
225+ if kwargs is not None :
226+ raise ValueError (f'Property "{ prop_name } " cannot be used to create a filtered batch with value { repr (val )} .' )
227+
211228 self ._wrap_ptr (ptrptr , countptr )
212229 self ._check_for_error ()
213230
214231 def begin_edit (self ) -> None :
215232 '''
216233 Marks for editing all DSS objects in the batch
217234
218- In the editing mode, some final side-effects of changing properties are post-poned
219- until `_end_edit ` is called. This side-effects can be somewhat costly, like updating
235+ In the editing mode, some final side-effects of changing properties are postponed
236+ until `end_edit ` is called. This side-effects can be somewhat costly, like updating
220237 the model parameters or internal matrices.
221238
222239 If you don't have any performance constraint, you may edit each property individually
0 commit comments