Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m.initialize has a bug setting the subsize if the array input is array of data views #82

Open
desean1625 opened this issue Nov 25, 2019 · 2 comments
Labels

Comments

@desean1625
Copy link
Contributor

Describe the bug
m.initialize has a bug setting the subsize if the array input is array of data views

To Reproduce

data = [new DataView(new ArrayBuffer(10))];
plot.overlay_array(data);//throw "subsize must be provided with type 2000 files";

Expected behavior
The code allows arrays of Dataviews to be set and attempts to get the length for the subsize using data[0].length. However, dataviews it should be data[0].byteLength

Additional context
Fix should be

else if (Array.isArray(data) && (Array.isArray(data[0]) || ArrayBuffer.isView(data[0]))) {
            //If this is a 2-D array automatically set subsize
            hcb.type = 2000;
            hcb.subsize = ArrayBuffer.isView(data[0]) ? data[0].byteLength: data[0].length;
            hcb.size = data.length;
        }
@desean1625
Copy link
Contributor Author

Also this needs to be corrected in bluefile.js when it flattens the 2d array

length = (buf.length * buf[0].length);

@mrecachinas
Copy link
Contributor

@desean1625 can you go ahead and submit a PR with these fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants