Esempio n. 1
0
        private Dictionary <string, object> GetFieldsDict()
        {
            Dictionary <string, object> ret;

            if (!HasNames)
            {
                ret = null;
            }
            else
            {
                NpyDict_Iter iter = null;
                NpyDict      dict = core.fields;
                ret = new Dictionary <string, object>();
                try
                {
                    NpyDict_KVPair KVPair = new NpyDict_KVPair();
                    iter = NpyCoreApi.NpyDict_AllocIter();
                    while (NpyCoreApi.NpyDict_Next(dict, iter, KVPair))
                    {
                        string key = (string)KVPair.key;
                        NpyArray_DescrField value = (NpyArray_DescrField)KVPair.value;
                        PythonTuple         t;

                        dtype d = new dtype(value.descr);
                        if (value.title == null)
                        {
                            t = new PythonTuple(new Object[] { d, value.offset });
                        }
                        else
                        {
                            t = new PythonTuple(new Object[] { d, value.offset, value.title });
                        }
                        ret.Add(key, t);
                    }
                }
                finally
                {
                    NpyCoreApi.NpyDict_FreeIter(iter);
                }
            }
            return(ret);
        }