Support uint8 and uint16 in Block.cpp for Direct Numpy Array Access

XMLWordPrintable

    • Type: New Feature
    • Resolution: resolved
    • Priority: Minor
    • Component/s: None
    • None

      From Ryan Herbst:

      https://github.com/slaclab/rogue/blob/fdfef6007c592d8d296f30f16c42ccd91f925150/src/rogue/interfaces/memory/Block.cpp#L926-L942

      Block.cpp
              if (PyArray_TYPE(arr) == NPY_UINT64) {
                  uint64_t* src   = reinterpret_castuint64_t*(PyArray_DATA(arr));
                  npy_intp stride = strides[0] / sizeof(uint64_t);
                  for (x = 0; x < dims[0]; x++) {
                      setUInt(src[x * stride], var, index + x);
      

      and here:

      https://github.com/slaclab/rogue/blob/fdfef6007c592d8d296f30f16c42ccd91f925150/src/rogue/interfaces/memory/Block.cpp#L1005-L1027

      Block.cpp
              if (var->valueBits_ > 32) {
                  obj                = PyArray_SimpleNew(1, dims, NPY_UINT64);
                  PyArrayObject* arr = reinterpret_castPyArrayObject*(obj);
                  uint64_t* dst      = reinterpret_castuint64_t*(PyArray_DATA(arr));
      

      seems like we may also want to support uin8 and uint16
      in one project I want to access as 8-bit locations so I have to convert the numpy array to astype(np.uint32) which is a copy in order to write an array of 8-bit values to a list variable

              Assignee:
              Ryan Herbst
              Reporter:
              Larry Ruckman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: