MCPcopy Create free account
hub / github.com/PAIR-code/lit / __init__

Method __init__

lit_nlp/api/dataset.py:87–118  ·  view source on GitHub ↗

Base class constructor. This can derive from another dataset by passing the 'base' argument; if so it will pre-populate with those fields, and override only those specified individually as arguments. Args: spec: dataset spec examples: data examples (datapoints) de

(self,
               spec: Optional[Spec] = None,
               examples: Optional[list[JsonDict]] = None,
               description: Optional[str] = None,
               base: Optional['Dataset'] = None)

Source from the content-addressed store, hash-verified

85 _base: Optional['Dataset'] = None
86
87 def __init__(self,
88 spec: Optional[Spec] = None,
89 examples: Optional[list[JsonDict]] = None,
90 description: Optional[str] = None,
91 base: Optional['Dataset'] = None):
92 """Base class constructor.
93
94 This can derive from another dataset by passing the 'base' argument;
95 if so it will pre-populate with those fields, and override only those
96 specified individually as arguments.
97
98 Args:
99 spec: dataset spec
100 examples: data examples (datapoints)
101 description: optional human-readable description of this component
102 base: optional base dataset to derive from
103 """
104 self._base = base
105 if self._base is not None:
106 self._examples = self._base.examples
107 self._spec = self._base.spec()
108 self._description = self._base.description()
109 # In case user child class requires the instance to convert examples
110 # this makes sure the user class is preserved. We cannot do this below
111 # as the default method is static and does not require instance.
112 self.bytes_from_lit_example = self._base.bytes_from_lit_example
113 self.lit_example_from_bytes = self._base.lit_example_from_bytes
114
115 # Override from direct arguments.
116 self._examples = examples if examples is not None else self._examples
117 self._spec = spec or self._spec
118 self._description = description or self._description
119
120 def description(self) -> str:
121 """Return a human-readable description of this component.

Callers 1

__init__Method · 0.45

Calls 2

specMethod · 0.45
descriptionMethod · 0.45

Tested by

no test coverage detected