@@ -447,6 +447,23 @@ def pca_weights_init(self, data):
447447 self ._weights [i , j ] = c1 * pc [pc_order [0 ]] + \
448448 c2 * pc [pc_order [1 ]]
449449
450+ def _check_fixed_points (self , fixed_points , data ):
451+ for k in fixed_points .keys ():
452+ if not isinstance (k , int ):
453+ raise TypeError (f'fixed points indexes must ' +
454+ 'be integers.' )
455+ if k >= len (data ) or k < 0 :
456+ raise ValueError (f'an index of a fixed point ' +
457+ 'cannot be grater than len(data)' +
458+ ' or less than 0.' )
459+ if fixed_points [k ][0 ] >= self ._weights .shape [0 ] or \
460+ fixed_points [k ][1 ] >= self ._weights .shape [1 ]:
461+ raise ValueError (f'coordinates for fixed point' +
462+ ' are out of boundaries.' )
463+ if fixed_points [k ][0 ] < 0 or \
464+ fixed_points [k ][1 ] < 0 :
465+ raise ValueError (f'coordinates cannot be negative.' )
466+
450467 def train (self , data , num_iteration ,
451468 random_order = False , verbose = False ,
452469 use_epochs = False , fixed_points = None ):
@@ -497,21 +514,7 @@ def get_decay_rate(iteration_index, data_len):
497514 return int (iteration_index )
498515
499516 if fixed_points :
500- for k in fixed_points .keys ():
501- if not isinstance (k , int ):
502- raise TypeError (f'fixed points indexes must ' +
503- 'be integers.' )
504- if k >= len (data ) or k < 0 :
505- raise ValueError (f'an index of a fixed point ' +
506- 'cannot be grater than len(data)' +
507- ' or less than 0.' )
508- if fixed_points [k ][0 ] >= self ._weights .shape [0 ] or \
509- fixed_points [k ][1 ] >= self ._weights .shape [1 ]:
510- raise ValueError (f'coordinates for fixed point' +
511- ' are out of boundaries.' )
512- if fixed_points [k ][0 ] < 0 or \
513- fixed_points [k ][1 ] < 0 :
514- raise ValueError (f'coordinates cannot be negative.' )
517+ self ._check_fixed_points (fixed_points , data )
515518 else :
516519 fixed_points = {}
517520
0 commit comments