A ViewExpression
that refers to a field or embedded field of a
document.
You can use dot notation to refer to subfields of embedded objects within fields.
When you create a ViewField
using a string field like
ViewField("embedded.field.name"), the meaning of this field is
interpreted relative to the context in which the ViewField
object
is used. For example, when passed to the ViewExpression.map
method,
this object will refer to the embedded.field.name object of the array
element being processed.
In other cases, you may wish to create a ViewField
that always
refers to the root document. You can do this by prepending "$" to the
name of the field, as in ViewField("$embedded.field.name").
Examples:
from fiftyone import ViewField as F # Reference the root of the current context F() # Reference the `ground_truth` field in the current context F("ground_truth") # Reference the `label` field of the `ground_truth` object in the # current context F("ground_truth.label") # Reference the root document in any context F("$") # Reference the `label` field of the root document in any context F("$label") # Reference the `label` field of the `ground_truth` object in the root # document in any context F("$ground_truth.label")
Parameters | |
name | the name of the field, with an optional "$" prepended if you wish to freeze this field to the root document |
Method | __deepcopy__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | to |
Returns a MongoDB representation of the field. |
Inherited from ViewExpression
:
Static Method | all |
Checks whether all of the given expressions evaluate to True. |
Static Method | any |
Checks whether any of the given expressions evaluate to True. |
Static Method | enumerate |
Returns an array of [index, element] pairs enumerating the elements of the given expression, which must resolve to an array. |
Static Method | literal |
Returns an expression representing the given value without parsing. |
Static Method | rand |
Returns an expression that generates a uniform random float in [0, 1] each time it is called. |
Static Method | randn |
Returns an expression that generates a sample from the standard Gaussian distribution each time it is called. |
Static Method | range |
Returns an array expression containing the sequence of integers from the specified start (inclusive) to stop (exclusive). |
Static Method | zip |
Zips the given expressions, which must resolve to arrays, into an array whose ith element is an array containing the ith element from each input array. |
Method | __abs__ |
Computes the absolute value of this expression, which must resolve to a numeric value. |
Method | __add__ |
Adds the given value to this expression, which must resolve to a numeric value, self + other. |
Method | __and__ |
Computes the logical AND of this expression and the given value or expression, self & other. |
Method | __call__ |
Retrieves the specified field or embedded field of this expression, which must resolve to a document. |
Method | __ceil__ |
Computes the ceiling of this expression, which must resolve to a numeric value. |
Method | __eq__ |
Determines whether this expression is equal to the given value or expression, self == other. |
Method | __floor__ |
Computes the floor of this expression, which must resolve to a numeric value. |
Method | __ge__ |
Determines whether this expression is greater than or equal to the given value or expression, self >= other. |
Method | __getitem__ |
Returns the element or slice of this expression, which must resolve to an array. |
Method | __gt__ |
Determines whether this expression is greater than the given value or expression, self >= other. |
Method | __hash__ |
Undocumented |
Method | __invert__ |
Inverts this expression, ~self. |
Method | __le__ |
Determines whether this expression is less than or equal to the given value or expression, self <= other. |
Method | __len__ |
Undocumented |
Method | __lt__ |
Determines whether this expression is less than the given value or expression, self <= other. |
Method | __mod__ |
Computes the modulus of this expression, which must resolve to a numeric value, self % other. |
Method | __mul__ |
Computes the product of the given value and this expression, which must resolve to a numeric value, self * other. |
Method | __ne__ |
Determines whether this expression is not equal to the given value or expression, self != other. |
Method | __or__ |
Computes the logical OR of this expression and the given value or expression, self | other. |
Method | __pow__ |
Raises this expression, which must resolve to a numeric value, to the given power, self ** power. |
Method | __radd__ |
Undocumented |
Method | __rand__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __rmod__ |
Undocumented |
Method | __rmul__ |
Undocumented |
Method | __ror__ |
Undocumented |
Method | __round__ |
Rounds this expression, which must resolve to a numeric value, at the given decimal place. |
Method | __rsub__ |
Undocumented |
Method | __rtruediv__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | __sub__ |
Subtracts the given value from this expression, which must resolve to a numeric value, self - other. |
Method | __truediv__ |
Divides this expression, which must resolve to a numeric value, by the given value, self / other. |
Method | abs |
Computes the absolute value of this expression, which must resolve to a numeric value. |
Method | append |
Appends the given value to this expression, which must resolve to an array. |
Method | apply |
Applies the given expression to this expression. |
Method | arccos |
Computes the inverse cosine of this expression, which must resolve to a numeric value, in radians. |
Method | arccosh |
Computes the inverse hyperbolic cosine of this expression, which must resolve to a numeric value, in radians. |
Method | arcsin |
Computes the inverse sine of this expression, which must resolve to a numeric value, in radians. |
Method | arcsinh |
Computes the inverse hyperbolic sine of this expression, which must resolve to a numeric value, in radians. |
Method | arctan |
Computes the inverse tangent of this expression, which must resolve to a numeric value, in radians. |
Method | arctanh |
Computes the inverse hyperbolic tangent of this expression, which must resolve to a numeric value, in radians. |
Method | cases |
Applies a case statement to this expression, which effectively computes the following pseudocode: |
Method | ceil |
Computes the ceiling of this expression, which must resolve to a numeric value. |
Method | concat |
Concatenates the given string(s) to this expression, which must resolve to a string. |
Method | contains |
Checks whether this expression, which must resolve to an array, contains any of the given values. |
Method | contains |
Determines whether this expression, which must resolve to a string, contains the given string or string(s). |
Method | cos |
Computes the cosine of this expression, which must resolve to a numeric value, in radians. |
Method | cosh |
Computes the hyperbolic cosine of this expression, which must resolve to a numeric value, in radians. |
Method | day |
Returns the day of the month of this date expression (in UTC) as a number between 1 and 31. |
Method | day |
Returns the day of the week of this date expression (in UTC) as a number between 1 (Sunday) and 7 (Saturday). |
Method | day |
Returns the day of the year of this date expression (in UTC) as a number between 1 and 366. |
Method | difference |
Computes the set difference of this expression, which must resolve to an array, and the given array or array expression. |
Method | ends |
Determines whether this expression, which must resolve to a string, ends with the given string or string(s). |
Method | exists |
Determines whether this expression, which must resolve to a field, exists and is not None. |
Method | exp |
Raises Euler's number to this expression, which must resolve to a numeric value. |
Method | extend |
Concatenates the given array(s) or array expression(s) to this expression, which must resolve to an array. |
Method | filter |
Applies the given filter to the elements of this expression, which must resolve to an array. |
Method | floor |
Computes the floor of this expression, which must resolve to a numeric value. |
Method | hour |
Returns the hour portion of this date expression (in UTC) as a number between 0 and 23. |
Method | if |
Returns either true_expr or false_expr depending on the value of this expression, which must resolve to a boolean. |
Method | insert |
Inserts the value before the given index in this expression, which must resolve to an array. |
Method | intersection |
Computes the set intersection of this expression, which must resolve to an array, and the given array(s) or array expression(s). |
Method | is |
Determines whether this expression is an array. |
Method | is |
Creates an expression that returns a boolean indicating whether self in values. |
Method | is |
Determines whether this expression refers to a missing field. |
Method | is |
Determines whether this expression is null. |
Method | is |
Determines whether this expression is a number. |
Method | is |
Determines whether this expression is a string. |
Method | is |
Checks whether this expression's contents, which must resolve to an array, are a subset of the given array or array expression's contents. |
Method | join |
Joins the elements of this expression, which must resolve to a string array, by the given delimiter. |
Method | length |
Computes the length of this expression, which must resolve to an array. |
Method | let |
Returns an equivalent expression where this expression is defined as a variable that is used wherever necessary in the given expression. |
Method | ln |
Computes the natural logarithm of this expression, which must resolve to a numeric value. |
Method | log |
Computes the logarithm base base of this expression, which must resolve to a numeric value. |
Method | log10 |
Computes the logarithm base 10 of this expression, which must resolve to a numeric value. |
Method | lower |
Converts this expression, which must resolve to a string, to lowercase. |
Method | lstrip |
Removes whitespace characters from the beginning of this expression, which must resolve to a string. |
Method | map |
Applies the given expression to the elements of this expression, which must resolve to an array. |
Method | map |
Replaces this expression with the corresponding value in the provided mapping dict, if it is present as a key. |
Method | matches |
Determines whether this expression, which must resolve to a string, exactly matches the given string or string(s). |
Method | max |
Returns the maximum value of either this expression, which must resolve to an array, or the maximum of this expression and the given value. |
Method | mean |
Returns the average value in this expression, which must resolve to a numeric array. |
Method | millisecond |
Returns the millisecond portion of this date expression (in UTC) as an integer between 0 and 999. |
Method | min |
Returns the minimum value of either this expression, which must resolve to an array, or the minimum of this expression and the given value. |
Method | minute |
Returns the minute portion of this date expression (in UTC) as a number between 0 and 59. |
Method | month |
Returns the month of this date expression (in UTC) as a number between 1 and 12. |
Method | pow |
Raises this expression, which must resolve to a numeric value, to the given power, self ** power. |
Method | prepend |
Prepends the given value to this expression, which must resolve to an array. |
Method | re |
Performs a regular expression pattern match on this expression, which must resolve to a string. |
Method | reduce |
Applies the given reduction to this expression, which must resolve to an array, and returns the single value computed. |
Method | replace |
Replaces all occurrences of old with new in this expression, which must resolve to a string. |
Method | reverse |
Reverses the order of the elements in the expression, which must resolve to an array. |
Method | round |
Rounds this expression, which must resolve to a numeric value, at the given decimal place. |
Method | rsplit |
Splits this expression, which must resolve to a string, by the given delimiter. |
Method | rstrip |
Removes whitespace characters from the end of this expression, which must resolve to a string. |
Method | second |
Returns the second portion of this date expression (in UTC) as a number between 0 and 59. |
Method | set |
Checks whether this expression, which must resolve to an array, contains the same distinct values as each of the given array(s) or array expression(s). |
Method | set |
Sets the specified field or embedded field of this expression, which must resolve to a document, to the given value or expression. |
Method | sin |
Computes the sine of this expression, which must resolve to a numeric value, in radians. |
Method | sinh |
Computes the hyperbolic sine of this expression, which must resolve to a numeric value, in radians. |
Method | sort |
Sorts this expression, which must resolve to an array. |
Method | split |
Splits this expression, which must resolve to a string, by the given delimiter. |
Method | sqrt |
Computes the square root of this expression, which must resolve to a numeric value. |
Method | starts |
Determines whether this expression, which must resolve to a string, starts with the given string or string(s). |
Method | std |
Returns the standard deviation of the values in this expression, which must resolve to a numeric array. |
Method | strip |
Removes whitespace characters from the beginning and end of this expression, which must resolve to a string. |
Method | strlen |
Computes the length of this expression, which must resolve to a string. |
Method | substr |
Extracts the specified substring from this expression, which must resolve to a string. |
Method | sum |
Returns the sum of the values in this expression, which must resolve to a numeric array. |
Method | switch |
Applies a switch statement to this expression, which effectively computes the given pseudocode: |
Method | tan |
Computes the tangent of this expression, which must resolve to a numeric value, in radians. |
Method | tanh |
Computes the hyperbolic tangent of this expression, which must resolve to a numeric value, in radians. |
Method | to |
Converts the expression to a boolean value. |
Method | to |
Converts the expression to a date value. |
Method | to |
Converts the expression to a double precision value. |
Method | to |
Converts the expression to an integer value. |
Method | to |
Converts the expression to a string value. |
Method | trunc |
Truncates this expression, which must resolve to a numeric value, at the specified decimal place. |
Method | type |
Returns the type string of this expression. |
Method | union |
Computes the set union of this expression, which must resolve to an array, and the given array(s) or array expression(s). |
Method | unique |
Returns an array containing the unique values in this expression, which must resolve to an array. |
Method | upper |
Converts this expression, which must resolve to a string, to uppercase. |
Method | week |
Returns the week of the year of this date expression (in UTC) as a number between 0 and 53. |
Method | year |
Returns the year of this date expression (in UTC). |
Property | is |
Whether this expression's prefix is frozen. |
Method | _freeze |
Undocumented |
Method | _function |
Undocumented |
Method | _let |
Undocumented |
Instance Variable | _expr |
Undocumented |
Instance Variable | _prefix |
Undocumented |
Returns a MongoDB representation of the field.
Parameters | |
prefix:None | an optional prefix to prepend to the field name |
Returns | |
a string |