How to use shape_graph method in localstack

Best Python code snippet using localstack_python

validator.py

Source: validator.py Github

copy

Full Screen

1#!/​usr/​bin/​env python2# -*- coding: utf-8 -*-3# author: houzhiwei4# time: 2020/​1/​5 17:565# https:/​/​github.com/​RDFLib/​pySHACL6from rdflib import Graph7from rdflib.util import guess_format8from pyshacl import validate, Validator9from datagraph import DataGraph10from utils import Utils11class GeoValidator(object):12 @staticmethod13 def read_graphs(*ont_graphs):14 """15 read and merge a set of ont graphs16 :param ont_graphs:17 :return: A merge of a set of RDF graphs18 """19 g = Graph()20 for ont in ont_graphs:21 f = guess_format(ont)22 g.parse(ont, format=f)23 return g24 @staticmethod25 def data_2_graph(parameter_id:str, data, data_theme=None, data_type=None):26 """27 read input data and generate RDF graph28 :param parameter_id: parameter identifier, indicates which parameter this data is prepared for29 :param data: input data path or value30 :param data_theme: data theme. e.g., DEM, soil, landuse, city, etc.31 :param data_type: automatically detect if is None. 0 for raster data; 1 for vector data; 2 for general (non-geospatial) data32 :return: data graph33 """34 _dg = DataGraph()35 if data_type is None:36 data_type = Utils.detect_data_type(data)37 # raster data38 if data_type == 0:39 graph = _dg.raster_graph(parameter_id, data, data_theme)40 # vector data41 elif data_type == 1:42 graph = _dg.vector_graph(parameter_id, data, data_theme)43 # non-geospatial data44 else:45 graph = _dg.general_graph(parameter_id, data, data_theme)46 return graph47 @staticmethod48 def validate_data(data_graph, shape_graph, ont=None):49 """50 validate_data input data against a predefined shape graph51 :param data_graph:52 :param shape_graph:53 :param ont:54 :return:55 """56 results = validate(data_graph, shacl_graph=shape_graph,57 ont_graph=ont, inference='rdfs', debug=False)58 # conforms, results_graph, results_text = results59 return results60 @staticmethod61 def advanced_validate(data_graph, shape_graph, ont=None):62 # enable SHACL advanced features: rules, custom targets63 results = validate(data_graph, shacl_graph=shape_graph, ont_graph=ont,64 advanced=True, inference='rdfs', debug=False)65 # conforms, results_graph, results_text = results66 # the results_graph just contains the validation report, not inferred triples67 return results68 @staticmethod69 def infer_with_extended_graph(data_graph, shacl_rule, ont=None):70 """71 use validate directly cannot get the inferred triples72 :param data_graph:73 :param shacl_rule:74 :param ont:75 :return:76 """77 v = Validator(data_graph=data_graph, shacl_graph=shacl_rule,78 options={"inference": "rdfs", "advanced": True}, ont_graph=ont)79 conforms, report_graph, report_text = v.run()80 # mixed in the extra-ontology graph81 expanded_graph = v.target_graph...

Full Screen

Full Screen

path.py

Source: path.py Github

copy

Full Screen

1from .bspline import Curve2Closed_BSpline2from .smoothen import smooth_spline3# Returns the slope of the line connecting two points4def slope(p0, p1):5 dx = p1[0] - p0[0]6 dy = p1[1] - p0[1]7 if dx == 0:8 return (9 dy * 9999999999999910 ) # Since dx is zero, we avoid division by zero. Instead, we multiply dy by a large number11 return 1.0 * dy /​ dx12class Path(object):13 # The path class encodes all the splines that are fit to a shape14 def __init__(self, shape_graph):15 self.path = self.make_path(shape_graph)16 self.shapes = set()17 def key(self):18 # This is the key used in the dict stored in the pixel graph19 return tuple(self.path)20 def make_path(self, shape_graph):21 # Creates the path and returns it22 nodes = set(shape_graph.nodes())23 path = [min(nodes)]24 neighbors = sorted(25 shape_graph.neighbors(path[0]), key=lambda p: slope(path[0], p)26 )27 path.append(neighbors[0])28 nodes.difference_update(29 path30 ) # This is equivalent to set difference between nodes and path31 # Go through the rest of the nodes and add nodes appropriately to the path32 p = path[-1]33 i = 034 while nodes:35 for neighbor in shape_graph.neighbors(path[-1]):36 if neighbor in nodes:37 nodes.remove(neighbor)38 path.append(neighbor)39 break40 if p != path[-1]:41 p = path[-1]42 i = 043 else:44 i += 145 if i == 3:46 break47 return path48 def make_spline(self):49 # Fit a spline to the path50 self.spline = Curve2Closed_BSpline(self.path)51 def smooth_spline(self):52 # Optimise the spline that is already fit to the path...

Full Screen

Full Screen

shapeImport.py

Source: shapeImport.py Github

copy

Full Screen

1import math2import networkx as nx3from ac_metro.importing.abstractImport import AbstractImport4class ShapeImport(AbstractImport):5 '''6 Load a shape graph from an Graphml file.7 '''8 @staticmethod9 def load(options: dict):10 print(f"Loading Shape with cost {options['shape_cost']}")11 if options['filepath'] is None:12 raise FileNotFoundError13 g_in = nx.read_graphml(options['filepath'])14 if 'x_attr' in options:15 x_attr = options['x_attr']16 else:17 x_attr = 'x'18 if 'y_attr' in options:19 y_attr = options['y_attr']20 else:21 y_attr = 'y'22 if 'id_start' in options:23 id_counter = options['id_start']24 else:25 id_counter = 026 shape_graph = nx.Graph()27 id_map = {}28 for v, data in g_in.nodes(data=True):29 x = float(data[x_attr])30 y = float(data[y_attr])31 id_map[v] = id_counter32 shape_graph.add_node(id_counter, x=x, y=y)33 id_counter += 134 for u, v, data in g_in.edges(data=True):35 shape_graph.add_edge(id_map[u], id_map[v], crossing=[],36 weight=options["shape_cost"] if "shape_cost" in options else 1)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful