MCPcopy Create free account
hub / github.com/CyberPoint/libpgm / load

Method load

libpgm/nodedata.py:48–95  ·  view source on GitHub ↗

Load node data from an input file located at *path*. Input file must be a plaintext .txt file with a JSON-style representation of a dict. The dict must have the top-level key ``Vdata`` or two top-level keys, ``initial_Vdata`` and ``twotbn_Vdata``. For example:: {

(self, path)

Source from the content-addressed store, hash-verified

46
47
48 def load(self, path):
49 '''
50 Load node data from an input file located at *path*. Input file must be a plaintext .txt file with a JSON-style representation of a dict. The dict must have the top-level key ``Vdata`` or two top-level keys, ``initial_Vdata`` and ``twotbn_Vdata``. For example::
51
52 {
53 "Vdata": {
54 "<vertex 1>": <dict containing vertex 1 data>,
55 ...
56 "<vertex n>": <dict containing vertex n data>
57 }
58 }
59
60 or::
61
62 {
63 "initial_Vdata": {
64 "<vertex 1>": <dict containing vertex 1 data>,
65 ...
66 "<vertex n>": <dict containing vertex n data>
67 }
68 "twotbn_Vdata": {
69 "<vertex 1>": <dict containing vertex 1 data>,
70 ...
71 "<vertex n>": <dict containing vertex n data>
72 }
73 }
74
75 The function takes the following arguments:
76 1. *path* -- The path to the text file that contains input data (e.g., "mydictionary.txt")
77
78 In the static case, it modifies *Vdata* to hold the dictionary found at path. In the dynamic case, it modifies the *initial_Vdata* and *twotbn_Vdata* attributes to hold the dictionaries found at path.
79
80 ''&#x27;
81 self.dictload(path)
82
83 # try to load both for normal and dynamic cases
84 try:
85 self.Vdata = self.alldata["Vdata"]
86 except KeyError:
87 try:
88 self.initial_Vdata = self.alldata["initial_Vdata"]
89 self.twotbn_Vdata = self.alldata["twotbn_Vdata"]
90 except KeyError:
91 print "Error: NodeData did not recognize input file format."
92
93
94 # free unused memory
95 del self.alldata
96
97 def entriestoinstances(self):
98 ''&#x27;

Callers 15

timerFunction · 0.95
timerFunction · 0.95
setUpMethod · 0.95
setUpMethod · 0.95
setUpMethod · 0.95
setUpMethod · 0.95
setUpMethod · 0.95
setUpMethod · 0.95
list_edgesFunction · 0.45
list_nodesFunction · 0.45
list_nodedataFunction · 0.45
add_edgeFunction · 0.45

Calls 1

dictloadMethod · 0.80

Tested by 10

setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.76
setUpMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36