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

`Task.write` does not handle certain inputs as expected

Aperta
#126 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

  • #127 di @stafak — chiusa senza merge

Valutazione

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

Direzione di ricerca

Inizia dal punto di ingresso Task.write e riproduci entrambi gli esempi dell’issue, inclusi l’elenco annidato e l’input misto Python-list/NumPy-array. Traccia il modo in cui vengono interpretate le forme e i tipi dei canali e dei campioni. Il lavoro è completato quando entrambi gli esempi scrivono i segnali digitali richiesti senza gli errori segnalati relativi al numero di canali o al tipo di campione, con copertura di regressione per questi input.

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

Descrizione

enhancement

Hi!

Running this code, I expect to write the signal to line 2, but instead I get a strange error message about mismatching number of channels (even though there is no mismatch):

import nidaqmx

taskLen = 100
signalLine2 = [True] * taskLen
signals = [signalLine2]

with nidaqmx.Task('mytask') as task:
    task.do_channels.add_do_chan('Dev1/port0/line2')
    task.write(signals, auto_start=True)
    task.wait_until_done()

print('done')
nidaqmx.errors.DaqError: Write cannot be performed, because the number of channels in the data does not match the number of channels in the task.

When writing, supply data for all channels in the task. Alternatively, modify the task to contain the same number of channels as the data written.

Number of Channels in Task: 1
Number of Channels in Data: 1

Task Name: mytask

I'm aware that it's possible to avoid this by simply using signalLine2 as the input instead of the 2-dimensional signals variable, but sometimes you can end up in this situation when creating a varying number of signals in a loop.


Similarly, an error is raised when mixing Python lists and numpy arrays in the input:

import nidaqmx
import numpy as np

taskLen = 100
signalLine2 = np.ones(taskLen, dtype=bool)
signalLine3 = np.ones(taskLen, dtype=bool)
signals = [signalLine2, signalLine3]

with nidaqmx.Task('mytask') as task:
    task.do_channels.add_do_chan('Dev1/port0/line2')
    task.do_channels.add_do_chan('Dev1/port0/line3')
    task.write(signals, auto_start=True)
    task.wait_until_done()

print('done')
nidaqmx.errors.DaqError: Write failed, because this write method only accepts boolean samples when there is one digital line per channel in a task.

Requested sample type: <class 'numpy.ndarray'>

Task Name: mytask
Lingua principale
Python
Stelle
590
Fork
199
Merge medio
1g 8h
PR unite (30g)
7

Preparare l'ambiente

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.