{"action":"created","issue":{"url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/138","repository_url":"https://api.github.com/repos/QuantStack/xtensor-python","labels_url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/138/labels{/name}","comments_url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/138/comments","events_url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/138/events","html_url":"https://github.com/QuantStack/xtensor-python/issues/138","id":295122306,"number":138,"title":"Is there any custom type cast defined for `xtensor` and `xarray`? ","user":{"login":"Roger-luo","id":8445510,"avatar_url":"https://avatars2.githubusercontent.com/u/8445510?v=4","gravatar_id":"","url":"https://api.github.com/users/Roger-luo","html_url":"https://github.com/Roger-luo","followers_url":"https://api.github.com/users/Roger-luo/followers","following_url":"https://api.github.com/users/Roger-luo/following{/other_user}","gists_url":"https://api.github.com/users/Roger-luo/gists{/gist_id}","starred_url":"https://api.github.com/users/Roger-luo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roger-luo/subscriptions","organizations_url":"https://api.github.com/users/Roger-luo/orgs","repos_url":"https://api.github.com/users/Roger-luo/repos","events_url":"https://api.github.com/users/Roger-luo/events{/privacy}","received_events_url":"https://api.github.com/users/Roger-luo/received_events","type":"User","site_admin":false},"labels":[{"id":667934606,"url":"https://api.github.com/repos/QuantStack/xtensor-python/labels/Question","name":"Question","color":"ff4081","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-02-07T12:38:12Z","updated_at":"2018-02-07T14:09:12Z","closed_at":"2018-02-07T14:09:12Z","author_association":"NONE","body":"I tried this based on example 1, but it seems that there no type casters like pybind11's `stl.h` which will auto-cast `std::vector` and etc. to python types.\r\n\r\n```c++\r\ndouble _sum_of_sines(xt::xarray<double> &m)\r\n{\r\n  auto sines = xt::sin(m);\r\n  return std::accumulate(sines.cbegin(), sines.cend(), 0.0);\r\n}\r\n\r\ndouble sum_of_sines(xt::pyarray<double> &m)\r\n{\r\n  return _sum_of_sines(m.cast<xt::xarray<double>>());\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/comments/363779694","html_url":"https://github.com/QuantStack/xtensor-python/issues/138#issuecomment-363779694","issue_url":"https://api.github.com/repos/QuantStack/xtensor-python/issues/138","id":363779694,"user":{"login":"Roger-luo","id":8445510,"avatar_url":"https://avatars2.githubusercontent.com/u/8445510?v=4","gravatar_id":"","url":"https://api.github.com/users/Roger-luo","html_url":"https://github.com/Roger-luo","followers_url":"https://api.github.com/users/Roger-luo/followers","following_url":"https://api.github.com/users/Roger-luo/following{/other_user}","gists_url":"https://api.github.com/users/Roger-luo/gists{/gist_id}","starred_url":"https://api.github.com/users/Roger-luo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roger-luo/subscriptions","organizations_url":"https://api.github.com/users/Roger-luo/orgs","repos_url":"https://api.github.com/users/Roger-luo/repos","events_url":"https://api.github.com/users/Roger-luo/events{/privacy}","received_events_url":"https://api.github.com/users/Roger-luo/received_events","type":"User","site_admin":false},"created_at":"2018-02-07T14:09:11Z","updated_at":"2018-02-07T14:09:11Z","author_association":"NONE","body":"@wolfv Oh, thanks, it works. So I guess both implementation would works. But I have to specify the type to be `xexpression<pyarray<double>>` while binding it to python according to the post. \r\n\r\n@SylvainCorlay this is a really cool post. I'm developing a quantum many-body physics toolkit and I was trying to write something similar based on [mshadow](https://github.com/dmlc/mshadow), just find your guys have already done. I'll continue my project with your package. Thanks a lot. "}}
{"actor":{"display_login":"Roger-luo"}}