numpy / numpy/numpy

BUG, ENH: Refine Nat checks and division by 0 setting in timedelta division code

Open
#17,831 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

00 - Bug component: numpy.datetime64 component: numpy.ufunc
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

I would like to take this as a follow-up PR as we need to make two major changes:
For both timedeltas, we need to do this: https://github.com/numpy/numpy/blob/000dfda49a012bd38efc6fbb89ece58279895bad/numpy/core/src/umath/loops.c.src#L1446-L1448

But as I mentioned in https://github.com/numpy/numpy/pull/17727#issuecomment-726084647, we are truncating instead of flooring. Second being the setting of invalid division.

Originally posted by @ganesh-k13 in https://github.com/numpy/numpy/pull/17727#discussion_r528838830

Refers: #17727, #16458
CC: @seberg , @mattip, @eric-wieser

Contributor guide

Open the contributing guide

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

Start in numpy/core/src/umath/loops.c.src around lines 1446-1448 and read the discussion in #17727 and #16458. Check the timedelta division paths for both timedelta operands, then verify that Nat checks use flooring rather than truncation and that invalid division is set as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
data
Issue type
Bug
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.