コード例 #1
0
ファイル: test_reject.py プロジェクト: ajstewart/tkp
 def test_unknownreason(self):
     with self.assertRaises(IntegrityError):
         dbqual.reject(self.image.id,
                       Rejectreason(id=666666, description="foobar"),
                       comment="bad reason",
                       session=self.session)
         self.session.flush()
コード例 #2
0
 def test_unknownreason(self):
     with self.assertRaises(IntegrityError):
         dbqual.reject(self.image.id,
                       Rejectreason(id=666666, description="foobar"),
                       comment="bad reason",
                       session=self.session)
         self.session.flush()
コード例 #3
0
 def test_rejectrms_and_unreject(self):
     dbqual.reject(self.image.id, dbqual.reject_reasons['rms'],
                   "10 times too high", self.session)
     image_rejections_q = self.session.query(Rejection).filter(
         Rejection.image_id == self.image.id)
     self.assertEqual(image_rejections_q.count(), 1)
     dbqual.unreject(self.image.id, self.session)
     self.assertEqual(image_rejections_q.count(), 0)
コード例 #4
0
ファイル: test_reject.py プロジェクト: ajstewart/tkp
 def test_rejectrms_and_unreject(self):
     dbqual.reject(self.image.id,
                   dbqual.reject_reasons['rms'],
                   "10 times too high",
                   self.session)
     image_rejections_q = self.session.query(Rejection).filter(
         Rejection.image_id == self.image.id)
     self.assertEqual(image_rejections_q.count(), 1)
     dbqual.unreject(self.image.id, self.session)
     self.assertEqual(image_rejections_q.count(), 0)
コード例 #5
0
    def test_isrejected(self):
        dbqual.unreject(self.image.id, self.session)
        self.assertFalse(dbqual.isrejected(self.image.id, self.session))

        rms_reason = dbqual.reject_reasons['rms']
        comment = "10 times too high"

        reason_comment_str = "{}: {}".format(rms_reason.description, comment)
        dbqual.reject(self.image.id, rms_reason, comment, self.session)
        self.assertEqual(dbqual.isrejected(self.image.id, self.session),
                         [reason_comment_str])
コード例 #6
0
ファイル: test_reject.py プロジェクト: jdswinbank/tkp
    def test_rejected_initial_image(self):
        """
        An image which is rejected should not be taken into account when
        deciding whether a patch of sky has been previously observed, and
        hence whether any detections in that area are (potential) transients.

        Here, we create a database with two images. The first
        (choronologically) is rejected; the second contains a source. That
        source should not be marked as a transient.
        """

        dataset = tkp.db.DataSet(
            data={'description': "Trans:" + self._testMethodName},
            database=tkp.db.Database())

        # We use a dataset with two images
        # NB the routine in db_subs automatically increments time between
        # images.
        n_images = 2
        db_imgs = [
            tkp.db.Image(data=im_params, dataset=dataset) for im_params in
            db_subs.generate_timespaced_dbimages_data(n_images)
        ]

        # The first image is rejected for an arbitrary reason
        # (for the sake of argument, we use an unacceptable RMS).
        db_quality.reject(imageid=db_imgs[0].id,
                          reason=db_quality.reject_reasons['rms'],
                          comment=self._testMethodName,
                          session=self.session)
        # Have to commit here: old DB code makes queries in a separate transaction.
        self.session.commit()

        # Since we rejected the first image, we only find a source in the
        # second.
        source = db_subs.example_extractedsource_tuple()
        insert_extracted_sources(db_imgs[1]._id, [source])

        # Standard source association procedure etc.
        associate_extracted_sources(db_imgs[1].id,
                                    deRuiter_r=3.7,
                                    new_source_sigma_margin=3)

        # Our source should _not_ be a transient. That is, there should be no
        # entries in the newsource table for this dataset.
        cursor = tkp.db.execute(
            """\
            SELECT t.id FROM newsource t, runningcatalog rc
                    WHERE t.runcat = rc.id
                      AND rc.dataset = %(ds_id)s
            """, {"ds_id": dataset.id})
        self.assertEqual(cursor.rowcount, 0)
コード例 #7
0
ファイル: test_reject.py プロジェクト: transientskp/tkp
    def test_rejected_initial_image(self):
        """
        An image which is rejected should not be taken into account when
        deciding whether a patch of sky has been previously observed, and
        hence whether any detections in that area are (potential) transients.

        Here, we create a database with two images. The first
        (choronologically) is rejected; the second contains a source. That
        source should not be marked as a transient.
        """

        dataset = tkp.db.DataSet(data={"description": "Trans:" + self._testMethodName}, database=tkp.db.Database())

        # We use a dataset with two images
        # NB the routine in db_subs automatically increments time between
        # images.
        n_images = 2
        db_imgs = [
            tkp.db.Image(data=im_params, dataset=dataset)
            for im_params in db_subs.generate_timespaced_dbimages_data(n_images)
        ]

        # The first image is rejected for an arbitrary reason
        # (for the sake of argument, we use an unacceptable RMS).
        db_quality.reject(
            imageid=db_imgs[0].id,
            reason=db_quality.reject_reasons["rms"],
            comment=self._testMethodName,
            session=self.session,
        )
        # Have to commit here: old DB code makes queries in a separate transaction.
        self.session.commit()

        # Since we rejected the first image, we only find a source in the
        # second.
        source = db_subs.example_extractedsource_tuple()
        insert_extracted_sources(db_imgs[1]._id, [source])

        # Standard source association procedure etc.
        associate_extracted_sources(db_imgs[1].id, deRuiter_r=3.7, new_source_sigma_margin=3)

        # Our source should _not_ be a transient. That is, there should be no
        # entries in the newsource table for this dataset.
        cursor = tkp.db.execute(
            """\
            SELECT t.id FROM newsource t, runningcatalog rc
                    WHERE t.runcat = rc.id
                      AND rc.dataset = %(ds_id)s
            """,
            {"ds_id": dataset.id},
        )
        self.assertEqual(cursor.rowcount, 0)
コード例 #8
0
ファイル: test_reject.py プロジェクト: ajstewart/tkp
    def test_isrejected(self):
        dbqual.unreject(self.image.id, self.session)
        self.assertFalse(dbqual.isrejected(self.image.id, self.session))

        rms_reason = dbqual.reject_reasons['rms']
        comment = "10 times too high"

        reason_comment_str = "{}: {}".format(rms_reason.description, comment)
        dbqual.reject(self.image.id,
                      rms_reason,
                      comment,
                      self.session)
        self.assertEqual(dbqual.isrejected(self.image.id, self.session),
                         [ reason_comment_str ])
コード例 #9
0
ファイル: test_reject.py プロジェクト: ajstewart/tkp
 def test_all_reasons_present_in_database(self):
     for reason in dbqual.reject_reasons.values():
         dbqual.reject(self.image.id, reason, "comment", self.session)
         dbqual.unreject(self.image.id, self.session)
コード例 #10
0
 def test_all_reasons_present_in_database(self):
     for reason in dbqual.reject_reasons.values():
         dbqual.reject(self.image.id, reason, "comment", self.session)
         dbqual.unreject(self.image.id, self.session)