spectrochempy.Quantity.is_compatible_with¶
- Quantity.is_compatible_with(self, other: Any, *contexts: Union[str, Context], **ctx_kwargs: Any ) -> bool: """check if the other object is compatible Parameters ---------- other The object to check. Treated as dimensionless if not a PlainQuantity, Unit or str. *contexts : str or pint.Context Contexts to use in the transformation. **ctx_kwargs : Values for the Context/s Returns ------- bool """ from .unit import PlainUnit if contexts or self._REGISTRY._active_ctx: try: self.to(other, *contexts, **ctx_kwargs) return True except DimensionalityError: return False if isinstance(other, (PlainQuantity, PlainUnit))[source]¶
check if the other object is compatible
- Parameters
other – The object to check. Treated as dimensionless if not a PlainQuantity, Unit or str.
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
- Returns
bool