class DocumentView(_Document): (source)
Known subclasses: fiftyone.core.frame.FrameView
, fiftyone.core.sample.SampleView
Constructor: DocumentView(doc, view, selected_fields, excluded_fields, filtered_fields)
A view into a Document
in a dataset.
Like Document
instances, the fields of a DocumentView
instance can be modified, new fields can be created, and any changes can be
saved to the database.
DocumentView
instances differ from Document
instances
in the following ways:
- A document view may contain only a subset of the fields of its source document, either by selecting and/or excluding specific fields
- A document view may contain array fields or embedded array fields that have been filtered, thus containing only a subset of the array elements from the source document
- Excluded fields of a document view may not be accessed or modified
Note
DocumentView.save
will not delete any excluded fields or
filtered array elements from the source document.
Document views should never be created manually; they are generated when
accessing the contents of a fiftyone.core.view.DatasetView
.
Parameters | |
doc | a fiftyone.core.odm.document.Document |
view | the fiftyone.core.view.DatasetView that the document
belongs to |
selected | a set of field names that this document view is restricted to, if any |
excluded | a set of field names that are excluded from this document view, if any |
filtered | a set of field names of array fields that are filtered in this document view, if any |
Method | __init__ |
Undocumented |
Method | __repr__ |
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 | save |
Saves the document view 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 BSON dictionary equivalent to the representation that would be stored in the database. |
Property | excluded |
The set of field names that are excluded on this document view, or None if no fields are explicitly excluded. |
Property | field |
An ordered tuple of field names of this document view. |
Property | filtered |
The set of field names or embedded.field.names that have been filtered on this document view, or None if no fields are filtered. |
Property | selected |
The set of field names that are selected on this document view, or None if no fields are explicitly selected. |
Method | _get |
Returns an ordered tuple of field names of this document. |
Method | _reload |
Undocumented |
Method | _save |
Undocumented |
Method | _to |
Undocumented |
Instance Variable | _excluded |
Undocumented |
Instance Variable | _filtered |
Undocumented |
Instance Variable | _selected |
Undocumented |
Instance Variable | _view |
Undocumented |
Property | _collection |
The fiftyone.core.collections.SampleCollection from which this document was taken, or None if it is not in a dataset. |
Inherited from _Document
:
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 | __setattr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | __str__ |
Undocumented |
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 | to |
Serializes the document to a JSON string. |
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 | in |
Whether the document has been added to a dataset. |
Method | _iter |
Undocumented |
Method | _parse |
Undocumented |
Instance Variable | _dataset |
Undocumented |
Instance Variable | _doc |
Undocumented |
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.sample.SampleView
Undocumented
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 |
fiftyone.core.document._Document.copy
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 |
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 |
Determines whether the document has the given field.
Parameters | |
field | the field name |
Returns | |
True/False |
fiftyone.core.document._Document.save
fiftyone.core.sample.SampleView
Saves the document view to the database.
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._Document.to_dict
fiftyone.core.sample.SampleView
Serializes the document to a JSON dictionary.
Parameters | |
includeFalse | whether to include private fields |
Returns | |
a JSON dict |
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 |
The set of field names that are excluded on this document view, or None if no fields are explicitly excluded.
An ordered tuple of field names of this document view.
This may be a subset of all fields of the document if fields have been selected or excluded.
The set of field names or embedded.field.names that have been filtered on this document view, or None if no fields are filtered.
The set of field names that are selected on this document view, or None if no fields are explicitly selected.
fiftyone.core.document._Document._save
fiftyone.core.sample.SampleView
Undocumented
The fiftyone.core.collections.SampleCollection
from which
this document was taken, or None if it is not in a dataset.