`beta_coef(self, t)` returns incorrect values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13
- Forks
- 3
- Avg merge
- 19h 43m
- Merged PRs (30d)
- 1
Description
due to complex indexing logic it can be hard for a user to understand exactly which parameters will return which coefficients
Current Behavior
BETA_COEFICIENTS = jnp.array([-1.0, 0.0, 1.0])
BETA_TIMES = jnp.array([50, 125, 150])
def test_buggy(t):
# copy pasted from AbstractParameters.beta_coef(self, t)
return BETA_COEFICIENTS[jnp.maximum(0, jnp.searchsorted(BETA_TIMES, t) - 1)]
times_of_interest = jnp.array([0, 49, 50, 51, 124, 125, 126, 149, 150, 151])
print(">>> self.beta_coef(t=%s) \n %s"%(times_of_interest.tolist(), test_buggy(times_of_interest)))
>>> self.beta_coef(t=[0, 25, 49, 50, 51, 124, 125, 126, 149, 150, 151])
[-1. -1. -1. -1. -1. -1. 0. 0. 0. 1.]
Proposed Solution
BETA_COEFICIENTS = jnp.array([-1.0, 0.0, 1.0])
BETA_TIMES = jnp.array([125, 150])
def test_proposed(t):
return BETA_COEFICIENTS[jnp.maximum(0, jnp.searchsorted(BETA_TIMES, t, side='right'))]
times_of_interest = jnp.array([0, 49, 50, 51, 124, 125, 126, 149, 150, 151])
print(">>> self.beta_coef(t=%s) \n %s"%(times_of_interest.tolist(), test_proposed(times_of_interest)))
>>> self.beta_coef(t=[0, 49, 50, 51, 124, 125, 126, 149, 150, 151])
[-1. -1. -1. -1. -1. 0. 0. 0. 1. 1.]
This includes more sane boundaries on the times listed in BETA_TIMES, furthermore BETA_COEFICIENTS being 1 element longer than BETA_TIMES more clearly indicates that the first and last coefficient bound t = [-inf, BETA_TIMES[0] ) and t = [BETA_TIMES[-1], inf ) respectively.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Find AbstractParameters.beta_coef(self, t) and reproduce the issue with the BETA_COEFICIENTS, BETA_TIMES, and times_of_interest examples in the report. Verify that boundary values at the listed times match the proposed interval behavior, including the first and last coefficient ranges.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100