Code Monkey home page Code Monkey logo

Comments (4)

AtheMathmo avatar AtheMathmo commented on May 28, 2024

Thanks for opening this issue. I'm not sure I can give a good answer to this one - the current implementation is definitely intentional.

I'll try to explain the reasoning:

In the current implementation sum_rows should be read as add all of the rows together. So in your example the matrix has 2 rows, each containing 3 elements. Adding these together should result in a single row with 3 elements. I believe your implementation would make more sense if read as sum along the rows.

I know that this disagrees with numpy for example - though they do explicitly state in the documentation that the sum is along the axis. I think at the very least this confusion should be eliminated in the rulinalg documentation. Or perhaps we should just adopt the along the axis convention.

I'll leave this issue open as I decide how best to handle this...

from rulinalg.

AtheMathmo avatar AtheMathmo commented on May 28, 2024

Actually it seems I wasn't remembering numpy's implementation correctly:

>>> import numpy as np
>>> a = np.array([[1,2,3],[4,5,6]])
>>> a.shape
(2,3)
>>> a.sum(0) # sum the rows
array([5, 7, 9])
>>> a.sum(1) # sum the cols
array([ 6, 15])

It seems that we do agree currently?

from rulinalg.

scholtzan avatar scholtzan commented on May 28, 2024

Yes, currently the results match those of numpy.
I didn't look at the numpy implementation at first so I didn't notice that the is sum calculated over the axis instead of along the axis.
Thank you for clarifying!

from rulinalg.

AtheMathmo avatar AtheMathmo commented on May 28, 2024

Of course!

In that case I'll close this issue and add a new one for improving the documentation a little. Thanks again for bringing this to my attention.

from rulinalg.

Related Issues (20)

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.