Skip to content

BUG: String fields in compound dtypes don't resize as might be expected #8969

Open

Description

@eric-wieser

Example:

>>> dt = np.dtype([('f', float), ('s', str)])
>>> np.array([(1.0, "hello world")], dt)
array([(1.0, '')], 
      dtype=[('f', '<f8'), ('s', 'S')])

Proposal: This should either resize or raise a ValueError (#8970), as it seems like it would always mask bugs

Activity

  1. added 2 commits that reference this issue on Nov 3, 2017
    12b2e39
  2. added a commit that references this issue on Oct 10, 2020
    083bc1a
  3. seberg commented on Feb 2, 2021

    @seberg
    Member

    Just to note, my half plan is that we deprecate "S" mostly (which doesn't actually change much). It would still be valid input to some functions like np.array() that do honor the fact that it can represent any length; and those should be the vast majority of use cases.
    For all other cases, we would then force "S0" to get the same result without any ambiguity (at least in the long run).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions