Ejemplo n.º 1
0
 def populate_list_pending(self):
     self.pending_assignments = fio.load('assignments')
     self.past_assignments = fio.load('completed_assignments')
     for item in self.pending_assignments:
         item.update_time_till_due()
     sorted_data = sort_assignments(self.pending_assignments)
     self.populate_list(sorted_data)
Ejemplo n.º 2
0
 def test_loads(self):
     file_io.save('temp.npy', self.Mat)
     Loaded = file_io.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, info_header.InfoArray))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
     self.assertEqual(Loaded.info['b'], self.Mat.info['b'])
     self.assertAlmostEqual(Loaded.info['c'], self.Mat.info['c'])
Ejemplo n.º 3
0
 def test_loads(self):
     file_io.save('temp.npy', self.Mat)
     Loaded = file_io.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, info_header.InfoArray))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
     self.assertEqual(Loaded.info['b'], self.Mat.info['b'])
     self.assertAlmostEqual(Loaded.info['c'], self.Mat.info['c'])
Ejemplo n.º 4
0
    def test_to_from_file(self):
        """Test that vects and mats can be written to and from file and have
        all thier properties preserved."""
        # For vectors.
        file_io.save('temp.npy', self.vect)
        new_vect = vector.vect_array(file_io.load('temp.npy'))
        self.assertTrue(sp.allclose(self.vect, new_vect))
        self.assertEqual(self.vect.axes, new_vect.axes)

        # For matricies.
        file_io.save('temp.npy', self.mat)
        new_mat = matrix.mat_array(file_io.load('temp.npy'))
        self.assertTrue(sp.allclose(self.mat, new_mat))
        self.assertEqual(self.mat.axes, new_mat.axes)

        # Messing with stuf should raise exceptions.
        new_mat = file_io.load('temp.npy')
        new_mat.info['cols'] = (0, 3)
        self.assertRaises(ValueError, matrix.mat_array, new_mat)

        # Clean up
        os.remove('temp.npy')
        os.remove('temp.npy.meta')
Ejemplo n.º 5
0
    def test_to_from_file(self):
        """Test that vects and mats can be written to and from file and have
        all thier properties preserved."""
        # For vectors.
        file_io.save('temp.npy', self.vect)
        new_vect = vector.vect_array(file_io.load('temp.npy'))
        self.assertTrue(sp.allclose(self.vect, new_vect))
        self.assertEqual(self.vect.axes, new_vect.axes)

        # For matricies.
        file_io.save('temp.npy', self.mat)
        new_mat = matrix.mat_array(file_io.load('temp.npy'))
        self.assertTrue(sp.allclose(self.mat, new_mat))
        self.assertEqual(self.mat.axes, new_mat.axes)

        # Messing with stuf should raise exceptions.
        new_mat = file_io.load('temp.npy')
        new_mat.info['cols'] = (0, 3)
        self.assertRaises(ValueError, matrix.mat_array, new_mat)

        # Clean up
        os.remove('temp.npy')
        os.remove('temp.npy.meta')
Ejemplo n.º 6
0
    def test_memmap_write(self):
        marray = file_io.open_memmap('temp.npy', mode="w+",
                                     shape=self.Mat.shape,
                                     dtype=self.Mat.dtype,
                                     )

        marray[:] = self.Mat[:]
        marray.info = self.Mat.info
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        self.assertTrue(sp.allclose(Loaded, self.Mat))
        self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Ejemplo n.º 7
0
    def test_memmap_write(self):
        marray = file_io.open_memmap(
            'temp.npy',
            mode="w+",
            shape=self.Mat.shape,
            dtype=self.Mat.dtype,
        )

        marray[:] = self.Mat[:]
        marray.info = self.Mat.info
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        self.assertTrue(sp.allclose(Loaded, self.Mat))
        self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Ejemplo n.º 8
0
def main_loop():

    balance_sheet = file_io.load_balance('balance_sheet.csv')
    player = file_io.load(chosenplayer)
    #print (player)
    init = player[0]
    building_list = player[1]
    UIDlist = player[2]
    money, pollution, trash = init
    # print(init)
    #print(building_list)
    #print(UIDlist)
    frame = 0
    crashed = False
    gameDisplay.fill(white)
    while not crashed:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                crashed = True
            # print(event)

        button("Build", 150, 472, 100, 50, red, bright_red, quitgame)
        #button("Upgrade", 250, 472, 100, 50, red, bright_red, quitgame)
        value_bar(524, 460, 100, 20, money, 800, green, black, white, border_thickness=1)
        value_bar(524, 490, 100, 20, pollution, 800, green, black, white, border_thickness=1)
        value_bar(644, 460, 100, 20, trash, 800, green, black, white, border_thickness=1)
        drawMap(1)
        frame = frame + 1
        if frame == 60:  # Clock divider because threading is hard
            money, pollution, trash = kernel.simulate(
                UIDlist, building_list, balance_sheet, money, pollution, trash)
            if money <= 0 or pollution >= 100 or trash >= 100:
                print("Game over")
                break
            #print('Money is: '+str(money))
            # print('Pollution is: '+ str(pollution)).
            #print('Trash is: '+ str(trash))
            frame = 0
        # print(secondframe)
#        bar(150, 200, 100, 20, green,black,white,3, frame,'100/100')
        #print(frame)
        pygame.display.update()
        clock.tick(60)
Ejemplo n.º 9
0
    def test_memmap_write_view(self):
        marray = file_io.open_memmap('temp.npy', mode="w+",
                                     shape=self.Mat.shape,
                                     dtype=self.Mat.dtype,
                                     )

        # Work with a higher level view, make sure se can deal with it.
        # This is testing a bug I had earlier where base data's were
        # overwriting the meta data of higher level objects.
        inf = marray.info
        marray = marray.view(info_header.InfoMemmap)
        inf2 = marray.info
        marray[:] = self.Mat[:]
        marray.info.update(self.Mat.info)
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        self.assertTrue(sp.allclose(Loaded, self.Mat))
        self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Ejemplo n.º 10
0
    def test_memmap_write_view(self):
        marray = file_io.open_memmap(
            'temp.npy',
            mode="w+",
            shape=self.Mat.shape,
            dtype=self.Mat.dtype,
        )

        # Work with a higher level view, make sure se can deal with it.
        # This is testing a bug I had earlier where base data's were
        # overwriting the meta data of higher level objects.
        inf = marray.info
        marray = marray.view(info_header.InfoMemmap)
        inf2 = marray.info
        marray[:] = self.Mat[:]
        marray.info.update(self.Mat.info)
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        self.assertTrue(sp.allclose(Loaded, self.Mat))
        self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Ejemplo n.º 11
0
def main_loop():

    balance_sheet = file_io.load_balance('balance_sheet.csv')
    player = file_io.load(chosenplayer)
    #print (player)
    init = player[0]
    building_list = player[1]
    UIDlist = player[2]
    money, pollution, trash = init
    # print(init)
    #print(building_list)
    #print(UIDlist)
    frame = 0
    crashed = False
    gameDisplay.fill(white)
    while not crashed:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                crashed = True
            # print(event)

        button("Build", 150, 472, 100, 50, red, bright_red, quitgame)
        #button("Upgrade", 250, 472, 100, 50, red, bright_red, quitgame)
        value_bar(524,
                  460,
                  100,
                  20,
                  money,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        value_bar(524,
                  490,
                  100,
                  20,
                  pollution,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        value_bar(644,
                  460,
                  100,
                  20,
                  trash,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        drawMap(1)
        frame = frame + 1
        if frame == 60:  # Clock divider because threading is hard
            money, pollution, trash = kernel.simulate(UIDlist, building_list,
                                                      balance_sheet, money,
                                                      pollution, trash)
            if money <= 0 or pollution >= 100 or trash >= 100:
                print("Game over")
                break
            #print('Money is: '+str(money))
            # print('Pollution is: '+ str(pollution)).
            #print('Trash is: '+ str(trash))
            frame = 0
        # print(secondframe)


#        bar(150, 200, 100, 20, green,black,white,3, frame,'100/100')
#print(frame)
        pygame.display.update()
        clock.tick(60)
Ejemplo n.º 12
0
building_add = []
UIDlist = []
money = 10
pollution = 0
trash = 0
init = 0
asdf = 0
chosenplayer = "asdf"

# load balance sheet

balance_sheet = file_io.load_balance("balance_sheet.csv")

# load savefilev for testing

player = file_io.load(chosenplayer)
print(player)
init = player[0]
building_list = player[1]
UIDlist = player[2]
money, pollution, trash = init
# print(init)
# print(building_list)
# print(UIDlist)d

# test buildingctl.addbuilding - Add building

player = buildingctl.addbuilding(player, balance_sheet, "power_plant", 1, 2)
print(player)

# UIDlist,building_list,money = building_add
Ejemplo n.º 13
0
building_add = []
UIDlist = []
money = 10
pollution = 0
trash = 0
init = 0
asdf = 0
chosenplayer = 'asdf'

#load balance sheet

balance_sheet = file_io.load_balance('balance_sheet.csv')

#load savefilev for testing

player = file_io.load(chosenplayer)
print(player)
init = player[0]
building_list = player[1]
UIDlist = player[2]
money, pollution, trash = init
#print(init)
#print(building_list)
#print(UIDlist)d

#test buildingctl.addbuilding - Add building

player = buildingctl.addbuilding(player, balance_sheet, 'power_plant', 1, 2)
print(player)

#UIDlist,building_list,money = building_add
Ejemplo n.º 14
0
 def load_data(self):
     return fio.load("assignments")