コード例 #1
0
        public Object this[params object[] args]
        {
            get
            {
                ndarray result;

                NpyIndexes indexes = new NpyIndexes();
                {
                    NpyUtil_IndexProcessing.IndexConverter(this.arr.ravel(), args, indexes);
                    result = NpyCoreApi.IterSubscript(this, indexes);
                }
                if (result.ndim == 0)
                {
                    return(result.GetItem(0));
                }
                else
                {
                    return(result);
                }
            }

            set
            {
                NpyIndexes indexes = new NpyIndexes();
                {
                    NpyUtil_IndexProcessing.IndexConverter(this.arr.ravel(), args, indexes);

                    if (indexes.NumIndexes == 1)
                    {
                        // Special cases for single assigment.
                        switch (indexes.IndexType(0))
                        {
                        case NpyIndexType.NPY_INDEX_INTP:
                            SingleAssign(indexes.GetIntP(0), value);
                            return;

                        case NpyIndexType.NPY_INDEX_BOOL:
                            if (indexes.GetBool(0))
                            {
                                SingleAssign(0, value);
                            }
                            return;

                        default:
                            break;
                        }
                    }

                    ndarray array_val = np.FromAny(value, arr.Dtype, 0, 0, 0, null);
                    NpyCoreApi.IterSubscriptAssign(this, indexes, array_val);
                }
            }
        }