Skip to content

Commit

Permalink
Add query for getting NeosCmos from NeosVisit (#33)
Browse files Browse the repository at this point in the history
Add query for getting NeosCmos from Visit
dahlend authored May 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b76ccc2 commit 68e7407
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/neospy/rust/fovs/definitions.rs
Original file line number Diff line number Diff line change
@@ -555,6 +555,22 @@ impl PyNeosVisit {
self.0.rotation
}

pub fn __len__(&self) -> usize {
4
}

/// Retrieve a specific CMOS FOV..
pub fn __getitem__(&self, idx: usize) -> PyResult<PyNeosCmos> {
if idx >= self.__len__() {
return Err(PyErr::new::<exceptions::PyIndexError, _>(""));
}

Ok(PyNeosCmos(match self.0.get_fov(idx) {
fov::FOV::NeosCmos(fov) => fov,
_ => unreachable!(),
}))
}

fn __repr__(&self) -> String {
format!(
"NEOSVisit(pointing={}, rotation={}, observer={}, side_id={}, stack_id={}, quad_id={}, loop_id={}, subloop_id={}, exposure_id={})",

0 comments on commit 68e7407

Please sign in to comment.