GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: SeedSequence accepts types outside of spec · Issue #27380 · numpy/numpy

BUG: SeedSequence accepts types outside of spec #27380

New issue
Copy link
New issue
Copy link
Open
Open
BUG: SeedSequence accepts types outside of spec#27380
Copy link
Labels
00 - Bug

Description

@bashtage
bashtage
opened on Sep 12, 2024
Issue body actions

Describe the issue:

SeedSequence supports None, int, Sequence[int] for entropy. It turns out that anythign with len(obj)==0 in the leading dimension will be accepted and is identical to 0. This includes ndarrays with any number of dimensions.

This might be more of a FR than a bug, but the lack of standardization could increase end users error risk.

Reproduce the code example:

import numpy as np

np.random.SeedSequence(0).generate_state(1)
np.random.SeedSequence([]).generate_state(1)
np.random.SeedSequence([[],[]]).generate_state(1)
np.random.SeedSequence(np.empty((0,10,10))).generate_state(1)
np.random.SeedSequence(np.empty((0,10,10), dtype=float)).generate_state(1)

Error message:

No error. The output of the above is

All produce

array([2968811710], dtype=uint32)
array([2968811710], dtype=uint32)
array([2968811710], dtype=uint32)
array([2968811710], dtype=uint32)
array([2968811710], dtype=uint32)

Python and NumPy Versions:

2.1.1
3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)]

Runtime Environment:

No response

Context for the issue:

It simply seems a bit less careful than it should be, and could allow accidental seed values in.

Activity

  1. bashtage
    added
    00 - Bug
    on Sep 12, 2024
  2. rkern commented on Sep 12, 2024

    @rkern
    rkern
    on Sep 12, 2024
    Member
    More actions

    The 0-padding behavior for [] should certainly be documented (we 0-pad out to pool_size uint32 integers so that spawning doesn't create conflicts).

    We certainly could tighten up our validation in _coerce_to_uint32_array(). What we implemented there was really an older proposal that didn't make the final cut that allowed a lot more than what we currently document because we thought we might want to allow things like hex-int '0x1badcafe' strings for ease of integration. That could certainly use another pass to align it with the final documentation.

    As a rule though, the documentation defines the standard and things outside of what's documented MAY raise a helpful exception but MAY also just execute with undefined behavior. Possibly worth tightening up if it's easy, but not urgently.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.