Git Product home page Git Product logo

Comments (11)

 avatar commented on September 15, 2024

Should the 1d view also be vertical or remain horizontal?

from ndarray-show.

indiejoseph avatar indiejoseph commented on September 15, 2024

yes, 1d remains horizontal, thanks

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

This indeed seems surprising/counterintuitive if you're working with ndarrays as matrices. I think it'd be best to increment a major version and swap the default order. I only see two dependants (crunch-js, ndarray-ldl-factorization), so hopefully it won't have a large effect, but I'm new here so not 100% confident.

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

@mikolalysenko @Planeshifter — I never show a matrix without first transposing. @indiejoseph has a fork that transposes the output. Does anyone support merging this? Otherwise I will create:

  1. A module that outputs the array in parsable format, à la numpy (effectively includes transposing, I think)
  2. Another module that mixes this method into ndarray's prototype for you so that, if you desire, console.log(A) is parsable js that reconstructs the array (though perhaps without a guarantee of being trailing-bit-perfect)

from ndarray-show.

mikolalysenko avatar mikolalysenko commented on September 15, 2024

I think reworking the order seems reasonable if we increment the major version. The default version should aim to be as intuitive as possible for common cases, and you can always get whatever other order you like by calling ndarray.transpose()

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

Agreed. Okay. What about output formatting? Do you think aiming for parsable output is a worthwhile goal?

from ndarray-show.

mikolalysenko avatar mikolalysenko commented on September 15, 2024

Easily parseable output would be nice, but not at the expense of human readability.

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

Oops. Nope. I can dig a little more, but doesn't currently appear possible to extend the ndarray prototype, so I'll probably forget about that module. nbd. Probably for the best. console.log(show(A)) isn't much worse than console.log(A).

from ndarray-show.

marton78 avatar marton78 commented on September 15, 2024

+1 The output of 2d-arrays currently does not adhere to the usual mathematical notation. Please transpose it! I agree that outputting 1d-arrays as a row makes sense in terms of screen space, but then at least you should add a ^T or similar in the end.

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

Sorry I've been slow on this! Was debating inside my head what the best variation is. I've just been using:

function show(label,data) {
  if( typeof data === 'number' ) { 
    console.log(label+' = '+data)
  } else if( data.dimension === 1 ) { 
    console.log(label+' = '+ndshow(data))
  } else {
    console.log(label+' =\n'+ndshow(data.transpose(1,0))+'\n')
  }
}

Since most of the time I'm just trying to dump a matrix scalar/vector/matrix to the screen. I also wanted to add formatting configuration and maybe the output = valid input feature. (Edit: uses fixed width float; already has precision)

from ndarray-show.

rreusser avatar rreusser commented on September 15, 2024

(not that that should go into the module; only that it's what I'm usually really after.)

from ndarray-show.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.