Package org.python.core

Examples of org.python.core.PyArray


            }
            return debugVar;

        }
        if (value instanceof PyArray) {
            PyArray arrayValue = (PyArray) value;
            Object[] dataArray = (Object[]) arrayValue.getArray();
            for (int i = 0; i < arrayValue.__len__(); i++) {
                Object o = dataArray[i];
                debugVar.addField(new DebugVariable("[" + i + "]",
                        o.getClass().toString(), o.toString()));
                debugVar = dumpJavaObject(o, debugVar);
            }
View Full Code Here


        });
        addPostClass(new PyObjectAdapter() {

            public PyObject adapt(Object o) {
                return new PyArray(o.getClass().getComponentType(), o);
            }

            public boolean canAdapt(Object o) {
                return o.getClass().isArray();
            }
View Full Code Here

        if (args.length - argstart < 2)
            Py.TypeError("illegal argument type for built-in operation");
        if (!(args[argstart] instanceof PyArray)) {
            throw Py.TypeError("pack_into takes an array arg"); // as well as a buffer, what else?
        }
        PyArray buffer = (PyArray)args[argstart];
        int offset = args[argstart + 1].asInt();

        ByteStream res = pack(format, f, size, argstart + 2, args);
        if (res.pos > buffer.__len__()) {
            throw StructError("pack_into requires a buffer of at least " + res.pos + " bytes, got " + buffer.__len__());
        }
        for (int i = 0; i < res.pos; i++, offset++) {
            char val = res.data[i];
            buffer.set(offset, val);
        }
    }
View Full Code Here

                throw Py.TypeError("Cannot use string as modifiable buffer");
            }
            throw Py.TypeError("argument 1 must be read-write buffer, not "
                               + buf.getType().fastGetName());
        }
        PyArray array = (PyArray)buf;
        String read = read(array.__len__());
        for (int i = 0; i < read.length(); i++) {
            array.set(i, new PyString(read.charAt(i)));
        }
        return read.length();
    }
View Full Code Here

    });
    addPostClass(new PyObjectAdapter() {

      public PyObject adapt(Object o) {
        return new PyArray(o.getClass().getComponentType(), o);
      }

      public boolean canAdapt(Object o) {
        return o.getClass().isArray();
      }
View Full Code Here

    private void execFile(String filePath, String... arguments) {
        interp.cleanup();
        interp.set("__file__", filePath);
        sys.argv = new PyList(new PyString[]{new PyString(filePath)});
        sys.argv.extend(new PyArray(PyString.class, arguments));
        interp.execfile(filePath);
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.