numpy / numpy/numpy

Behaviour of np.generic.real and np.generic.imag is ... really imaginative

Open
#10,818 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

triaged
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Discovered in https://github.com/numpy/numpy_stubs/pull/14#discussion_r176951593

>>> b = np.bytes_(b'test')
>>> b.real, b.imag
('test', '')

>>> d = np.datetime64(dt.datetime.now())
>>> d.real, d.imag
(numpy.datetime64('2018-03-26T15:22:14.672804'), numpy.datetime64('1970-01-01T00:00:00.000000'))

It seems like we should give an error or warning here, in both cases.

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 with the np.generic.real and np.generic.imag entry points and review the examples linked from numpy_stubs PR #14. Determine the intended behavior for bytes_ and datetime64, then add focused regression coverage for the agreed error or warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.