use crate::atoms::Band;
use pyo3::exceptions::PyTypeError;
use pyo3::prelude::*;
use pyo3::pyclass::CompareOp;
pub(crate) fn band_of(op: CompareOp, other: &Bound<'_, PyAny>) -> PyResult<Option<Band>> {
let Ok(x) = other.extract::<f64>() else {
return Ok(None);
};
let band = match op {
CompareOp::Ge => Band::new(Some(x), None, None, None),
CompareOp::Gt => Band::new(None, Some(x), None, None),
CompareOp::Le => Band::new(None, None, Some(x), None),
CompareOp::Lt => Band::new(None, None, None, Some(x)),
CompareOp::Eq | CompareOp::Ne => return Ok(None),
}?;
Ok(Some(band))
}
pub(crate) fn reject_modulo(modulo: &Bound<'_, PyAny>) -> PyResult<()> {
if modulo.is_none() {
return Ok(());
}
Err(PyTypeError::new_err(
"field ** exponent does not support a modulo argument",
))
}