static Object fromByteArray(final byte[] bytes, final char type) {
        if (bytes.length % PyMultiarray.typeToNBytes(type) != 0) { throw Py
                .ValueError("array size must be a multiple of the type size"); }
        try {
            final java.io.ByteArrayInputStream byteStream = new java.io.ByteArrayInputStream(
                    bytes);
            final java.io.DataInputStream dataStream = new java.io.DataInputStream(
                    byteStream);
            final Object data = Array.newInstance(
                    PyMultiarray.typeToClass(type),
                    bytes.length / PyMultiarray.typeToNBytes(type));
            switch (type) {
            case '1':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setByte(data, i, dataStream.readByte());
                }
                break;
            case 's':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setShort(data, i, dataStream.readShort());
                }
                break;
            case 'i':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setInt(data, i, dataStream.readInt());
                }
                break;
            case 'l':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setLong(data, i, dataStream.readLong());
                }
                break;
            case 'f':
            case 'F':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setFloat(data, i, dataStream.readFloat());
                }
                break;
            case 'd':
            case 'D':
                for (int i = 0; i < Array.getLength(data); i++) {
                    Array.setDouble(data, i, dataStream.readDouble());
                }
                break;
            default:
                throw Py.ValueError("typecode must be in [1silfFdDO]");
            }
            return data;
        } catch (final java.io.IOException e) {
            throw Py.RuntimeError("ioexception:" + e.getMessage());
        }
    }