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: concatenation of a numpy scalar with a namedtuple is broken on Python 3.15.0a7 · Issue #31088 · numpy/numpy

BUG: concatenation of a numpy scalar with a namedtuple is broken on Python 3.15.0a7 #31088

New issue
Copy link
New issue
Copy link
Closed
Closed
BUG: concatenation of a numpy scalar with a namedtuple is broken on Python 3.15.0a7#31088
Copy link

Description

@neutrinoceros
neutrinoceros
opened on Mar 28, 2026
Issue body actions

Found this while trying out astropy's test suite against Python 3.15
(xref: astropy/astropy#19503)

>>> import numpy as np
>>> (1.,) + np.float64(2.) # just to demonstrate that this works
array([3.])
>>> from typing import NamedTuple
>>> class T(NamedTuple):
...     x: float
... 
>>> T(x=1.) + np.float64(2.)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    T(x=1.) + np.float64(2.)
    ~~~~~~~~^~~~~~~~~~~~~~~~
TypeError: can only concatenate tuple (not "numpy.float64") to tuple

In Python 3.14 I get the same output from with a builtin tuple or a NamedTuple.
It feels (to me) a bit more likely to be a regression in CPython, but I expect that the first question I'll get if I report there first is what numpy
devs think about it, so here I am, asking here first.

Activity

  1. jorenham commented on Mar 28, 2026

    @jorenham
    jorenham
    on Mar 28, 2026
    Member
    More actions

    From a type-theoretical perspective this can indeed be considered a bug in CPython. This named tuple called T here is a subtype of tuple[float], and should therefore support at least every operation that a tuple[float] supports. Put differently; this violates Barbara Liskov's substitution principle (wiki).

    Reacted by Clément Robert
  2. neutrinoceros commented on Mar 29, 2026

    @neutrinoceros
    neutrinoceros
    on Mar 29, 2026
    ContributorAuthor
    More actions

    Thanks ! I managed to remove numpy entirely from the reproducer so I think we can just close this one. FTR the report is now at python/cpython#146592

    Reacted by Joren Hammudoglu
  3. neutrinoceros
    closed this as completedon Mar 29, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — 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.