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

Function example__storing_features_in_a_collection

generator/pygen/example.py:10–37  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 3

MwmMethod · 0.80
formatMethod · 0.80
slowFunction · 0.70

Tested by

no test coverage detected