Example #1
0
def test_calculator_data():
    '''
    This case is used to verify the primary functionality of calculator
    for data-driven
    '''
    calculator = app_calculator.app_calculator()
    calculator.launch()

    print("Save a screen-shot at calculator_launch.png")
    calculator.screenshot("calculator_launch.png")

    calculator.clear()
    assert calculator.verify(cfg("formula"), cfg("exp_result"))
Example #2
0
def my_getNewCard( self, _old ):
    '''Continually call _getNewCard until we get one with a focusMorph we haven't
    seen before. Also skip bad vocab cards'''
    while True:
        C = partial( cfg, None, self.col.decks.active()[0] )
        if not C('next new card feature'):
            return _old( self )
        if not C('new card merged fill'):
            c = _old( self )
        else:   # pop from opposite direction and skip sibling spacing
            if not self._fillNew(): return
            ( id, due ) = self._newQueue.pop( 0 )
            c = self.col.getCard( id )

        if not c: return			# no more cards
        n = c.note()

        try: fm = focus( n )		# fm is either the focusMorph or empty
        except KeyError: return c	# card has no focusMorph field -> assume it's good

        # determine if good vocab word based on whether k+1
        # defaults to whether has focus morph if no k+N field or disabled
        try: goodVocab = n[ cfg( n.mid, None, 'k+N' ) ] == '1'
        except KeyError: goodVocab = fm

        if not goodVocab or fm in seenMorphs or n.hasTag( CN( n, 'tag_alreadyKnown' ) ):
            self.buryNote( c.note().id )
            continue
        break
    return c
Example #3
0
def my_getNewCard(self, _old):
    '''Continually call _getNewCard until we get one with a focusMorph we haven't
    seen before. Also skip bad vocab cards'''
    while True:
        C = partial(cfg, None, self.col.decks.active()[0])
        if not C('next new card feature'):
            return _old(self)
        if not C('new card merged fill'):
            c = _old(self)
        else:  # pop from opposite direction and skip sibling spacing
            if not self._fillNew(): return
            (id, due) = self._newQueue.pop(0)
            c = self.col.getCard(id)

        if not c: return  # no more cards
        n = c.note()

        try:
            fm = focus(n)  # fm is either the focusMorph or empty
        except KeyError:
            return c  # card has no focusMorph field -> assume it's good

        # determine if good vocab word based on whether k+1
        # defaults to whether has focus morph if no k+N field or disabled
        try:
            goodVocab = n[cfg(n.mid, None, 'k+N')] == '1'
        except KeyError:
            goodVocab = fm

        if not goodVocab or fm in seenMorphs or n.hasTag(
                CN(n, 'tag_alreadyKnown')):
            self.buryNote(c.note().id)
            continue
        break
    return c
def per( st, n ):
    mats = mw.col.db.list( 'select ivl from cards where nid = :nid', nid=n.id )
    for f in cfg( n.mid, None, 'morph_fields' ):
        ms = getMorphemes( n[ f ], None, cfg1('morph_blacklist') )
        loc = AnkiDeck( n.id, f, n[ f ], n.guid, mats )
        st['morphDb'].addMsL( ms, loc )
    return st
Example #5
0
def per( st, n ):
    for f in cfg( n.mid, None, 'batch media fields' ):
        try:
            r = re.search( anki.sound._soundReg, n[ f ] )
            if r:
                st['vid2nid'][ r.group(1) ] = n.id
                break
        except KeyError: pass
    return st
Example #6
0
def per( st, n ): # :: State -> Note -> State
    #n.delTag( st['tags'] ) # clear tags if they already exist?
    
    for field in cfg( n.mid, None, 'morph_fields' ):
        for m in getMorphemes( n[ field ], None, cfg1('morph_blacklist') ):
            if m in st['db'].db:
                n.addTag( st['tags'] )
                break
    n.flush()
    return st
Example #7
0
def per(st, n):
    for f in cfg(n.mid, None, 'batch media fields'):
        try:
            r = re.search(anki.sound._soundReg, n[f])
            if r:
                st['vid2nid'][r.group(1)] = n.id
                break
        except KeyError:
            pass
    return st
Example #8
0
def per(st, n):  # :: State -> Note -> State
    #n.delTag( st['tags'] ) # clear tags if they already exist?

    for field in cfg(n.mid, None, 'morph_fields'):
        for m in getMorphemes(getMorphemizerForNote(n), n[field]):
            if m in st['db'].db:
                n.addTag(st['tags'])
                break
    n.flush()
    return st
Example #9
0
def focusName( n ): return    cfg( n.mid, None, 'focusMorph' )
def focus( n ):     return n[ cfg( n.mid, None, 'focusMorph' ) ]
Example #10
0
def focus(n):
    return n[cfg(n.mid, None, 'focusMorph')]
Example #11
0
def CN( n, key ):   return    cfg( n.mid, None, key )
def focusName( n ): return    jcfg('Field_FocusMorph') # TODO remove argument n
Example #12
0
def per(st, n):
    st['morphemizer'] = getMorphemizerForNote(n)
    for f in cfg(n.mid, None, 'morph_fields'):
        st['txt'] += n[f] + '  '
    return st
Example #13
0
def CN(n, key):
    return cfg(n.mid, None, key)
Example #14
0
def per( st, n ):
    for f in cfg( n.mid, None, 'morph_fields' ):
        st['txt'] += n[ f ] + '  '
    return st
Example #15
0
def focusName(n):
    return cfg(n.mid, None, 'focusMorph')
Example #16
0
# %%
from datetime import date, timedelta
import pandas as pd
# from datetime import date, timedelta, datetime
from util import con, cfg, db, tool

# day = date.today().strftime("%Y%m%d")
# minDF = db().selectDatatoDF(sql_statment = f"SELECT * FROM dailyminsholc WHERE TradeDate = {day}")

day = date.today().strftime("%Y-%m-%d")
# day = "2021-10-15"
api = con().LoginToServerForStock(simulate=False)
tb = cfg().getValueByConfigFile(key="tb_mins")
# %%

stock_lst = tool.DFcolumnToList(db().selectDatatoDF(
    cfg().getValueByConfigFile(key="tb_basic")),
                                colname="StockID")

DFtoDBmin = pd.DataFrame()
for id in stock_lst:
    stkDF = con(api).getKarData(stkid=id, sdate=day, edate=day)
    stkDF = stkDF.filter(items=[
        "StockID", "TradeDate", "TradeTime", "Open", "High", "Low", "Close",
        "Volume"
    ])
    print(id)

    db().updateDFtoDB(stkDF, tb_name=tb)

# %%
Example #17
0
def CN( n, key ):   return    cfg( n.mid, None, key )
def focusName( n ): return    cfg( n.mid, None, 'focusMorph' )
Example #18
0
def focus( n ):     return n[ cfg( n.mid, None, 'focusMorph' ) ]


########## 6 parent deck pulls new cards from all children instead of sequentially (ie. mostly first)
def my_fillNew( self, _old ):
Example #19
0
parser = argparse.ArgumentParser()
parser.add_argument('--interval', type=int, default=1)
parser.add_argument('--alpha', type=float, default=0.85)
parser.add_argument('--totalepoch', type=int, default=4)
parser.add_argument('--configure', type=str, default='')

args = parser.parse_args()
eps, alp, training_epochs, configure = args.interval, args.alpha, args.totalepoch, args.configure

from timeit import default_timer as timer
import resource, os, sys

from util import cfg

cf = cfg()
cf.parseConfig(configure)

# Import MNIST data
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets(cf.datadir, one_hot=True)
# mnist = input_data.read_data_sets("../dnn/mnist/MNIST_data/", one_hot=True)
import buildSet as bs
import reNN as rn
import act2grdcp as ag

sys.path.append(cf.paraviewdir)
sys.path.append(cf.paraviewdir + '/python2.7/site-packages')

from paraview.simple import *