class _Document(object): (source)
Known subclasses: fiftyone.core.document.Document
, fiftyone.core.document.DocumentView
Constructor: _Document(doc, dataset)
Undocumented
Method | __contains__ |
Undocumented |
Method | __copy__ |
Undocumented |
Method | __delattr__ |
Undocumented |
Method | __delitem__ |
Undocumented |
Method | __dir__ |
Undocumented |
Method | __eq__ |
Undocumented |
Method | __getattr__ |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setattr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | clear |
Clears the value of a field of the document. |
Method | copy |
Returns a deep copy of the document that has not been added to the database. |
Method | get |
Gets the value of a field of the document. |
Method | has |
Determines whether the document has the given field. |
Method | iter |
Returns an iterator over the (name, value) pairs of the public fields of the document. |
Method | merge |
Merges the fields of the document into this document. |
Method | save |
Saves the document to the database. |
Method | set |
Sets the value of a field of the document. |
Method | to |
Serializes the document to a JSON dictionary. |
Method | to |
Serializes the document to a JSON string. |
Method | to |
Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database. |
Method | update |
Sets the dictionary of fields on the document. |
Property | dataset |
The dataset to which this document belongs, or None if it has not been added to a dataset. |
Property | field |
An ordered tuple of the public field names of this document. |
Property | in |
Whether the document has been added to a dataset. |
Method | _get |
Returns an ordered tuple of field names of this document. |
Method | _iter |
Undocumented |
Method | _parse |
Undocumented |
Method | _save |
Undocumented |
Instance Variable | _dataset |
Undocumented |
Instance Variable | _doc |
Undocumented |
Property | _collection |
The fiftyone.core.collections.SampleCollection from which this document was taken, or None if it is not in a dataset. |
Property | _id |
The ObjectId of the document, or None if it has not been added to the database. |
Property | _in |
Whether the document has been inserted into the database. |
fiftyone.core.document.DocumentView
Clears the value of a field of the document.
Parameters | |
field | the name of the field to clear |
Raises | |
AttributeError | if the field does not exist |
Returns a deep copy of the document that has not been added to the database.
Parameters | |
fields:None | an optional field or iterable of fields to which to restrict the copy. This can also be a dict mapping existing field names to new field names |
omitNone | an optional field or iterable of fields to exclude from the copy |
Returns | |
a Document |
fiftyone.core.document.DocumentView
Gets the value of a field of the document.
Parameters | |
field | the field name |
Returns | |
the field value | |
Raises | |
AttributeError | if the field does not exist |
fiftyone.core.document.DocumentView
Determines whether the document has the given field.
Parameters | |
field | the field name |
Returns | |
True/False |
Merges the fields of the document into this document.
The behavior of this method is highly customizable. By default, all
top-level fields from the provided document are merged in, overwriting
any existing values for those fields, with the exception of list fields
(e.g., tags) and label list fields (e.g.,
fiftyone.core.labels.Detections
fields), in which case the
elements of the lists themselves are merged. In the case of label list
fields, labels with the same id in both documents are updated
rather than duplicated.
To avoid confusion between missing fields and fields whose value is None, None-valued fields are always treated as missing while merging.
This method can be configured in numerous ways, including:
- Whether new fields can be added to the document schema
- Whether list fields should be treated as ordinary fields and merged as a whole rather than merging their elements
- Whether to merge only specific fields, or all but certain fields
- Mapping input document fields to different field names of this document
Parameters | |
document | a Document or DocumentView of the same
type |
fields:None | an optional field or iterable of fields to which to restrict the merge. This can also be a dict mapping field names of the input document to field names of this document |
omitNone | an optional field or iterable of fields to exclude from the merge |
mergeTrue | whether to merge the elements of top-level list
fields (e.g., tags) and label list fields (e.g.,
fiftyone.core.labels.Detections fields) rather than
merging the entire top-level field like other field types.
For label lists fields, existing
fiftyone.core.label.Label elements are either replaced
(when overwrite is True) or kept (when overwrite is
False) when their id matches a label from the provided
document |
overwrite:True | whether to overwrite (True) or skip (False) existing fields and label elements |
expandTrue | whether to dynamically add new fields encountered to the document schema. If False, an error is raised if any fields are not in the document schema |
validate:True | whether to validate values for existing fields |
dynamic:False | whether to declare dynamic embedded document fields |
Raises | |
AttributeError | if expand_schema == False and a field does not exist |
fiftyone.core.document.DocumentView
, fiftyone.core.frame.Frame
, fiftyone.core.sample.Sample
Saves the document to the database.
fiftyone.core.document.DocumentView
Sets the value of a field of the document.
Parameters | |
field | the field name |
value | the field value |
create:True | whether to create the field if it does not exist |
validate:True | whether to validate values for existing fields |
dynamic:False | whether to declare dynamic embedded document fields |
Raises | |
ValueError | if field_name is not an allowed field name |
AttributeError | if the field does not exist and create == False |
fiftyone.core.document.DocumentView
Serializes the document to a JSON dictionary.
Parameters | |
includeFalse | whether to include private fields |
Returns | |
a JSON dict |
Serializes the document to a JSON string.
The document ID and private fields are excluded in this representation.
Parameters | |
prettyFalse | whether to render the JSON in human readable format with newlines and indentations |
Returns | |
a JSON string |
fiftyone.core.document.DocumentView
Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database.
Parameters | |
includeFalse | whether to include the document ID |
Returns | |
a BSON dict |
Sets the dictionary of fields on the document.
Parameters | |
fields | a dict mapping field names to values |
expandTrue | whether to dynamically add new fields encountered to the document schema. If False, an error is raised if any fields are not in the document schema |
validate:True | whether to validate values for existing fields |
dynamic:False | whether to declare dynamic embedded document fields |
Raises | |
AttributeError | if expand_schema == False and a field does not exist |
fiftyone.core.document.DocumentView
An ordered tuple of the public field names of this document.
fiftyone.core.document.DocumentView
The fiftyone.core.collections.SampleCollection
from which
this document was taken, or None if it is not in a dataset.