crystal-data / num.cr

Scientific computing in pure Crystal
MIT License
151 stars 12 forks source link

Documented tensor constructors missing in released num.cr #68

Closed nanobowers closed 3 years ago

nanobowers commented 3 years ago

Code Sample, a copy-pastable example if possible

Tensor(Float64).linear_space(a,b,c)
Tensor(T)#range, etc...

Problem description

API docs here https://crystal-data.github.io/num.cr/Tensor.html describe several constructor methods that are not available in any code that pulls the shard from the latest release which is confusing. Also range, etc. are missing. It's not clear to me if the methods have been intentionally removed, as they look like they were just added in #30 .

christopherzimmerman commented 3 years ago

Thanks for the issue. I think the root cause is two-fold. First, it seems that I broke the API generation, so that documentation is a bit old. Second, the documentation (when I fix it), will only reflect the master branch, rather than the most recent release (or the ability to view specific releases). Both of these issues need to be fixed.

I've mostly been focused on the 1.0 release with device-agnostic backends, but I should be able to get those other creation methods in a release without too much issue.

nanobowers commented 3 years ago

Thanks for the timely reply. I have been working on https://github.com/nanobowers/py2cr which is a port of py2rb but handles python type annotations and other Crystalisms where applicable. One part of py2rb was some rudimentary support for translating common methods in numpy to Numo::NArray. A user on the crystal discord chat was kind enough to recommend num.cr as a potential target for numpy in py2cr. Anyway, I was intrigued after reading the API docs, but my attempts to get some of the common constructors working (py: linspace, arange) were unsuccessful, hence the question.

It sounds like you have your hands full with the 1.0 release, but if there's anything I can do to help, either in terms of documentation, PRs to re-merge the other constructors, or features to support numpy style features, please drop me a line.

christopherzimmerman commented 3 years ago

I looked through your example, apart from the missing constructors, num.cr should support pretty much every numpy standard feature listed there. If you need any code examples for certain functionality, some can be a bit different since iteration is done rather than C, which exposes a lot more flexibility.

christopherzimmerman commented 3 years ago

@nanobowers I re-added the creation methods in question + fixed doc generation, you should be able to see a more accurate representation of the API here now: https://crystal-data.github.io/num.cr/