spectrochempy.Unit.is_compatible_with¶
- Unit.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 Quantity, PlainUnit or str. *contexts : str or pint.Context Contexts to use in the transformation. **ctx_kwargs : Values for the Context/s Returns ------- bool """ from .quantity import PlainQuantity if contexts or self._REGISTRY._active_ctx: try: (1 * 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 Quantity, PlainUnit or str.
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
- Returns
bool