Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ All notable changes to this project will be documented in this file.
one for Python 3.9-3.12 (numpy>=1.22) and one for Python 3.13+ (numpy>=2.1).
* The `nidaqmx` distribution package now specifies only a lower bound for `click`.
* Clarify PyPy support and enable unit testing with PyPy.
* Adopt ni-python-styleguide for hand-written code.

* ### Known Issues
* ...
Expand Down
20 changes: 17 additions & 3 deletions generated/nidaqmx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from nidaqmx.errors import DaqError, DaqReadError, DaqWriteError, DaqWarning, DaqResourceWarning
from nidaqmx.grpc_session_options import *
"""The NI-DAQmx API for Python."""

from nidaqmx.errors import (
DaqError,
DaqReadError,
DaqResourceWarning,
DaqWarning,
DaqWriteError,
)
from nidaqmx.grpc_session_options import * # noqa: F403 - 'from nidaqmx.grpc_session_options import *' used; unable to detect undefined names (auto-generated noqa)
from nidaqmx.scale import Scale
from nidaqmx.task import Task
from nidaqmx.types import CtrFreq, CtrTick, CtrTime
Expand All @@ -11,7 +19,13 @@

__version__ = version(__name__)

__all__ = ["errors", "scale", "stream_readers", "stream_writers", "task"]
__all__ = [ # noqa: F405 - 'errors' may be undefined, or defined from star imports: nidaqmx.grpc_session_options (auto-generated noqa)
"errors",
"scale",
"stream_readers",
"stream_writers",
"task",
]

# Do not add a null logging handler. If the application has not configured logging, the
# default behavior is to log warnings and errors to stderr.
9 changes: 6 additions & 3 deletions generated/nidaqmx/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""'nidaqmx' command line utility."""

from __future__ import annotations

import logging
from typing import Optional

import click

Expand All @@ -16,12 +17,14 @@
count=True,
help="Enable verbose logging. Repeat to increase verbosity.",
)
def main(verbosity: int) -> None:
def main( # noqa: D103 - Missing docstring in public function (auto-generated noqa)
verbosity: int,
) -> None:
_configure_logging(verbosity)


@main.command()
def installdriver():
def installdriver(): # noqa: D103 - Missing docstring in public function (auto-generated noqa)
_install_daqmx.installdriver()


Expand Down
19 changes: 8 additions & 11 deletions generated/nidaqmx/_bitfield_utils.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
def enum_bitfield_to_list(bitfield_value, bitfield_enum_type,
actual_enum_type):
"""
Converts a bitfield value to a list of enums.
def enum_bitfield_to_list(bitfield_value, bitfield_enum_type, actual_enum_type):
"""Converts a bitfield value to a list of enums.

Args:
bitfield_value (int): Specifies the value of the bitfield.
bitfield_enum_type (enum.Enum): Specifies the bitfield enum type
from which to mask and extract the enum values.
actual_enum_type (enum.Enum): Specifies the actual enum type.

Returns:
List[enum.Enum]: Indicates the converted list of enums.
"""
supported_values = []
for bitfield_mask in bitfield_enum_type:
if bitfield_value & bitfield_mask.value:
enum_value = next(
e for e in actual_enum_type if e.name == bitfield_mask.name)
enum_value = next(e for e in actual_enum_type if e.name == bitfield_mask.name)
supported_values.append(enum_value)

return supported_values


def enum_list_to_bitfield(enum_list, bitfield_enum_type):
"""
Converts a list of enums to a bitfield value.
"""Converts a list of enums to a bitfield value.

Args:
enum_list (List[enum.Enum]): Specifies the list of enums.
bitfield_enum_type (enum.Enum): Specifies the bitfield enum type
from which to mask and extract the enum values.

Returns:
int: Indicates the value of the bitfield.
"""
bitfield_value = 0
for enum_value in enum_list:
bitfield_mask = next(
b for b in bitfield_enum_type if b.name == enum_value.name)
bitfield_mask = next(b for b in bitfield_enum_type if b.name == enum_value.name)
bitfield_value |= bitfield_mask.value

return bitfield_value
return bitfield_value
2 changes: 1 addition & 1 deletion generated/nidaqmx/_dotenvpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def _get_package_path() -> Path:
"""Get the path of this package."""
module = sys.modules[__package__]
assert module.__file__ and module.__file__.endswith("__init__.py")
return Path(module.__file__).parent
return Path(module.__file__).parent
7 changes: 5 additions & 2 deletions generated/nidaqmx/_feature_toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import functools
import sys
from decouple import AutoConfig, Undefined, undefined
from enum import Enum
from typing import TYPE_CHECKING, Callable, TypeVar

from decouple import AutoConfig, Undefined, undefined

from nidaqmx._dotenvpath import get_dotenv_search_path
from nidaqmx.errors import FeatureNotSupportedError

Expand Down Expand Up @@ -36,6 +38,7 @@ def _config(
cast: Callable[[str], _T] | Undefined = undefined,
) -> _T: ...


# Based on the recipe at https://docs.python.org/3/howto/enum.html
class _OrderedEnum(Enum):
def __ge__(self, other: Self) -> bool:
Expand Down Expand Up @@ -156,4 +159,4 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T:
# Define feature toggle constants here:
# --------------------------------------

WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.INCOMPLETE)
WAVEFORM_SUPPORT = FeatureToggle("WAVEFORM_SUPPORT", CodeReadiness.INCOMPLETE)
23 changes: 13 additions & 10 deletions generated/nidaqmx/_grpc_time.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from __future__ import annotations

from datetime import timezone
from datetime import datetime as std_datetime
from datetime import tzinfo as dt_tzinfo
from hightime import datetime as ht_datetime
from hightime import timedelta as ht_timedelta
from typing import Optional, Union
from nidaqmx._time import _convert_to_desired_timezone
from datetime import datetime as std_datetime, timezone, tzinfo as dt_tzinfo

from google.protobuf.timestamp_pb2 import Timestamp as GrpcTimestamp
from hightime import datetime as ht_datetime, timedelta as ht_timedelta

from nidaqmx._time import _convert_to_desired_timezone

# 66 years, 17 leap days = 24107 days = 2082844800 seconds
_BIAS_FROM_1970_EPOCH = 2082844800
Expand All @@ -22,7 +19,10 @@

_EPOCH_1970 = ht_datetime(1970, 1, 1, tzinfo=timezone.utc)

def convert_time_to_timestamp(dt: std_datetime | ht_datetime, ts: GrpcTimestamp | None = None) -> GrpcTimestamp:

def convert_time_to_timestamp( # noqa: D103 - Missing docstring in public function (auto-generated noqa)
dt: std_datetime | ht_datetime, ts: GrpcTimestamp | None = None
) -> GrpcTimestamp:
seconds_since_1970 = 0

if ts is None:
Expand All @@ -44,10 +44,13 @@ def convert_time_to_timestamp(dt: std_datetime | ht_datetime, ts: GrpcTimestamp
ts.FromNanoseconds(seconds_since_1970 * _NS_PER_S + nanos)
return ts

def convert_timestamp_to_time(ts: GrpcTimestamp, tzinfo: dt_tzinfo | None = None) -> ht_datetime:

def convert_timestamp_to_time( # noqa: D103 - Missing docstring in public function (auto-generated noqa)
ts: GrpcTimestamp, tzinfo: dt_tzinfo | None = None
) -> ht_datetime:
total_nanos = ts.ToNanoseconds()
seconds, nanos = divmod(total_nanos, _NS_PER_S)
# Convert the nanoseconds to yoctoseconds.
total_yoctoseconds = int(round(_YS_PER_NS * nanos))
dt = _EPOCH_1970 + ht_timedelta(seconds = seconds) + ht_timedelta(yoctoseconds=total_yoctoseconds)
dt = _EPOCH_1970 + ht_timedelta(seconds=seconds) + ht_timedelta(yoctoseconds=total_yoctoseconds)
return _convert_to_desired_timezone(dt, tzinfo)
Loading
Loading