MCPcopy Create free account
hub / github.com/Vision-CAIR/VisualGPT / Example

Class Example

data/example.py:2–27  ·  view source on GitHub ↗

Defines a single training or test example. Stores each column of the example as an attribute.

Source from the content-addressed store, hash-verified

1
2class Example(object):
3 """Defines a single training or test example.
4 Stores each column of the example as an attribute.
5 """
6 @classmethod
7 def fromdict(cls, data):
8 ex = cls(data)
9 return ex
10
11 def __init__(self, data):
12 for key, val in data.items():
13 super(Example, self).__setattr__(key, val)
14
15 def __setattr__(self, key, value):
16 raise AttributeError
17
18 def __hash__(self):
19 return hash(tuple(x for x in self.__dict__.values()))
20
21 def __eq__(self, other):
22 this = tuple(x for x in self.__dict__.values())
23 other = tuple(x for x in other.__dict__.values())
24 return this == other
25
26 def __ne__(self, other):
27 return not self.__eq__(other)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected