Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ValueError for np.dtype([("", int), ("f0", int)]) #14239

Copy link
Copy link
Open
@Zac-HD

Description

@Zac-HD
Issue body actions

We found this one with Hypothesis, HypothesisWorks/hypothesis#1963, and I added a workaround at the PyCon sprints but only now got around to opening an upstream issue.

Fields with the empty string as their name are re-named f{index}; it would be a sufficient fix to detect if there is another field with that as an explicit name and choose something else. The idea would be that the field ... occurs more than once would only occur if a name was actually specified more than once by the user.

Defaulting to f{index_of_other_use} would be confusing, and does not cover multiple or multi-step collisions. Any other deterministic name might have to consider number-of-fields options; imagine for example the rule "increment the field number" on names "", "f0", "f1", ....

I would therefore also be happy with an improved error message, that The field at index _x_ is named "", which defaults to "f_x_", but this name is already in use at index _y_..

Reproducing code example:

import numpy as np

# raises `ValueError: field 'f0' occurs more than once`
np.dtype([("", int), ("f0", int)])

# Forecloses the easy "swap the names" solution
np.dtype([("", int), ("f0", int), ("f1", int)])

Numpy/Python version information:

Numpy 1.14.5 and 1.17.0; Python 3.7 and earlier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.