Comments (4)
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.
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.
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.
Great, thanks!
from uncertainties.
Related Issues (20)
- TypeError: can't convert an affine function (<class 'uncertainties.core.AffineScalarFunc'>) to float; use x.nominal_value HOT 2
- Type Annotation Checker Problems with UFloat HOT 6
- uncompatibility with Python3.12 HOT 4
- package maintanence HOT 65
- [3.1.7] SyntaxWarning: invalid escape sequence '\<something>' with Python 3.12 HOT 2
- Unintuitive class behaviour HOT 1
- Pandas sort_values with multiple columns does not work for AffineScalarFunc HOT 1
- Add uploading code coverage to codecov to github action HOT 3
- code coverage not uploading for master branch HOT 6
- Lacks basic VSCode settings for running pytest tests with VSCode. HOT 6
- Replace documentation references from nose unit tests to pytest unit tests.
- Remove unused imports in tests. HOT 1
- Add CITATION.cff file HOT 6
- Changelog maintenance plan HOT 2
- Review numpy API coverage
- `tests/helpers.py` is missing in 3.2.0 PyPI sdist HOT 2
- Import error in autopkgtests -missing unumpy HOT 1
- readthedocs docs not building HOT 6
- Trailing decimal symbol test failing HOT 3
- Strange behavior on copying
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uncertainties.