Exemplo n.º 1
0
TEST(NAME, DestroyEntitiesByName)
{
    World w;
    MockEntityManagerListener mock;
    EntityManager em(&w);
    em.event.addListener(&mock, "mock");

    // uninteresting calls
    EXPECT_CALL(mock, onEntitiesReallocatedHelper(testing::_))
        .Times(testing::AtLeast(0));

    // interesting calls
    EXPECT_CALL(mock, onCreateEntityHelper(testing::_))
        .Times(3);
    EXPECT_CALL(mock, onDestroyEntityHelper(testing::_))
        .Times(2);

    Entity& e1 = em.createEntity("entity");
    Entity& e2 = em.createEntity("entity");
    Entity& e3 = em.createEntity("keep me");
    ASSERT_EQ(3, em.getEntityList().size());
    em.destroyEntities("entity");
    ASSERT_EQ(1, em.getEntityList().size());
    em.event.removeListener("mock");
}
Exemplo n.º 2
0
TEST(MovesTest, Constructor)
{
    Board board;
    Pieces pieces;
    Position position;
    MoveList list;

    Move m;
    ExtendedMove em(m, 50);
    list[0] = em;
    EXPECT_EQ(em.value(), list[0].value());

    EXPECT_EQ(0, list.cur_ply());

    Moves moves(board, pieces, position, list);

    // Test if MoveList::inc_ply() has been implicitly called by Moves()
    EXPECT_EQ(1, list.cur_ply());

    EXPECT_EQ(BEST, moves.state());

    EXPECT_EQ(0, moves.count(BEST));
    EXPECT_EQ(0, moves.count(GOOD_CAPTURES));
    EXPECT_EQ(0, moves.count(KILLERS));
    EXPECT_EQ(0, moves.count(BAD_CAPTURES));
    EXPECT_EQ(0, moves.count(QUIET_MOVES));

    for (int i = 0; i < MAX_PLY; ++i) {
        EXPECT_EQ(0, list[i].value());
    }
    list.dec_ply();
    EXPECT_EQ(em.value(), list[0].value());
}
Exemplo n.º 3
0
void KOAttendeeListView::dropEvent( QDropEvent *e )
{
#ifndef KORG_NODND
  QString text;
  QString vcards;

#ifndef KORG_NOKABC
  if ( KVCardDrag::decode( e, vcards ) ) {
    KABC::VCardConverter converter;

    KABC::Addressee::List list = converter.parseVCards( vcards );
    KABC::Addressee::List::Iterator it;
    for ( it = list.begin(); it != list.end(); ++it ) {
      QString em( (*it).fullEmail() );
      if (em.isEmpty()) {
        em=(*it).realName();
      }
      addAttendee( em );
    }
  } else
#endif // KORG_NOKABC
  if (QTextDrag::decode(e,text)) {
    kdDebug(5850) << "Dropped : " << text << endl;
    QStringList emails = QStringList::split(",",text);
    for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
      addAttendee(*it);
    }
  }
#endif //KORG_NODND
}
void KOAttendeeListView::dropEvent( QDropEvent *e )
{
    const QMimeData *md = e->mimeData();

    if ( KPIM::KVCardDrag::canDecode( md ) ) {
        KABC::Addressee::List list;
        KPIM::KVCardDrag::fromMimeData( md, list );

        KABC::Addressee::List::ConstIterator it;
        for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
            QString em( (*it).fullEmail() );
            if ( em.isEmpty() ) {
                em = (*it).realName();
            }
            addAttendee( em );
        }
    }

    if ( md->hasText() ) {
        QString text = md->text();
        kDebug() << "Dropped :" << text;
        QStringList emails = text.split( ',', QString::SkipEmptyParts );
        for ( QStringList::ConstIterator it = emails.constBegin(); it != emails.constEnd(); ++it ) {
            addAttendee( *it );
        }
    }
}
Exemplo n.º 5
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void IOSupport::addWarningMessage(const QString& filterName, const QString& warnDescription, int warnCode)
{
  PipelineMessage em(getNameOfClass(), warnDescription, warnCode, PipelineMessage::Warning);
  em.setFilterHumanLabel(getHumanLabel());
  em.setFilterClassName(getNameOfClass());
  m_PipelineMessages.push_back(em);
}
Exemplo n.º 6
0
void MarkSweep::mark_sweep_phase1(oop* p) {
  // Recursively traverse all live objects and mark them by reversing pointers.
  EventMarker em("1 reverse pointers");

  trace(" 1");

  WeakArrayRegister::begin_mark_sweep();
  Processes::convert_hcode_pointers();

  Universe::oops_do(&follow_root);

  // Hcode pointers point to the inside of methodOops and
  // have to be converted before we can follow the processes.
  Processes::follow_roots();

  WeakArrayRegister::check_and_follow_contents();
  NotificationQueue::oops_do(&follow_root);

  vmSymbols::follow_contents();

  // finalize unused objects - must be after all other gc_mark routines!
  Universe::symbol_table->follow_used_symbols();

  assert(stack->isEmpty(), "stack should be empty by now");
}
Exemplo n.º 7
0
TEST(NAME, AddingAndRemovingComponentsDispatchesEvents)
{
    World w;
    MockEntityManagerListener mock;
    EntityManager em(&w);
    em.event.addListener(&mock, "mock");

    // uninteresting calls
    EXPECT_CALL(mock, onEntitiesReallocatedHelper(testing::_))
        .Times(testing::AtLeast(0));
    EXPECT_CALL(mock, onCreateEntityHelper(testing::_))
        .Times(testing::AtLeast(0));
    EXPECT_CALL(mock, onDestroyEntityHelper(testing::_))
        .Times(testing::AtLeast(0));

    // interesting calls
    EXPECT_CALL(mock, onAddComponentHelper(testing::_, testing::Pointee(testing::Eq(TestComponent(336, 743)))))
        .Times(1);
    EXPECT_CALL(mock, onRemoveComponentHelper(testing::_, testing::Pointee(testing::Eq(TestComponent(254, 8376)))))
        .Times(1);

    Entity& e = em.createEntity("entity");
    e.addComponent<TestComponent>(336, 743);
    e.getComponent<TestComponent>().x = 254;
    e.getComponent<TestComponent>().y = 8376;
    e.removeComponent<TestComponent>();
    em.event.removeListener("mock");
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
    MainWindow* win;
    SvgView* view;

    QApplication app(argc, argv);

    QTranslator t;
    t.load(QString("simuduino_") + QLocale::system().name().section('_', 0, 0));
    app.installTranslator(&t);

    win = new MainWindow();
    view = win->getView();
    win->show();

    ElementManager em(view);

    // v.setPictureName("../images/chassis.svg");
    em.addElement("voiture", &v);

    setup();

    //while(true)
    {
        loop();
    }

    return app.exec();
}
Exemplo n.º 9
0
EMAlgorithm Bootstrap::run_em() {
    auto counts = mult_.sample();
    EMAlgorithm em(counts, index_, tc_, mean_fls_, opt);

    //em.set_start(em_start);
    em.run(10000, 50, false, false);
    /* em.compute_rho(); */

    return em;
}
Exemplo n.º 10
0
void MarkSweep::mark_sweep_phase2() {
  // Now all live objects are marked, compute the new object addresses.
  EventMarker em("2 compute new addresses");
  trace("2");

  OldWaterMark mark = Universe::old_gen.bottom_mark();
  // %note memory must be traversed in the same order as phase3
  Universe::old_gen.prepare_for_compaction(&mark);
  Universe::new_gen.prepare_for_compaction(&mark);
}
Exemplo n.º 11
0
int makeold(int argc,char **argv){
  if(argc<1){
    fprintf(stderr,"\t-> output is a vcf2fq style file \n");
    return 0; 
  }
  args *pars = getArgs(argc,argv);
  writepsmc_header(stderr,pars->perc);
  

  double *gls = new double[2*pars->perc->nSites];
  size_t at=0;
  //first pull all the data
  for(myMap::iterator it=pars->perc->mm.begin();it!=pars->perc->mm.end();++it){
    if(pars->chooseChr!=NULL)
      it = iter_init(pars->perc,pars->chooseChr,pars->start,pars->stop);
    else
      it = iter_init(pars->perc,it->first,pars->start,pars->stop);
    
    //    fprintf(stderr,"it->first:%s\tlast:%lu\n",it->first,pars->perc->last);
    memcpy(gls+at,pars->perc->gls,sizeof(double)*2*pars->perc->last);
    at += pars->perc->last;
    if(pars->chooseChr!=NULL)
      break;
  }
  double opt = 0.01;
  double llh = em(opt,gls,at,1e-8);
  fprintf(stderr,"estimated het:%f with llh:%f\n",opt,llh);
  delete [] gls;

  kstring_t kstr;kstr.l=kstr.m=0;kstr.s=NULL;
  for(myMap::iterator it=pars->perc->mm.begin();it!=pars->perc->mm.end();++it){
    if(pars->chooseChr!=NULL)
      it = iter_init(pars->perc,pars->chooseChr,pars->start,pars->stop);
    else
      it = iter_init(pars->perc,it->first,pars->start,pars->stop);
    ksprintf(&kstr,">%s\n",it->first);
    double *pp = new double[pars->perc->last];
    calcpost(opt,pars->perc->gls,pars->perc->last,pp);
    writefa(&kstr,pp,pars->perc->last,100,50,0.9);
    if(kstr.l>0&&kstr.s[kstr.l-1]!='\n')
      ksprintf(&kstr,"\n");
    fwrite(kstr.s,sizeof(char),kstr.l,stdout);
    kstr.l=0;
    delete [] pp;
    if(pars->chooseChr!=NULL)
      break;
  }
  free(kstr.s);
  /*
 
    break;
  */
  return 0;
}
EMAlgorithm Bootstrap::run_em(const EMAlgorithm& em_start) {
    auto counts = mult_.sample();
    auto weights = calc_weights(counts, ecmap_, eff_lens_);
    EMAlgorithm em(ecmap_, counts, target_names_, eff_lens_, weights);

    //em.set_start(em_start);
    em.run(10000, 20, false);
    /* em.compute_rho(); */

    return em;
}
Exemplo n.º 13
0
TEST(NAME, GetEntityByID)
{
    World w;
    EntityManager em(&w);
    Entity::ID a = em.createEntity("entity1").getID();
    Entity::ID b = em.createEntity("entity2").getID();
    Entity::ID c = em.createEntity("entity3").getID();
    
    ASSERT_EQ(std::string("entity1"), em.getEntity(a).getName());
    ASSERT_EQ(std::string("entity2"), em.getEntity(b).getName());
    ASSERT_EQ(std::string("entity3"), em.getEntity(c).getName());
}
Exemplo n.º 14
0
void NetworkController::trainNetwork(){
	DataDistribution datadu(network_, observations_);
	storeDiscretisedData("discretisedData.txt");
	datadu.assignObservationsToNodes();
	datadu.distributeObservations();
	EM em(network_, observations_, 0.001f, 100000);
	eMRuns_ = em.getNumberOfRuns();
	finalDifference_ = em.getDifference();
	likelihoodOfTheData_ = em.calculateLikelihoodOfTheData();
	timeInMicroSeconds_ = em.getTimeInMicroSeconds();
	network_.clearDynProgMatrices();
}
Exemplo n.º 15
0
int main(int argv, char** argc){
	// parse arguments
  dd::CmdParser cmd_parser = parse_input(argv, argc);

  // run gibbs sampler
  if(cmd_parser.app_name == "gibbs"){
    gibbs(cmd_parser);
  } else if (cmd_parser.app_name == "em") {
      em(cmd_parser);
  }

}
Exemplo n.º 16
0
void zone::flush() {
  ResourceMark rm;
  TraceTime   t("Flushing method cache...", PrintCodeReclamation);
  EventMarker em("flushing method cache");

  // Deoptimize all stack frames
  Processes::deoptimize_all();
 
  FOR_ALL_NMETHODS(p) { p->makeZombie(true); }
  flushZombies(false);

  verify_if_often();
}
Exemplo n.º 17
0
void MarkSweep::mark_sweep_phase3() {
  EventMarker em("3 compact heap");
  trace("3");
  OldWaterMark mark = Universe::old_gen.bottom_mark();
  mark._space->initialize_threshold();
  // %note memory must be traversed in the same order as phase2
  Universe::old_gen.compact(&mark);
  Universe::new_gen.compact(&mark);

  // All hcode pointers can now be restored. Remember
  // we converted these pointers in phase1.
  Processes::restore_hcode_pointers();
}
Exemplo n.º 18
0
void EdgeMatchSetFinder::addEdgeMatches(ConstNetworkEdgePtr e1, ConstNetworkEdgePtr e2)
{
  // recursively explore the edges that neighbor e1 and e2. All the discovered matches will be
  // recorded

  EdgeMatchPtr em(new EdgeMatch());

  bool reversed = _details->isReversed(e1, e2);
  em->getString1()->addFirstEdge(e1, false);
  em->getString2()->addFirstEdge(e2, reversed);

  _addEdgeMatches(em);
}
Exemplo n.º 19
0
void hook_call(const WHook *hk, void *p,
               WHookMarshall *m, WHookMarshallExtl *em)
{
    WHookItem *hi, *next;
    
    for(hi=hk->items; hi!=NULL; hi=next){
        next=hi->next;
        if(hi->fn!=NULL)
            m(hi->fn, p);
        else if(em!=NULL)
            em(hi->efn, p);
    }
}
Exemplo n.º 20
0
void QLCFixtureEditor::slotAddMode()
{
    EditMode em(_app, m_fixtureDef);
    em.setClipboard(m_physicalCopy);
    bool ok = false;
    while (ok == false)
    {
        if (em.exec() == QDialog::Accepted)
        {
            if (m_fixtureDef->mode(em.mode()->name()) != NULL)
            {
                QMessageBox::warning(this,
                                     tr("Unable to add mode"),
                                     tr("Another mode by that name already exists"));

                // User must rename the mode to continue
                ok = false;
            }
            else if (em.mode()->name().length() == 0)
            {
                QMessageBox::warning(this,
                                     tr("Unable to add mode"),
                                     tr("You must give a name to the mode"));
                ok = false;
            }
            else
            {
                /* Create new mode and an item for it */
                QTreeWidgetItem* item;
                QLCFixtureMode* mode;

                mode = new QLCFixtureMode(m_fixtureDef, em.mode());
                item = new QTreeWidgetItem(m_modeList);

                m_fixtureDef->addMode(mode);
                updateModeItem(mode, item);
                m_modeList->setCurrentItem(item);
                m_modeList->resizeColumnToContents(MODE_COL_NAME);

                setModified();
                ok = true;
            }
        }
        else
        {
            /* Cancel pressed */
            ok = true;
        }
    }
    m_physicalCopy = em.getClipboard();
}
Exemplo n.º 21
0
int main(int argc, const char* argv[]) {

    signal(SIGABRT,&abortFunc);
    signal(SIGTERM,&abortFunc);
    signal(SIGINT,&abortFunc);
    
    if(argc != 6) {
        printf("parse [grammar] [nBuckets] [nIter] [inputFile] [outputFile]\n");
        exit(-2);
    }

    printf("\n\n\t\tWELCOME TO THE BUCKET PARSER\n\n");
    
    const char* grammarFilename = argv[1];
    unsigned int nBuckets = atoi(argv[2]);
    unsigned int nIter = atoi(argv[3]);
    const char* trainFilename = argv[4];
    const char* outputFilename = argv[5];
    std::ifstream ifs(grammarFilename);
    if(!ifs.is_open()) {
        printf("Invalid file at %s\n",grammarFilename);
        exit(-2);
    }

    printf("%u buckets, %u iterations of EM\n",nBuckets,nIter);
    
    BucketGrammar g(ifs);
    BucketEM em(g,trainFilename,nBuckets);

    for(unsigned int i=0;i<nIter && cont;++i) {
        q = false;
        printf("%u - %e\n",i+1,em.emIter(true));
    }

    em.emIter(false);
    
    std::ofstream ofs(outputFilename);
    if(!ofs.is_open()) {
        printf("Invalid file at %s\n",outputFilename);
        exit(-2);
    }

    g.write(ofs);
    
    printf("\n\n\t\tTHANK YOU FOR PLAYING\n\n\t\t\tTHE END\n\n");
    
    return 0;
    
}
Exemplo n.º 22
0
int main() {
  char *out = doctype() html(
    head(
      meta(attr("charset", "UTF-8"))
      title("Hello World"))

    body(
      h1("Lorem Ipsum")
      p("Hello " span(attr("class", "important"), "world"))
      blockquote("This is " em("madness"))));

  puts(out);

  return 0;
}
Exemplo n.º 23
0
uint8_t DIA_gotoTime(uint16_t *hh, uint16_t *mm, uint16_t *ss)
{
uint32_t h=*hh,m=*mm,s=*ss;

diaElemUInteger   eh(&h,QT_TR_NOOP("_Hours:"),0,24);
diaElemUInteger   em(&m,QT_TR_NOOP("_Minutes:"),0,59);
diaElemUInteger   es(&s,QT_TR_NOOP("_Seconds:"),0,59);
        diaElem *allWidgets[]={&eh,&em,&es};

  if(!diaFactoryRun(QT_TR_NOOP("Go to Time"),3,allWidgets)) return 0;
    *hh=h;
    *mm=m;
    *ss=s;
    return 1;

}
Exemplo n.º 24
0
static int do_parent(int child, int terminal) {
  fd_set fds_read, fds_write, fds_error;
  int retval;

  /* Clear bit masks */
  FD_ZERO(&fds_read); FD_ZERO(&fds_write); FD_ZERO(&fds_error);
  /* Set read bits */
  FD_SET(terminal, &fds_read);
  FD_SET(terminal, &fds_write);
  
  /* Test if we can read or write from/to fd. As fd is opened read only we
   * cannot actually write, so the select should return immediately with fd
   * set in fds_write, but not in fds_read. Note that the child waits two
   * seconds before sending data. This gives us the opportunity run this
   * sub-test as reading from fd is blocking at this point. */
  retval = select(terminal+1, &fds_read, &fds_write, &fds_error, NULL);
  
  if(retval != 1) em(1, "incorrect amount of ready file descriptors");


  if(FD_ISSET(terminal, &fds_read)) em(2, "read should NOT be set");
  if(!FD_ISSET(terminal, &fds_write)) em(3, "write should be set");
  if(FD_ISSET(terminal, &fds_error)) em(4, "error should NOT be set");

  /* Block until ready; until child wrote stuff */
  FD_ZERO(&fds_read); FD_ZERO(&fds_write); FD_ZERO(&fds_error);
  FD_SET(terminal, &fds_read);
  retval = select(terminal+1, &fds_read, NULL, &fds_error, NULL);
 
  if(retval != 1) em(5, "incorrect amount of ready file descriptors");
  if(!FD_ISSET(terminal, &fds_read)) em(6, "read should be set");
  if(FD_ISSET(terminal, &fds_error)) em(7, "error should not be set");


  FD_ZERO(&fds_read); FD_ZERO(&fds_error);
  FD_SET(terminal, &fds_write);
  retval = select(terminal+1, NULL, &fds_write, NULL, NULL);
  /* As it is impossible to write to a read only fd, this select should return
   * immediately with fd set in fds_write. */
  if(retval != 1) em(8, "incorrect amount or ready file descriptors");

  close(terminal);
  waitpid(child, &retval, 0);
  exit(errct);
}
Exemplo n.º 25
0
nsresult nsPalmSyncSupport::GetPalmSyncInstall(nsILocalFile ** aLocalFile)
{
    nsresult rv;
    nsCOMPtr<nsIExtensionManager> em(do_GetService("@mozilla.org/extensions/manager;1"));
    NS_ENSURE_TRUE(em, NS_ERROR_FAILURE);

    nsCOMPtr<nsIInstallLocation> installLocation;
    rv = em->GetInstallLocation(NS_LITERAL_STRING(EXTENSION_ID), getter_AddRefs(installLocation));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIFile> palmSyncInstallExe;
    rv = installLocation->GetItemFile(NS_LITERAL_STRING(EXTENSION_ID), NS_LITERAL_STRING(EXECUTABLE_FILENAME), getter_AddRefs(palmSyncInstallExe));
    NS_ENSURE_SUCCESS(rv, rv);

    palmSyncInstallExe->QueryInterface(NS_GET_IID(nsILocalFile), (void **) aLocalFile);
    return rv;
}
Exemplo n.º 26
0
bool hook_call_alt(const WHook *hk, void *p,
                   WHookMarshall *m, WHookMarshallExtl *em)
{
    WHookItem *hi, *next;
    bool ret=FALSE;
    
    for(hi=hk->items; hi!=NULL; hi=next){
        next=hi->next;
        if(hi->fn!=NULL)
            ret=m(hi->fn, p);
        else if(em!=NULL)
            ret=em(hi->efn, p);
        if(ret)
            break;
    }
    
    return ret;
}
Exemplo n.º 27
0
void QLCFixtureEditor::slotAddMode()
{
	EditMode em(_app, m_fixtureDef);
	bool ok = false;
	while (ok == false)
	{
		if (em.exec() == QDialog::Accepted)
		{
			if (m_fixtureDef->mode(em.mode()->name()) != NULL)
			{
				QMessageBox::warning(
					this, 
					tr("Unable to add mode"),
					tr("Another mode by that name already exists"));
				
				// User must rename the mode to continue
				ok = false;
			}
			else if (em.mode()->name().length() == 0)
			{
				QMessageBox::warning(
					this, 
					tr("Unable to add mode"),
					tr("You must give a name to the mode"));
				
				ok = false;
			}
			else
			{
				ok = true;
				m_fixtureDef->addMode(
					new QLCFixtureMode(em.mode()));
				refreshModeList();
				setModified();
			}
		}
		else
		{
			ok = true;
		}
	}
}
Exemplo n.º 28
0
void train(int ntrees, int nspecies, int *gene_sizes,
           float **lengths, float *times,
           float *sp_alpha, float *sp_beta, 
           float *gene_alpha, float *gene_beta,
           int nrates, int max_iter)
{
    RatesEM em(ntrees, nspecies, nrates, gene_sizes, lengths, times,
               sp_alpha, sp_beta, *gene_alpha, *gene_beta);
    
    
    // make initial guess for model parameters
    em.init_params();
    
    // iterate until convergence
    for (int iter=0; iter<max_iter; iter++) {
        em.EStep();
        em.MStep();
    }
      
}
Exemplo n.º 29
0
void QLCFixtureEditor::slotEditMode()
{
    QLCFixtureMode* mode = currentMode();
    QTreeWidgetItem* item = NULL;

    if (mode == NULL)
        return;

    EditMode em(this, mode);
    em.setClipboard(m_physicalCopy);
    if (em.exec() == QDialog::Accepted)
    {
        *mode = *(em.mode());

        item = m_modeList->currentItem();
        updateModeItem(mode, item);
        setModified();
    }
    m_physicalCopy = em.getClipboard();
}
Exemplo n.º 30
0
        void run() {
            MmapV1ExtentManager em( "x", "x", false );

            ASSERT_EQUALS( em.maxSize(), em.quantizeExtentSize( em.maxSize() ) );

            // test that no matter what we start with, we always get to max extent size
            for ( int obj=16; obj<BSONObjMaxUserSize; obj += 111 ) {

                int sz = em.initialSize( obj );

                double totalExtentSize = sz;

                int numFiles = 1;
                int sizeLeftInExtent = em.maxSize() - 1;

                for ( int i=0; i<100; i++ ) {
                    sz = em.followupSize( obj , sz );
                    ASSERT( sz >= obj );
                    ASSERT( sz >= em.minSize() );
                    ASSERT( sz <= em.maxSize() );
                    ASSERT( sz <= em.maxSize() );

                    totalExtentSize += sz;

                    if ( sz < sizeLeftInExtent ) {
                        sizeLeftInExtent -= sz;
                    }
                    else {
                        numFiles++;
                        sizeLeftInExtent = em.maxSize() - sz;
                    }
                }
                ASSERT_EQUALS( em.maxSize(), sz );

                double allocatedOnDisk = (double)numFiles * em.maxSize();

                ASSERT( ( totalExtentSize / allocatedOnDisk ) > .95 );

                invariant( em.numFiles() == 0 );
            }
        }