Skip to content

Comments

ENH: fixing generic error messages to be more specific in multiarray/descriptor.c#15484

Merged
mattip merged 24 commits intonumpy:masterfrom
ericmariasis:report_generic
Feb 2, 2020
Merged

ENH: fixing generic error messages to be more specific in multiarray/descriptor.c#15484
mattip merged 24 commits intonumpy:masterfrom
ericmariasis:report_generic

Conversation

@ericmariasis
Copy link
Contributor

@ericmariasis ericmariasis commented Feb 1, 2020

Closes #15316

@eric-wieser
Copy link
Member

If there are no callers left, can you delete the definition of _report_generic_error?

ericmariasis and others added 5 commits February 1, 2020 07:23
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
…into report_generic

* 'report_generic' of https://github.com/ericmariasis/numpy:
  Update numpy/core/src/multiarray/descriptor.c
  Update numpy/core/src/multiarray/descriptor.c
  Update numpy/core/src/multiarray/descriptor.c
@ericmariasis
Copy link
Contributor Author

If there are no callers left, can you delete the definition of _report_generic_error?

I was so close but unfortunately there was one location that I couldn't think of a good replacement for. It was basically if the data type could not be recognized in general.

@eric-wieser
Copy link
Member

If it's one location, you could just inline the function

@ericmariasis
Copy link
Contributor Author

If it's one location, you could just inline the function

Done.

@ericmariasis ericmariasis reopened this Feb 1, 2020
ericmariasis and others added 3 commits February 1, 2020 08:55
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
ericmariasis and others added 5 commits February 1, 2020 10:03
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Probably doesn't need a test, but it would be great if you could post some example error output in a comment here.

@ericmariasis
Copy link
Contributor Author

Closes #15316

Example error output:

dtype2 = np.dtype([2,3,4])
Traceback (most recent call last):
File "", line 1, in
TypeError: data type not understood

dtype3 = np.dtype((float,))
Traceback (most recent call last):
File "", line 1, in
TypeError: data type not understood

-- The above is now updated to give better details of the error.

Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericmariasis can you paste the error that happens with this patch applied? Thought ticks around '%R' may make sense. I am sure you can always massage the text, but its a nice improvement.

Some of the lines are a bit long, we often use:

PyErr_Format(PyExc_TypeError,
        "8 spaces indentation before the message", )

style. It does not have to be that style, below 80 characters would be nice though (at least not much over).

ericmariasis and others added 6 commits February 1, 2020 13:16
Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I am good with putting it in now. If someone wants to massage the error messages also great, but most of them are rare, and they read fine to me.
Two more style nitpicks if you are still motivated.

@ericmariasis
Copy link
Contributor Author

Now that all reviewers have approved, is there anything on my part I can do to help this get merged into master?

@mattip mattip merged commit cd82df3 into numpy:master Feb 2, 2020
@mattip
Copy link
Member

mattip commented Feb 2, 2020

Thanks @ericmariasis

@ericmariasis ericmariasis deleted the report_generic branch February 2, 2020 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace calls to _report_generic_error with a more useful error message.

4 participants