Skip to content

CheckedSession default dtype is confusing and annoying #1163

Description

@gdementen
>>> a = Axis('a=a0,a1')
>>> class CS(CheckedSession):
...     v: CheckedArray(a)
>>> arr = ndtest(a)
>>> arr.dtype
dtype('int64')
>>> cs = CS(v=arr)
>>> cs.v.dtype
dtype('float64')
>>> cs.v = arr
>>> cs.v.dtype
dtype('float64')

When the dtype is not specified, instead of (silently) coercing to float, it should accept any dtype. We asked to check for the axes, not the dtype.

Activity

  1. gdementen commented on Feb 25, 2026

    @gdementen
    ContributorAuthor

    The silent coercion happens even for unsafe conversions, which is not acceptable to me (see #1164).

  2. gdementen commented on Feb 25, 2026

    @gdementen
    ContributorAuthor

    FWIW, Vesna stumbed on this one. She wanted to do:

    >>> a = Axis('a=a0..a4')
    >>> int_axis = Axis('int_axis=1,2,3')
    >>> int_array = Array([1,3,2,1,2], a) # values all exist in int_axis (int dtype)
    >>> class CS(CheckedSession):
    ...     v: CheckedArray(a)
    >>> cs = CS(...)
    >>> cs.int_array = int_array          # silently becomes float dtype even if float is never mentioned explicitly anywhere
    >>> other_array = ndtest(int_axis)    # array with one axis with integer labels
    >>> other_array[cs.indice_array]      # <-- fails because the labels in other_array.int_axis are integers but the "key" array has floats

    This was just an awful debugging experience.

  3. added this to the 0.36 milestone on Mar 25, 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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions