示例#1
0
 def test_polygon_lenght(self):
     params = {'distance': 3000}
     link_strategy = Polygon(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     self.assertEqual(len(dataset.index), 9)
示例#2
0
 def test_empty_polygon(self):
     params = {'distance': 3}
     link_strategy = Polygon(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     self.assertEqual(dataset.size, 0)
示例#3
0
 def test_closest_point_lenght_no_filter(self):
     params = {'filter': False, 'distance': 0}
     link_strategy = ClosestPoint(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     self.assertEqual(len(dataset.index), 3)
示例#4
0
 def test_empty_closest_point(self):
     params = {'filter': True, 'distance': 3}
     link_strategy = ClosestPoint(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     self.assertEqual(dataset.size, 0)
示例#5
0
def layers_configuration(request, pk_a, pk_b):
    popup_data = request.data['popup_data']
    colours = request.data['colours']
    name = request.data['name']
    description = request.data['description']
    App.save_layers_configuration(pk_a, pk_b, popup_data, colours, name,
                                  description)
    return Response(data={"result": "ok"}, status=status.HTTP_200_OK)
示例#6
0
def link_similarity_preview(request, pk_a, pk_b):
    rules = request.data['rules']
    results = App.link_files_similarity_preview(pk_a, pk_b, {'rules': rules})
    [data, cols] = App.make_response_link(results)
    return Response(data={
        "data": data,
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#7
0
def link_polygon_preview(request, pk_a, pk_b, max_distance):
    params = {'distance': max_distance / 1000}
    results = App.link_files_polygon_preview(pk_a, pk_b, params)
    [data, cols] = App.make_response_link(results)
    return Response(data={
        "data": data,
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#8
0
def link_closest_point_preview(request, pk_a, pk_b):
    params = {'distance': 0, 'filter': False}
    results = App.link_files_closest_point_preview(pk_a, pk_b, params)
    [data, cols] = App.make_response_link(results)
    return Response(data={
        "data": data,
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#9
0
 def test_polygon(self):
     params = {'distance': 3000}
     link_strategy = Polygon(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     linked_file = App.link_polygon(self.gf1.get_id(), self.gf2.get_id(), "name", "description", params)
     dataset_linked = linked_file.get_data()
     pd.testing.assert_frame_equal(dataset, dataset_linked)
示例#10
0
 def test_closest_point(self):
     params = {'distance': 0, 'filter': False}
     link_strategy = ClosestPoint(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     linked_file = App.link_closest_points(self.gf1.get_id(), self.gf2.get_id(), "name", "description", params)
     dataset_linked = linked_file.get_data()
     pd.testing.assert_frame_equal(dataset, dataset_linked)
示例#11
0
 def test_link_similarity_same_y_column(self):
     r_1 = Rule('verificado', 'JURISDICCI', [{"Verificado": "PROV"}])
     r_2 = Rule('valorVinchuca', 'JURISDICCI', [{"patagonica": "PROV"}])
     rules = [r_1, r_2]
     params = {'rules': rules}
     link_strategy = Similarity(params)
     ds_a = App.get_ds(self.gf1.get_id())
     ds_b = App.get_ds(self.gf2.get_id())
     dataset = link_strategy.link(ds_a, ds_b)
     self.assertTrue(len(dataset.index) == 1)
示例#12
0
def link_polygon(request, pk_a, pk_b, max_distance, name, description):
    params = {'distance': max_distance / 1000}
    linked_file = App.link_polygon(pk_a, pk_b, name, description, params)
    [data, cols] = App.make_response_link(linked_file.get_data())
    return Response(data={
        "data": data,
        "id": linked_file.get_id(),
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#13
0
def link_similarity(request, pk_a, pk_b, name, description):
    rules = request.data['rules']
    linked_file = App.link_similarity(pk_a, pk_b, name, description,
                                      {'rules': rules})
    [data, cols] = App.make_response_link(linked_file.get_data())
    return Response(data={
        "data": data,
        "id": linked_file.get_id(),
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#14
0
def link_closest_point(request, pk_a, pk_b, name, description):
    params = {'distance': 0, 'filter': False}
    linked_file = App.link_closest_points(pk_a, pk_b, name, description,
                                          params)
    [data, cols] = App.make_response_link(linked_file.get_data())
    return Response(data={
        "data": data,
        "id": linked_file.get_id(),
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#15
0
def link_closest_point_filter(request, pk_a, pk_b, max_distance, name,
                              description):
    # create the strategy
    params = {'distance': max_distance / 1000, 'filter': True}
    linked_file = App.link_closest_points(pk_a, pk_b, name, description,
                                          params)
    [data, cols] = App.make_response_link(linked_file.get_data())
    return Response(data={
        "data": data,
        "id": linked_file.get_id(),
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#16
0
def clusterize_meanshift_preview(request, pk_ids, col_a, col_b):
    results = App.clusterize_meanshift_preview(pk_ids, col_a, col_b)
    [centroids, labels, data, cluster_size, cats,
     cols] = App.make_response_cluster(results)
    return Response(data={
        "centroids": centroids,
        "labels": labels,
        "data": data,
        "cluster_size": cluster_size,
        "cats": cats,
        "cols": cols
    },
                    status=status.HTTP_200_OK)
示例#17
0
 def test_categorize_uncategorize_values(self):
     dataset = App.get_ds(self.gf2.get_id()).get_data()
     cat_col = Categorizer.categorize_column(dataset, 'p1')
     dataset['p1_cat'] = cat_col
     cat_value = dataset.iloc[0]['p1_cat']
     real_value = dataset.iloc[0]['p1']
     uncat_value = Categorizer.uncategorize_value(dataset, 'p1', cat_value)
     self.assertEqual(real_value, uncat_value)
示例#18
0
def get_clusterization(request, pk_conf):
    [
        name, description, col_a, col_b, cols, data, strategy, labels,
        centroids, lat_col, lon_col, cats
    ] = App.get_cluster_configuration(pk_conf)
    return Response(data={
        "name": name,
        "description": description,
        "col_a": col_a,
        "col_b": col_b,
        "data": data,
        "strategy": strategy,
        "cols": cols,
        "cats": cats,
        "cluster_size": len(centroids),
        "centroids": centroids,
        "labels": labels,
        "lat": lat_col,
        "lon": lon_col
    },
                    status=status.HTTP_200_OK)
示例#19
0
def get_clusterizations(request):
    confs = App.get_clusterizations()
    serializer = ConfigurationSerializer(confs, many=True)
    return JsonResponse(serializer.data, safe=False)
示例#20
0
 def test_get_details(self):
     ds_a = App.get_ds(self.gf.get_id())
     details = ds_a.get_details()
     self.assertEqual(details['name'], 'geofile test')
     self.assertEqual(details['description'], 'description')
     self.assertEqual(details['doc'], 'test_files/GeoVin_sample.csv')
示例#21
0
 def test_categorize_column_long(self):
     dataset = App.get_ds(self.gf2.get_id()).get_data()
     cat_col = Categorizer.categorize_column(dataset, 'p1')
     uncat_col = dataset[['p1']]
     self.assertEqual(len(cat_col), len(uncat_col))
示例#22
0
def clusterize_kmeans(request, pk_ids, name, description, col_a, col_b, k=3):
    results = App.clusterize_kmeans(name, description, pk_ids, col_a, col_b, k)
    return Response(data={"results": "OK"}, status=status.HTTP_200_OK)
示例#23
0
def get_ds_details(request, pk_ids):
    details = App.get_details(pk_ids)
    return Response(data={"details": details}, status=status.HTTP_200_OK)
示例#24
0
def get_configuration(request, pk_conf):
    conf = App.get_configuration(pk_conf)
    return Response(data={"conf": conf}, status=status.HTTP_200_OK)
示例#25
0
def data_files(request):
    files = App.get_data_files()
    serializer = IDataSourceSerializer(files, many=True)
    return JsonResponse(serializer.data, safe=False)