Пример #1
0
def decompositionview(request):
    ### do something here ##
    para= False
    if request.method=='POST':
        form=DecompositionForm(request.POST,request.FILES)
        if form.is_valid():
            form.save()
            obj=Decomposition.objects.all()[len(Decomposition.objects.all())-1]
            decompose(obj.document.name)
            para =True
    else : 
        form =DecompositionForm()
    return render(request, 'forecast/decomposition.html',  {
        'form': form, 'para': para,
    })
Пример #2
0
def test_decompose():
    n = 48      # 2^4 * 3
    facteurs = decompose.decompose(n)
    facteurs_reduits = decompose.reduit_polynome(facteurs)
    assert facteurs == [2, 2, 2, 2, 3]
    assert facteurs_reduits == ['2^4', '3']

    assert decompose.decompose(4) == [2, 2]
    assert decompose.decompose(34866) == [2, 3, 3, 13, 149]
    assert decompose.decompose(2017) == [2017]
    assert decompose.decompose(65537) == [65537]
    for i in primes:
        assert decompose.decompose(i) == [i]
Пример #3
0
def plan_complete_coverage_mission(params):
    # Extract lists of exterior and interior points
    exterior = [(point["lat"], point["lon"]) for point in params["exterior"]]
    interiors = []
    for obstacle in params["obstacles"]:
        interiors.append([(point["lat"], point["lon"]) for point in obstacle])

    # Convert lists from latitude/longitude to meters relative to the
    # home point, which will be (0, 0) in the new coordinate frame
    home = (params["home"]["lat"], params["home"]["lon"])
    coordtransform.latlon_to_meters(exterior, home)
    for interior in interiors:
        coordtransform.latlon_to_meters(interior, home)

    # Generate a shapely Polygon representing the field
    polygon = Polygon(exterior, interiors)

    # Decompose the polygon into cells and trapezoids
    # Note that the cells and traps returned will be rotated by angle
    # degrees about the point (0, 0)
    cells, traps, angle = decompose.decompose(polygon)

    # Generate adjacencey graphs for the cells and trapezoids
    cellgrapher.build_graph(cells)
    cellgrapher.build_graph(traps)

    # Determine which cell contains the home point
    for start_cell in cells:
        if start_cell.polygon.contains(Point(0, 0)):
            break
    else:
        raise Exception("Home point is not within polygon")

    # Starting with that cell, find a sequence that travels through
    # the graph of cells, visiting all of them at least once
    stack = celllinker.optimal(start_cell, cells)

    # Based on this sequence, generate a detailed path that can be
    # used by a drone to cover the entirety of the given polygon
    rotated_polygon = shapely.affinity.rotate(polygon,
                                              angle,
                                              origin=Point(0, 0))
    path = oxpath.generate_path(stack, params["radius"], rotated_polygon,
                                traps)

    # Rotate this path back to the original orientation
    path.rotate(-angle, Point(0, 0))

    # Consolidate an ordered list of the waypoints that make up the
    # path (including while covering a given cell, and while
    # transitioning between cells, with no distinction between the
    # two for the moment)
    waypoints = []
    for i in range(0, path.cells_traversed()):
        waypoints += path.transitions[i].waypoints
        waypoints += path.cells[i].waypoints
    waypoints += path.transitions[i + 1].waypoints

    mission = {
        "waypoints": [{
            "x": waypoint.x,
            "y": waypoint.y
        } for waypoint in waypoints]
    }

    # Return a dictionary with some data structures that allow the
    # client to generate a visualization of the algorithm's output
    visualization_data = {
        'polygon': polygon,
        'waypoints': waypoints,
        'cells': cells,
        'traps': traps,
        'stack': stack,
        'angle': angle,
        'path': path
    }

    return (visualization_data, mission)
Пример #4
0
def plan_complete_coverage_mission(params):
    # Extract lists of exterior and interior points
    exterior = [(point["lat"], point["lon"])
                    for point in params["exterior"]]
    interiors = []
    for obstacle in params["obstacles"]:
        interiors.append([(point["lat"], point["lon"])
                             for point in obstacle])

    # Convert lists from latitude/longitude to meters relative to the
    # home point, which will be (0, 0) in the new coordinate frame
    home = (params["home"]["lat"], params["home"]["lon"])
    coordtransform.latlon_to_meters(exterior, home)
    for interior in interiors:
        coordtransform.latlon_to_meters(interior, home)

    # Generate a shapely Polygon representing the field
    polygon = Polygon(exterior, interiors)

    # Decompose the polygon into cells and trapezoids
    # Note that the cells and traps returned will be rotated by angle
    # degrees about the point (0, 0)
    cells, traps, angle = decompose.decompose(polygon)

    # Generate adjacencey graphs for the cells and trapezoids
    cellgrapher.build_graph(cells)
    cellgrapher.build_graph(traps)

    # Determine which cell contains the home point
    for start_cell in cells:
        if start_cell.polygon.contains(Point(0, 0)):
            break
    else:
        raise Exception("Home point is not within polygon")

    # Starting with that cell, find a sequence that travels through
    # the graph of cells, visiting all of them at least once
    stack = celllinker.optimal(start_cell, cells)

    # Based on this sequence, generate a detailed path that can be
    # used by a drone to cover the entirety of the given polygon
    rotated_polygon = shapely.affinity.rotate(
        polygon, angle, origin=Point(0, 0))
    path = oxpath.generate_path(stack, params["radius"],
                                rotated_polygon, traps)

    # Rotate this path back to the original orientation
    path.rotate(-angle, Point(0, 0))

    # Consolidate an ordered list of the waypoints that make up the
    # path (including while covering a given cell, and while
    # transitioning between cells, with no distinction between the
    # two for the moment)
    waypoints = []
    for i in range(0, path.cells_traversed()):
        waypoints += path.transitions[i].waypoints
        waypoints += path.cells[i].waypoints
    waypoints += path.transitions[i+1].waypoints

    mission = {
        "waypoints": [
            {
                "x": waypoint.x,
                "y": waypoint.y
            } for waypoint in waypoints
        ]
    }

    # Return a dictionary with some data structures that allow the
    # client to generate a visualization of the algorithm's output
    visualization_data = {
        'polygon': polygon,
        'waypoints': waypoints,
        'cells': cells,
        'traps': traps,
        'stack': stack,
        'angle': angle,
        'path': path
    }

    return (visualization_data, mission)
Пример #5
0
 def test_german_sharp_s(self):
     print(f"ß {self.ligatures.upper().lower()}")
     self.assertEqual('ss', decompose('ß'))
     self.assertEqual('SS', decompose('ẞ'))
Пример #6
0
 def test_capitalized_ligatures(self):
     self.assertEqual('Oe', decompose(u'\N{Latin capital ligature OE}'))
     self.assertEqual('Ae', decompose(u'\N{Latin capital letter AE}'))
Пример #7
0
 def test_ligatures(self):
     self.assertEqual(self.decomposed_ligatures, decompose(self.ligatures))
Пример #8
0
 def test_capitalized_diacritics(self):
     self.assertEqual(self.decomposed_diacritics.upper(),
                      decompose(self.diacritics.upper()))
Пример #9
0
 def test_diacritics(self):
     self.assertEqual(self.decomposed_diacritics,
                      decompose(self.diacritics))
 def test(self):
     self.assertEqual(decompose(12), [1, 2, 3, 7, 9])
     self.assertEqual(decompose(6), None)
     self.assertEqual(decompose(50), [1, 3, 5, 8, 49])
     self.assertEqual(decompose(44), [2, 3, 5, 7, 43])
     self.assertEqual(decompose(625), [2, 5, 8, 34, 624])
     self.assertEqual(decompose(5), [3, 4])
     self.assertEqual(decompose(7100), [2, 3, 5, 119, 7099])
     self.assertEqual(decompose(123456), [1, 2, 7, 29, 496, 123455])
     self.assertEqual(decompose(1234567), [2, 8, 32, 1571, 1234566])
     self.assertEqual(decompose(7654321), [6, 10, 69, 3912, 7654320])
     self.assertEqual(decompose(4), None)
     self.assertEqual(decompose(7654322), [1, 4, 11, 69, 3912, 7654321])
Пример #11
0
 def getgetCommonSpace(self,k, max_iter=6000, alpha=0.5):
     sigAdict,sigBdict = self.__getCommonSpacePoint()
     W,H = decompose(self.__commonSpacePoint,k,max_iter,alpha)
     return W,H,sigAdict,sigBdict
Пример #12
0
 def __getDict (self):
     sigADict,_ = decompose(np.abs(self.__signalASTFT), k=SPEECH_RANK)
     sigBdict,_ = decompose(np.abs(self.__signalBSTFT), k=SPEECH_RANK)
     return sigADict,sigBdict
Пример #13
0
 def __getIndividDict(self):
     value = get_spec(self.__signal)
     self.__individDict,_ = decompose(np.abs(value), k=SPEECH_RANK)