borglab / borglab/gtsfm

Delayed expected types

Open
#238 2 comments 1 reaction 0 assignees View on GitHub
documentation
Dominant language
Jupyter Notebook
Stars
524
Forks
64
Avg merge
4h 1m
Merged PRs (30d)
3

Description

I think it would be useful for any function which has a `Delayed` object as either an input or an output, to specify the expected type of the variable after task completion in the doc string. This will reduce the need to follow a chain of function calls to figure out the expected type during development. For example, in the `DetectorDescriptorBase` class, instead of

```
def create_computation_graph(self, image_graph: Delayed) -> Tuple[Delayed, Delayed]:
"""
Generates the computation graph for detections and their descriptors.

Args:
image_graph: computation graph for a single image (from a loader).

Returns:
Delayed tasks for detections.
Delayed task for corr. descriptors.
"""
# get delayed object, cannot separate two arguments immediately
joint_graph = dask.delayed(self.detect_and_describe)(image_graph)

keypoints_graph = joint_graph[0]
descriptor_graph = joint_graph[1]

return keypoints_graph, descriptor_graph
```

It could be something like

```
def create_computation_graph(self, image_graph: Delayed) -> Tuple[Delayed, Delayed]:
"""
Generates the computation graph for detections and their descriptors.

Args:
image_graph: computation graph for a single image (expects Image).

Returns:
Delayed tasks for detections (expects Keypoints).
Delayed task for corr. descriptors (expects np.ndarray).
"""
# get delayed object, cannot separate two arguments immediately
joint_graph = dask.delayed(self.detect_and_describe)(image_graph)

keypoints_graph = joint_graph[0]
descriptor_graph = joint_graph[1]

return keypoints_graph, descriptor_graph
```

Contributor guide

Open the contributing guide

Research direction

Start by locating DetectorDescriptorBase.create_computation_graph and reviewing how its Delayed inputs and outputs are documented. Audit the other functions that accept or return Delayed objects, then verify that their docstrings state the expected types after task completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.