GithubHelp home page GithubHelp logo

Comments (4)

lebigot avatar lebigot commented on August 23, 2024

Thank you for the heads up. I'll look into this missing feature.

EOL

On Thu, 16 Jun 2011, seibert wrote:

One direction of the multiplication operator between a float and a unumpy matrix seems to be missing:

>>> from uncertainties import unumpy, ufloat
>>> m = unumpy.matrix([[ufloat((1.0, 0.2))]])
>>> m * 0.5
matrix([[0.5+/-0.1]], dtype=object)
>>> 0.5 * m
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'float' and 'matrix'

However, this works just fine for a normal numpy matrix:

>>> import numpy
>>> m = numpy.matrix([[1.0]])
>>> m * 0.5
matrix([[ 0.5]])
>>> 0.5 * m
matrix([[ 0.5]])

from uncertainties.

lebigot avatar lebigot commented on August 23, 2024

0.5*m uses NumPy's dot function. The core of the problem seems to be the following non-symmetrical behavior of NumPy's dot functions (either from numpy.core.multiarray or from the optimized numpy.core._dotblas, which are the two possible sources for numpy.core.numeric.dot()):

>>> m2 = numpy.matrix([uncertainties.ufloat((1, 0.1))])
>>> numeric.dot(3, m2)
NotImplemented
>>> numeric.dot(m2, 3)
matrix([[3.0+/-0.3]], dtype=object)

Both work, for a matrix m2 of floats, but not for a matrix of objects. I am not sure that this behavior of NumPy is intended. I'll investigate this.

from uncertainties.

lebigot avatar lebigot commented on August 23, 2024

3*unumpy.matrix(…) works, in the new uncertainties version 1.7.3. I went around the apparent limitation in NumPy's dot() function. I'll contact NumPy's maintainers about the issue. Thank you for the heads up!

from uncertainties.

seibert avatar seibert commented on August 23, 2024

Great, thanks!

from uncertainties.

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.