Beispiel #1
0
 private static int[] TupleToIndices(Array a, IList <object> tuple)
 {
     int[] indices = new int[tuple.Count];
     for (int i = 0; i < indices.Length; i++)
     {
         indices[i] = PythonOps.FixIndex(Converter.ConvertToInt32(tuple[i]), a.GetUpperBound(i) + 1);
     }
     return(indices);
 }
Beispiel #2
0
        public static void SetItem(Array data, int index, object value)
        {
            if (data == null)
            {
                throw PythonOps.TypeError("expected Array, got None");
            }

            data.SetValue(Converter.Convert(value, data.GetType().GetElementType()), PythonOps.FixIndex(index, data.Length) + data.GetLowerBound(0));
        }
Beispiel #3
0
        public static object GetItem(Array data, int index)
        {
            if (data == null)
            {
                throw PythonOps.TypeError("expected Array, got None");
            }

            return(data.GetValue(PythonOps.FixIndex(index, data.Length) + data.GetLowerBound(0)));
        }
Beispiel #4
0
 private static int[] TupleToIndices(Array a, IList <object?> tuple)
 {
     int[] indices = new int[tuple.Count];
     for (int i = 0; i < indices.Length; i++)
     {
         int iindex = Converter.ConvertToInt32(tuple[i]);
         indices[i] = i < a.Rank ? PythonOps.FixIndex(iindex, a.GetLength(i)) : int.MinValue;
     }
     return(indices);
 }
Beispiel #5
0
        public static object?GetItem(Array data, int index)
        {
            if (data == null)
            {
                throw PythonOps.TypeError("expected Array, got None");
            }
            if (data.Rank != 1)
            {
                throw PythonOps.TypeError("bad dimensions for array, got {0} expected {1}", 1, data.Rank);
            }

            return(data.GetValue(PythonOps.FixIndex(index, data.Length) + data.GetLowerBound(0)));
        }
Beispiel #6
0
 public static void DeleteItem(List <T> l, int index)
 {
     l.RemoveAt(PythonOps.FixIndex(index, l.Count));
 }