Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`stream_readers` array shape validation is incompatible with `READ_ALL_AVAILABLE`

Aperta
#421 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
numpy, python
Ambito
api

Direzione di ricerca

Inizia da generated/nidaqmx/stream_readers.py, in particolare da read_many_sample e _verify_array, quindi riproduci l'esempio usando AnalogMultiChannelReader e READ_ALL_AVAILABLE. Il lavoro è completato quando viene accettato un array NumPy preallocato di (2, 1000) anche se il numero di campioni disponibili varia e l'esempio stampa i dati dell'array senza l'errore di convalida della forma.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

If you use stream_readers to read into a preallocated NumPy array with number_of_samples_per_channel=READ_ALL_AVAILABLE, the stream reader validates the NumPy array shape against the available samples per channel, which is not a predictable number.

Steps to reproduce

Install an X Series or M Series as Dev1 and run this code:

import pprint
import time

import nidaqmx
import numpy
from nidaqmx.constants import AcquisitionType
from nidaqmx.stream_readers import AnalogMultiChannelReader

pp = pprint.PrettyPrinter(indent=4)

with nidaqmx.Task() as task:
    task.ai_channels.add_ai_voltage_chan("Dev1/ai0:1")
    task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.CONTINUOUS)
    task.start()
    time.sleep(100e-3)

    reader = AnalogMultiChannelReader(task.in_stream)
    data = numpy.zeros((2, 1000), dtype=numpy.double)
    reader.read_many_sample(data, timeout=0.0)

    pp.pprint(data)

Expected output

Prints array data

Actual output

The required number of samples varies from run to run but is around 100 to 110.

Traceback (most recent call last):
  File "D:\dev\nidaqmx-python\examples\ai_raw.py", line 19, in <module>
    reader.read_many_sample(data, timeout=0.0)
  File "D:\dev\nidaqmx-python\generated\nidaqmx\stream_readers.py", line 322, in read_many_sample
    self._verify_array(data, number_of_samples_per_channel, True, True)
  File "D:\dev\nidaqmx-python\generated\nidaqmx\stream_readers.py", line 83, in _verify_array
    raise DaqError(
nidaqmx.errors.DaqError: Read cannot be performed because the NumPy array passed into this function is not shaped correctly. You must pass in a NumPy array of the correct shape based on the number of channels in task and the number of samples per channel requested.

Shape of NumPy Array provided: (2, 1000)
Shape of NumPy Array required: (2, 105)

Task Name: _unnamedTask<0>
Lingua principale
Python
Stelle
592
Fork
199
Merge medio
1g 16h
PR unite (30g)
10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ni/nidaqmx-python

Tutte le issue di ni/nidaqmx-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.