Пример #1
0
    def test_add_galaxy(self):
        before = Galaxy.objects.count()

        db = DbController()
        db.add_galaxy("assdf", True, True)

        self.assertEqual(Galaxy.objects.count(), before + 1)
Пример #2
0
    def test_returns_false_if_all_labelled(self):
        db = DbController()
        galaxies = Galaxy.objects.all()
        for galaxy in galaxies:
            galaxy.human_label = True
            galaxy.save()

        galaxy = db.next_unlabeled_galaxy()
        self.assertFalse(galaxy)
Пример #3
0
    def test_update_affirmation_label_false(self):
        new_galaxy = Galaxy.objects.create(file_url="somefile",
                                           affirmation=None)
        new_galaxy.save()
        id = new_galaxy.id

        db = DbController()
        db.update_machine_affirmation(id, 0)

        my_galaxy = Galaxy.objects.get(id=id)
        self.assertFalse(my_galaxy.affirmation)
Пример #4
0
    def test_update_human_label_true(self):
        new_galaxy = Galaxy.objects.create(file_url="somefile",
                                           human_label=None)
        new_galaxy.save()
        id = new_galaxy.id

        db = DbController()
        db.update_human_label(id, 1)

        my_galaxy = Galaxy.objects.get(id=id)
        self.assertTrue(my_galaxy.human_label)
Пример #5
0
    def test_unlabeled_galaxy_has_no_human_label(self):
        db = DbController()
        galaxy = db.next_unlabeled_galaxy()

        self.assertIsNone(galaxy.human_label)
Пример #6
0
    def test_gets_unlabeled_galaxies(self):
        db = DbController()
        galaxy = db.next_unlabeled_galaxy()

        self.assertIsInstance(galaxy, Galaxy)
Пример #7
0
import os
from django.shortcuts import render

from tinder.src.DbController import DbController
from tinder.src.PlotBuilder import PlotBuilder
from tinder.src.FitsLoader import FitsLoader

from tinder.models import Galaxy

controller = DbController()


def generate_plot(galaxy):
    xs, ys = FitsLoader().load_fits(
        os.path.join(galaxy.original_root_extension, galaxy.file_url))
    div = PlotBuilder().build(xs, ys)

    return div


def index(request):
    return render(request, 'about.html')


def labeller(request):
    if request.method == "POST":
        is_wr = request.POST['is_wr']
        id = request.POST['id']

        if is_wr != "SKIP":
            controller.update_human_label(id, is_wr)