kw() public static method

public static kw ( ) : KeywordArguments
return KeywordArguments
示例#1
0
        private void GetArgs(object[] inargs, CallInfo callInfo, out PyTuple args, out PyDict kwargs)
        {
            if (callInfo == null || callInfo.ArgumentNames.Count == 0)
            {
                GetArgs(inargs, out args, out kwargs);
                return;
            }

            // Support for .net named arguments
            var namedArgumentCount   = callInfo.ArgumentNames.Count;
            var regularArgumentCount = callInfo.ArgumentCount - namedArgumentCount;

            var argTuple = Runtime.PyTuple_New(regularArgumentCount);

            for (int i = 0; i < regularArgumentCount; ++i)
            {
                AddArgument(argTuple, i, inargs[i]);
            }
            args = new PyTuple(argTuple);

            var namedArgs = new object[namedArgumentCount * 2];

            for (int i = 0; i < namedArgumentCount; ++i)
            {
                namedArgs[i * 2]     = callInfo.ArgumentNames[i];
                namedArgs[i * 2 + 1] = inargs[regularArgumentCount + i];
            }
            kwargs = Py.kw(namedArgs);
        }
示例#2
0
        public static byte[] SaveFigureToArray(PyObject fig, int dpi = 200, string format = "png")
        {
            if (fig.GetPythonType().Handle != PltFigureType)
            {
                throw new Exception("object is not a matplotlib Figure");
            }

            dynamic _np = np;
            //buf = io.BytesIO()
            dynamic buf = BytesIO.Invoke();

            //fig.savefig(buf, dpi=__dpi__, format='png')
            fig.InvokeMethod("savefig", new PyTuple(new PyObject[] { buf }), Py.kw("dpi", dpi, "format", format));
            var buf_out = _np.array(buf.getbuffer(), Py.kw("dtype", Numpy.GetNumpyDataType(typeof(byte))));
            var arr     = Numpy.ToArray(buf_out);

            return((byte[])arr);
        }