CDCgov / CDCgov/PyRenew

Add `ConvolveScanner` class and subclasses (replace `new_convolve_scanner` and `new_double_scanner` function factories)

Open
#177 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pyrenew request
Dominant language
Python
Stars
29
Forks
9
Avg merge
9d 9h
Merged PRs (30d)
8

Description

Something like this:

class SingleConvolveScanner:
    def __init__(self, array: ArrayLike, transform: Callable):
        self.array = array
        self.transform = transform

    def __call__(self, history_subset: ArrayLike, multiplier: float) -> tuple[ArrayLike, float]:
        new_val = self.transform(multiplier * jnp.dot(self.array, history_subset))
        latest = jnp.hstack([history_subset[1:], new_val])
        return latest, new_val

Pro

  • Easier to inspect
  • Explicitly calling an object constructor makes it even clearer we're making a new thing.

Con

  • A bit more verbose
  • Probably don't want to encourage mutating scanners in place e.g.:
my_scanner = SingleConvolveScanner(jnp.array[0.5, 0.3, 0.2]), transform=lambda x: x)
my_scanner.array = jnp.array([0.7, 0.2, 0.1])

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate new_convolve_scanner and new_double_scanner and trace their call sites first. Use those call sites to determine the needed ConvolveScanner subclasses, then verify the factories are replaced without changing scanner behavior; no test or file path is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.