MCPcopy Create free account
hub / github.com/comaps/comaps / example__storing_features_in_a_collection

Function example__storing_features_in_a_collection

tools/python/mwm/mwm_test.py:11–38  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

9
10
11def example__storing_features_in_a_collection(path):
12 ft_list = [ft for ft in mwm.Mwm(path)]
13 print(f"List size: {len(ft_list)}")
14
15 ft_tuple = tuple(ft for ft in mwm.Mwm(path))
16 print(f"Tuple size: {len(ft_tuple)}")
17
18 def slow():
19 ft_with_metadata_list = []
20 for ft in mwm.Mwm(path):
21 if ft.metadata():
22 ft_with_metadata_list.append(ft)
23 return ft_with_metadata_list
24
25 ft_with_metadata_list = slow()
26 print("Features with metadata:", len(ft_with_metadata_list))
27 print("First three are:", ft_with_metadata_list[:3])
28
29 def fast():
30 ft_with_metadata_list = []
31 for ft in mwm.Mwm(path, False):
32 if ft.metadata():
33 ft_with_metadata_list.append(ft.parse())
34 return ft_with_metadata_list
35
36 tslow = timeit.timeit(slow, number=10)
37 tfast = timeit.timeit(fast, number=10)
38 print(f"Slow took {tslow}, fast took {tfast}.")
39
40
41def example__features_generator(path):

Callers 1

mainFunction · 0.70

Calls 2

MwmMethod · 0.80
slowFunction · 0.70

Tested by

no test coverage detected