genome_spy.Parameter¶
- class genome_spy.Parameter(param, *, empty=True, _name_is_explicit=True)View on GitHub¶
Bases:
ExpressionOperatorMixin,ExprRefRepresent a declared GenomeSpy parameter in Python expressions.
A parameter handle keeps its generated declaration in
paramand supplies the parameter name when used in an expression. Attach handles to charts withgenome_spy.TopLevelSpec.add_params().- Parameters:
param – Exact generated GenomeSpy parameter declaration.
empty – Whether an empty selection matches when consumed as a predicate.
- Returns:
A reusable parameter authoring handle.
- Raises:
TypeError – If the declaration has no string name.
Example
>>> threshold = param("threshold", value=0.5) >>> str(threshold * 2) '(threshold * 2)'
Methods
copy(*[, deep])Return an equivalent parameter handle.
expr(value)Return a copy with
exprupdated.Return this class schema with referenced properties merged in.
to_dict(*[, validate])Return an expression reference for expression-capable parameters.
to_json(*[, validate])Serialize this schema wrapper to formatted JSON.
validate(instance)Validate an instance against this wrapper's schema.
Attributes
Return whether this handle represents a selection parameter.
Return the declared GenomeSpy parameter name.
Return whether the parameter name was supplied by the user.
- property nameView on GitHub¶
Return the declared GenomeSpy parameter name.
- property is_selectionView on GitHub¶
Return whether this handle represents a selection parameter.
- property name_is_explicitView on GitHub¶
Return whether the parameter name was supplied by the user.
- copy(*, deep=True, **kwds)View on GitHub¶
Return an equivalent parameter handle.
- Parameters:
deep – Copy nested values in the generated declaration.
**kwds – Updates for the generated declaration.
- Returns:
A parameter handle with the same declaration and authoring metadata.
- Raises:
TypeError – If the copied declaration is not a generated parameter.
Example
>>> threshold = param("threshold", value=0.5) >>> threshold.copy().param.to_dict() {'name': 'threshold', 'value': 0.5}
- to_dict(*, validate=True)View on GitHub¶
Return an expression reference for expression-capable parameters.
- Parameters:
validate – Validate the expression reference against its schema.
- Returns:
A GenomeSpy expression-reference mapping.
- Raises:
TypeError – If this is a selection parameter, which requires an explicit condition or filter context.
Example
>>> param("opacity", value=0.5).to_dict() {'expr': 'opacity'}
- expr(value)View on GitHub¶
Return a copy with
exprupdated.
- classmethod resolve_references()View on GitHub¶
Return this class schema with referenced properties merged in.
- to_json(*, validate=True)View on GitHub¶
Serialize this schema wrapper to formatted JSON.
- classmethod validate(instance)View on GitHub¶
Validate an instance against this wrapper’s schema.