Esempio n. 1
0
    def test_compatibility_3(self):
        # Same box size, different cutoff
        box1 = np.ones(3) * 5.0
        box2 = np.ones(3) * 5.0

        point1 = np.array([[0.5, 0.5, 0.5]])
        point2 = np.array([[1.0, 1.0, 1.0]])

        cg1 = CellGrid(box1, 0.5, point1)
        cg2 = CellGrid(box2, 0.25, point2)

        assert_raises(ValueError, cellgrid_distance_array, cg1, cg2)
Esempio n. 2
0
    def test_compatibility_2(self):
        # Same box volume, will have differing number of cells in
        # each dimension
        box1 = np.array([2.0, 3.0, 4.0])
        box2 = np.array([4.0, 2.0, 3.0])

        point1 = np.array([[0.5, 0.5, 0.5]])
        point2 = np.array([[1.0, 1.0, 1.0]])

        cg1 = CellGrid(box1, 0.5, point1)
        cg2 = CellGrid(box2, 0.5, point2)

        assert_raises(ValueError, cellgrid_distance_array, cg1, cg2)
Esempio n. 3
0
    def test_compatibility_1(self):

        # Different box sizes, should raise ValueError
        box1 = np.ones(3)
        box2 = np.ones(3) * 5.0

        point1 = np.array([[0.5, 0.5, 0.5]])
        point2 = np.array([[1.0, 1.0, 1.0]])

        cg1 = CellGrid(box1, 0.5, point1)
        cg2 = CellGrid(box2, 0.5, point2)

        assert_raises(ValueError, cellgrid_distance_array, cg1, cg2)
Esempio n. 4
0
    def test_capped_periodic(self):
        for prec in self.precs:
            box = (np.ones(3) * 10).astype(prec)

            point1 = np.array([[0.5, 1.0, 1.0]]).astype(prec)
            point2 = np.array([[9.5, 1.0, 1.0]]).astype(prec)

            cg1 = CellGrid(box, 1.0, point1)
            cg2 = CellGrid(box, 1.0, point2)

            idx, dists = cellgrid_distance_array(cg1, cg2)

            assert (idx[0] == (0, 0)).all()
            assert dists[0] == 1.0
Esempio n. 5
0
    def test_capped_partial(self):
        for prec in self.precs:
            # 3 x 3 x 3 box
            box = (np.ones(3) * 3).astype(prec)
            # Equally spaced points from 0.5 to 2.5
            grid = (np.array(list(np.ndindex(3, 3, 3))) + 0.5).astype(prec)
            # A single point to use to check who it sees
            # this is in the bottom corner of the box
            probe = np.array([[1.0, 1.0, 1.0]]).astype(prec)

            cg1 = CellGrid(box, 0.5, grid)
            cg2 = CellGrid(box, 0.5, probe)

            idx, dists = cellgrid_distance_array(cg1, cg2)

            # Probe should have seen 8 points
            assert len(dists) == 8
Esempio n. 6
0
    def test_capped_3(self):
        for prec in self.precs:
            # 27 points in the corner of a
            # 10 x 10 x 10 box
            # put probe in middle and see only 27
            box = (np.ones(3) * 10).astype(prec)
            # Equally spaced points from 0.5 to 2.5
            grid = (np.array(list(np.ndindex(10, 10, 10))) + 0.5).astype(prec)
            # A single point to use to check who it sees
            # this is in the bottom corner of the box
            probe = (np.array([[1.0, 1.0, 1.0]])).astype(prec)

            cg1 = CellGrid(box, 1.0, grid)
            cg2 = CellGrid(box, 1.0, probe)

            idx, dists = cellgrid_distance_array(cg1, cg2)

            # Probe should have seen 27 points
            assert len(dists) == 27
Esempio n. 7
0
from cellgrid import CellGrid
from cell import Cell
from coord import Coord
from configreader import ConfigReader
import route
import json
import datetime
config = ConfigReader("settings.conf")
api_key = config.apikey
grid = CellGrid(Coord(39.0095, -77.16796),
                Coord(38.8044, -76.89331),
                grid_width=5,
                grid_height=5)
with open('gridfeaturecounts.json', 'r') as featurecounts_per_cell:
    javascript_analysis_results_json = featurecounts_per_cell.read().replace(
        '\n', '')

grid.load_javascript_analysis_json(javascript_analysis_results_json)
grid.generate_scaled_scores_zero_to_one()
print(grid.to_geojson())
Esempio n. 8
0
RandomPopulate.grid(row=0, column=0)
Logic = Button(frame,
               text="Demonstrate Logic Gates",
               command=lambda: popupmsg())
Logic.grid(row=0, column=2)
# And = Button(frame, text = "AND", command = AndPressed  )
# And.grid(row = 1, column = 2, sticky = "E")
# Or = Button(frame, text = "OR", command = orPressed)
# Or.grid(row = 1, column = 2)
# Not = Button(frame, text = "NOT", command = NotPressed)
# Not.grid(row = 1, column = 2, sticky = "W")
# Next = Button(frame, text = "Next Generation", command = update)
Next = Button(frame,
              text="Next Generation",
              repeatdelay=1,
              repeatinterval=1,
              command=update)
Next.grid(row=0, column=1)
Clear = Button(frame, text="Clear Memory", command=clear)
Clear.grid(row=0, column=3)
Exit = Button(frame, text="Exit", command=lambda: gui.destroy())
Exit.grid(row=0, column=4)
grid = CellGrid(gui, board_height, board_width, 10)
grid.pack()

# Or.configure(state = "disabled")
# Not.configure(state = "disabled")
# And.configure(state = "disabled")

gui.mainloop()
Esempio n. 9
0
def cg_method(a, b, box, d_max):
    cga = CellGrid(box, d_max, a)
    cgb = CellGrid(box, d_max, b)
    return capped_distance_array(cga, cgb)
Esempio n. 10
0
config = ConfigReader("settings.conf")
api_key = config.apikey

#start_loc = Coord(38.9975396, -76.9546925)
#end_loc = Coord(40.7143528, -74.0059731)
#routefinder = Routefinder(api_key)

#route = routefinder.find_route(start_loc, end_loc)
#for coord in route.coord_list:
#    print(coord.lat, coord.lon)
#print(route.length_miles)

# ----------- Route and Javascript generation -------------------

grid = CellGrid(Coord(39.0095, -77.16796),
                Coord(38.8044, -76.89331),
                grid_width=5,
                grid_height=5)
#print(grid.to_geojson())

grid_routes = grid.get_routes_for_all_cells()

routes_by_cell = [
]  # A list where each element is a list of routes for one cell
all_routes = []  # A list of all routes for every cell

# Populate routes_by_cell and all_routes
for currentcellroutes in grid_routes:
    routes_by_cell.append(route.route_list_to_geojson(currentcellroutes))
    for rte in currentcellroutes:
        all_routes.append(rte)