Exemplo n.º 1
0
    def setUp(self):

        cardsA = mst.MdimStruct([2], [(0, 0)])
        cardsB = mst.MdimStruct([3], [(0, 0)])

        self.lsA = lb.LabelSet(cardsA, None)
        self.lsB = lb.LabelSet(cardsB, None)

        return
Exemplo n.º 2
0
    def generate(self, fix_par, mod_par=None):

        res = None

        lim = fix_par.lim

        if mod_par is None:

            offs = 0
            card = fix_par.card
            per = card

        else:

            offs = mod_par.offs
            card = mod_par.mcard
            per = mod_par.per

        def labfc(x):

            clab = cyu.int_cyclic_label(offs, x[0], per, lim)

            res = [clab]

            return res

        fcdims = [(0, 0)]

        cards = mst.MdimStruct([card], fcdims)
        labels = mst.MdimStruct([labfc], fcdims)

        res = lb.LabelSet(cards, labels)

        return res
Exemplo n.º 3
0
 def update(self, src_val, did, cmd, depr = False):
     
     dims = (did, did)
     
     #TODO: implement these as function arguments 
     src = cmd['src']
     fix = cmd['fix']
     
     #1. Get fix value
     if 'n' == fix[did]:
     
         fix_val = self.core_dm.n(did)
     
     elif self.core_symb.get_obj(dims) == fix[did]:
     
         fix_val = self.core_dm.bandlims.get_obj(dims)[1]
     
     else:
         
         wdims = self.core_words.get_dims(did)           
         crword = self.core_words.get_obj(wdims)
             
         dmgen = self.dmgens.get_obj(wdims)[crword][fix]
         fix_dm = dmgen(self.core_dm)
         
         fix_val = fix_dm.bandlims.get_obj(dims)[1]
     
     #2. Apply rule
     rule = self.rls.get_obj(dims)[src[did] ][fix[did] ]
     dst_val = rule(src_val, fix_val)
     
     #3. Prepare results
     new_n = dst_val[0]
     new_bandlims = cp.deepcopy(dst_val[1] )
     
     #4. Core update
     self.core_dm.update(new_n, new_bandlims, did)
             
     #TODO: find final sol. this is a workaround
     rlabels = ls.LabelSet(mst.MdimStruct( [new_n], [ (0, 0) ] ) )
     self.bsubsp_labels.replace(rlabels, dims)
     
     #TODO: remove these depr. members and adapt test cases in test_equirep
     if depr:
         
         dmgen = self.dmgens.get_obj((0,0))['t']['f']
         self.domains = {'t' : self.core_dm, 'f' : dmgen(self.core_dm) }
     
     return
Exemplo n.º 4
0
    def __init__(self, labels=None, points=None):

        if labels is None:

            self.__labels = lb.LabelSet()

        else:

            self.__labels = labels

        if points is None:

            self.__points = default_points()

        else:

            self.__points = points

        return
Exemplo n.º 5
0
def print_single_label():
    try:
        customer = request.form.get('customer')
        cultivar = request.form.get('cultivar')
        tray = request.form.get('tray_number')
        lot = request.form.get('lot_number')
        label_type = request.form.get('label_type')
        print(label_type)

        lsg = labels.LabelSet(customer, cultivar, lot, tray)
        labels.printLabel([(lsg, tray)], label_type)

        response = { "success": True}

    except Exception as e:
        print("print-single-label failed")
        print(str(e))
        response = {
            "success": False,
            "error_message": str(e)
        }
    
    return jsonify(response)
Exemplo n.º 6
0
    def __init__(self, domain = None, symb = None, words = None,
                         rls = None, codmgens = None, dmgens = None, depr = False):
        
        if not symb is None:
        
            self.core_symb = symb
            
        else:
            
            self.core_symb = mst.MdimStruct( ['t'], [ (0,0) ] )
            
        if not words is None:
            
            self.core_words = words
            
        else:
            
            self.core_words = cp.deepcopy(self.core_symb)
        
        if not domain is None:
            
            self.core_dm = domain
        
        else:
            
            self.core_dm = dm.Domain()
            
        if not rls is None:
            
                self.rls = cp.deepcopy(rls)
       
        else:

            self.rls = mst.MdimStruct( [ {'t' : {'t' : None,
                                                 'f' : get_XX_rule('t', 'f'),
                                                 'n': get_Xn_rule('t') },
                                            
                                          'f' : {'t' : get_XX_rule('f', 't'),
                                                 'f' : None, 
                                                 'n': get_Xn_rule('f') },
                                            
                                          'n' : {'t' : get_nX_rule('t'),
                                                 'f' : get_nX_rule('f'), 
                                                 'n': None } } ],
    
                                        [ (0,0) ] )

        #Base function codomain generators
        if not ( codmgens is None ):
            
                self.gens = cp.deepcopy(codmgens)
                
        else:
    
            self.gens = mst.MdimStruct( [ {'t' : {'t' : sgg.get_codm_gen('t', 't'),
                                                  'f' : sgg.get_codm_gen('f','t') },
    
                                           'f' : {'t' : sgg.get_codm_gen('t', 'f'),
                                                  'f' : sgg.get_codm_gen('f', 'f') } } ],
    
                                        [ (0,0) ] )
        
        #Base function domain generators
        if not dmgens is None:
        
            self.dmgens = dmgens
            
        else:

            self.dmgens = mst.MdimStruct( [ {'t' : {'t' : None,
                                                    'f' : get_cartes_gen('t', 'f') },
    
                                             'f' : {'t' : get_cartes_gen('f', 't'),
                                                    'f' : None } } ],
    
                                          [ (0,0) ] )

            
        cards = cp.deepcopy(self.core_dm.ns)        
        self.bsubsp_labels = None
        for card in cards:
            
            new_labels = ls.LabelSet(mst.MdimStruct( [ card[1] ], [ (0,0) ] ) )
            
            if self.bsubsp_labels is None:
                
                self.bsubsp_labels = new_labels
                
            else:
                
                self.bsubsp_labels = self.bsubsp_labels.prod(new_labels)
    
        #TODO: remove this deprecated member, as soon as tests will be adapted
        #to new class structure.
        if depr:
        
            dmgen = self.dmgens.get_obj((0,0))['t']['f']
            
            self.domains = {'t' : self.core_dm, 'f' : dmgen(self.core_dm) }
    
        return