Comments (4)
Most functions do not have compile-time checks for this. There could indeed be static assertions for many functions that are easy or less easy to write, but for the moment this is not xtensor's policy. There are run-time assertions I believe. You could compile with XTENSOR_ENABLE_ASSERT
which should fire a runtime error : https://xtensor.readthedocs.io/en/latest/dev-build-options.html#build
As background information, it seems that upon construction the 2d return array tries to read the second dimension of vector
. Since it is not part of vector
's memory you simply get rubbish.
from xtensor-python.
Yes sorry, the C-T checking was just an aside; this example just illustrates why I like it and why it generates frustration to leave things to runtime.
I am using xtensor and the python module from conda-forge, updated the above with versions.
Just realised whilst describing this to a friend - is this a problem with the shape types? I assume the insane size NumPy wants to allocate is due to junk on the stack. Has it run pat the end of the std::array, expecting it to have two elements, but as a vector expression, size() is returning an array with just one? If so, I'd expect whichever side is responsible (python or BLAS) to be checking both for dimensional consistency of the shape, but also that the length of the shape (i.e. number of dimensions) is suitable.
from xtensor-python.
I also noted there's nothing stopping me from writing:
xt::pytensor<int, 1> a(...);
xt::pytensor<int, 2> b(...);
a = b;
Or equally the same with regular xtensor
s. I'd assumed that as they're templated this should be illegal - is everything checked at runtime rather than compile-time then?
from xtensor-python.
Indeed!
Personally, I'm not strictly against adding compile-time assertions. However, it would increase compile time, and I find this already somewhat long on many occasions. For me run-time assertions offer enough safety : I just run once with xtensor assertions and then never again. However, if you are willing to make the case of compile-time assertions and think about implementation I will for sure not stop you ;)
from xtensor-python.
Related Issues (20)
- Release to Pybind 2.5 HOT 1
- Cannot compile python bindings
- Is this a valid way of interfacing xtensor with python? HOT 4
- Bug in sort
- Enable load cast `xt::xtensor<...>`
- Error with strided view
- is:issue how to sum string type load from csv? and how to convert string column to timestamp? HOT 1
- The URL listed on the project's page is a broken link HOT 1
- Doesn't install the python binding HOT 4
- Tests fail to find Python.h HOT 6
- Segmentation fault of MSVC 19
- Broadcasting problem on basic operations? HOT 5
- Retrieving xt::pyarray when embedding python using pybind11 HOT 1
- Add support for nanobind? HOT 5
- Support for custom types? HOT 1
- problem calculating quantile on pytensor HOT 7
- Build C++ XTensor project as Python package so users can `pip install` without any additional dependencies
- How to convert xt::pyarray to xt::xarray? HOT 1
- /home/mona/anaconda3/envs/zephyr/include/xtensor-python/pycontainer.hpp:30:10: fatal error: numpy/arrayobject.h: No such file or directory HOT 2
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 xtensor-python.