Exemple #1
0
 internal static int npy_append_str(npy_tmp_string_t s, string c)
 {
     if (s.s == null)
     {
         s.s         = c.ToString();
         s.pos       = 0;
         s.allocated = s.s.Length;
     }
     else
     {
         s.s        += c.ToString();
         s.pos       = 0;
         s.allocated = s.s.Length;
     }
     return(0);
 }
Exemple #2
0
        /*
         * Global information about all active buffers
         *
         * Note: because for backward compatibility we cannot define bf_releasebuffer,
         * we must manually keep track of the additional data required by the buffers.
         */



        /* Fill in the info structure */
        internal static npy_buffer_info_t npy_buffer_info_new(NpyArray arr)
        {
            npy_buffer_info_t info;
            npy_tmp_string_t  fmt = new npy_tmp_string_t()
            {
                allocated = 0, pos = 0, s = null
            };
            int k;

            info = new npy_buffer_info_t();

            /* Fill in format */
            size_t offset           = 0;
            char   active_byteorder = '0';

            if (npy_buffer_format_string(NpyArray_DESCR(arr), fmt, arr, ref offset, ref active_byteorder) != 0)
            {
                return(null);
            }
            npy_append_char(fmt, '\0');
            info.format = fmt.s;

            /* Fill in shape and strides */
            info.ndim = NpyArray_NDIM(arr);

            if (info.ndim == 0)
            {
                info.shape   = null;
                info.strides = null;
            }
            else
            {
                info.shape   = new size_t[NpyArray_NDIM(arr)];
                info.strides = new size_t[NpyArray_NDIM(arr)];
                for (k = 0; k < NpyArray_NDIM(arr); ++k)
                {
                    info.shape[k]   = (ulong)NpyArray_DIM(arr, k);
                    info.strides[k] = (ulong)NpyArray_STRIDE(arr, k);
                }
            }

            return(info);
        }
Exemple #3
0
        internal static string NpyArrayAccess_GetBufferFormatString(NpyArray arr)
        {
            Debug.Assert(Validate(arr));

            npy_tmp_string_t fmt = new npy_tmp_string_t()
            {
                allocated = 0, pos = 0, s = null
            };

            char  active_byte_order = '0';
            ulong offset            = 0;

            if (npy_buffer_format_string(NpyArray_DESCR(arr), fmt, arr, ref offset, ref active_byte_order) != 0)
            {
                return(null);
            }
            npy_append_char(fmt, '\0');

            return(fmt.s);
        }
Exemple #4
0
 internal static int npy_buffer_format_string(NpyArray_Descr descr, npy_tmp_string_t str, NpyArray arr, ref size_t offset, ref char active_byteorder)
 {
     // todo:
     return(0);
 }