You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org> on 2025/01/03 16:12:57 UTC
[PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
ShaiviAgarwal2 opened a new pull request, #45160:
URL: https://github.com/apache/arrow/pull/45160
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
We have added the missing documentation for various tensor classes in PyArrow, specifically `SparseCOOTensor`, `SparseCSRMatrix`, `SparseCSCMatrix`, and `SparseCSFTensor`. This documentation is necessary to provide users with reference information and examples on how to use these classes, as currently, there is no reference documentation or information in the PyArrow user guide regarding these tensor classes.
### What changes are included in this PR?
1. Added docstrings to the `SparseCSRMatrix`, `SparseCSCMatrix`, and `SparseCSFTensor` classes and their methods in the `tensor.pxi` file.
2. Updated the `tables.rst` file to include documentation for `SparseCSFTensor` along with examples.
### Are these changes tested?
No new tests are included in this PR as the changes are purely documentation updates. The existing tests for the tensor classes should cover the functionality.
### Are there any user-facing changes?
Yes, the user-facing change is the addition of documentation for the tensor classes, which will help users understand and utilize these classes more effectively. There are no breaking changes to public APIs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2710544194
@ShaiviAgarwal2 if it would be easier you can also start fresh and create a new PR from latest main in favour of this one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2728177634
> @ShaiviAgarwal2 if it would be easier you can also start fresh and create a new PR from latest main in favour of this one?
Okk
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903086650
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
Yes. It's my suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903981393
##########
docs/source/python/api/tensors.rst:
##########
@@ -0,0 +1,114 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements. See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership. The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied. See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+
+.. _api.tensor:
+
+Tensors
+=======
+
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+^^^^^^^^^^^^^
+
+.. autosummary::
+ :toctree: ../generated/
+
+ Tensor
+
+Sparse Tensors
+^^^^^^^^^^^^^
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+"""SparseCOOTensor"""
+
+The ``SparseCOOTensor`` represents a sparse tensor in Coordinate (COO) format, where non-zero elements are stored as tuples of row and column indices.
Review Comment:
@AlenkaF Thanks for reviewing. Will do all the requested changes, soon!!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903248563
##########
docs/source/index.rst:
##########
@@ -115,6 +115,16 @@ Implementations
Rust <https://docs.rs/crate/arrow/>
status
+Tensors
+-------
+
+.. _toc.tensors:
+
+.. toctree::
+ :maxdepth: 2
+
+ <python/api/tensors.rst>
+
Review Comment:
Could you use `docs/source/python/api.rst` not `docs/source/index.rst`?
##########
docs/source/index.rst:
##########
@@ -127,3 +137,4 @@ Examples
Java cookbook <https://arrow.apache.org/cookbook/java/>
Python cookbook <https://arrow.apache.org/cookbook/py/>
R cookbook <https://arrow.apache.org/cookbook/r/>
+
Review Comment:
Could you revert a needless change?
##########
docs/source/python/api/tensors.rst:
##########
@@ -0,0 +1,114 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements. See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership. The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied. See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+
+.. _api.tensor:
+
+Tensors
+=======
+
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+^^^^^^^^^^^^^
+
+.. autosummary::
+ :toctree: ../generated/
+
+ Tensor
+
+Sparse Tensors
+^^^^^^^^^^^^^
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+"""SparseCOOTensor"""
Review Comment:
```suggestion
SparseCOOTensor
^^^^^^^^^^^^^^^
```
##########
docs/source/python/api/tensors.rst:
##########
@@ -0,0 +1,114 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements. See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership. The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied. See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+
+.. _api.tensor:
+
+Tensors
+=======
+
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+^^^^^^^^^^^^^
Review Comment:
Could you use `---...` like other file?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903257003
##########
docs/source/index.rst:
##########
@@ -115,6 +115,16 @@ Implementations
Rust <https://docs.rs/crate/arrow/>
status
+Tensors
+-------
+
+.. _toc.tensors:
+
+.. toctree::
+ :maxdepth: 2
+
+ <python/api/tensors.rst>
+
Review Comment:
okk sure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2585702469
Yes. If `master` doesn't exit, `git checkout master` must be failed.
BTW, it seems that your main https://github.com/ShaiviAgarwal2/arrow is too old:
> This branch is [1902 commits behind](https://github.com/ShaiviAgarwal2/arrow/compare/main...apache%3Aarrow%3Amain) apache/arrow:main.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-4150492653
Closing this PR as it appears from the comments that the changes will be made in a separate PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-4074285259
Thank you for your contribution. Unfortunately, this pull request has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this PR will be closed in 14 days. Feel free to re-open this if it has been closed in error. If you do not have repository permissions to reopen the PR, please tag a maintainer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1902968086
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
Should I create a new file named `tensors.rst` in the same directory as `tables.rst` (e.g., `docs/source/python/api/tensors.rst`) and then move tensor content to `tensors.rst` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903928003
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
Yeah, sure, the split to `tensors.rst` sounds fine 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic closed pull request #45160: GH-43352: [Docs][Python] Add all tensor classes documentation
URL: https://github.com/apache/arrow/pull/45160
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2582246806
@kou Could you please help me to resolve the conflicts caused!!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2585039562
> Hmm. What `git` commands did you use...? There are needless changes...
>
> It may be better that you create a new branch and open a new PR from it.
I use these commands inorder to resolve the conflicts but they didn't work !!
git checkout master
git pull
git checkout <branch>
git merge master
[ ... resolve any conflicts ... ]
git add [files that were conflicted]
git commit
git push
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2572824221
> There are some style corrections needed - I think @kou added all but they are marked as resolved - maybe we are missing a commit?
>
> I also added some comments regarding the code blocks and docstrings.
@AlenkaF Yes I marked as resolved but didn't submit the new commit as working on some checks that are failing
Will do the needful soon!!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903086730
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
@AlenkaF What do you think about this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2585039823
> Hmm. What `git` commands did you use...? There are needless changes...
>
> It may be better that you create a new branch and open a new PR from it.
Ok will now create a new branch and submit a new pr from it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2585654095
> > git checkout master
>
> Is this correct? It seems that your fork doesn't have `master`: https://github.com/ShaiviAgarwal2/arrow/branches/all?query=master&lastTab=overview Did you use `main` instead?
Yes i used `main`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1902258321
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
Could you use `"""..."?
BTW, we may should split tensor documentations to a separated file to avoid too deep section...
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
Review Comment:
Could you use `^^^...`?
See also: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2569479796
:warning: GitHub issue #43352 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2585116956
> git checkout master
Is this correct? It seems that your fork doesn't have `master`: https://github.com/ShaiviAgarwal2/arrow/branches/all?query=master&lastTab=overview
Did you use `main` instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1902258321
##########
docs/source/python/api/tables.rst:
##########
@@ -59,7 +59,92 @@ Dataframe Interchange Protocol
Tensors
-------
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+-------------
+
.. autosummary::
:toctree: ../generated/
Tensor
+
+Sparse Tensors
+--------------
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+### SparseCOOTensor
Review Comment:
Could you use `"""...`?
BTW, we may should split tensor documentations to a separated file to avoid too deep section...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "ShaiviAgarwal2 (via GitHub)" <gi...@apache.org>.
ShaiviAgarwal2 commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2571579826
@kou @AlenkaF Could you please review the recent updates?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2571590747
Revision: 59e8197732010390c2768a304579387fdcbf3883
Submitted crossbow builds: [ursacomputing/crossbow @ actions-8a25ed4ca3](https://github.com/ursacomputing/crossbow/branches/all?query=actions-8a25ed4ca3)
|Task|Status|
|----|------|
|preview-docs|[](https://github.com/ursacomputing/crossbow/actions/runs/12619068190/job/35163163120)|
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2571590264
@github-actions crossbow submit preview-docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on code in PR #45160:
URL: https://github.com/apache/arrow/pull/45160#discussion_r1903963210
##########
python/pyarrow/tensor.pxi:
##########
@@ -595,7 +595,25 @@ shape: {0.shape}""".format(self)
cdef class SparseCSRMatrix(_Weakrefable):
"""
- A sparse CSR matrix.
+ SparseCSRMatrix represents a sparse matrix in Compressed Sparse Row (CSR) format.
+
+ Attributes:
+ indptr : array
+ Index pointer array.
+ indices : array
+ Column indices of the corresponding non-zero values.
+ shape : tuple
+ Shape of the matrix.
+ dim_names : list, optional
+ Names of the dimensions.
+
+ Example:
+ >>> import pyarrow as pa
+ >>> indptr = pa.array([0, 2, 3])
+ >>> indices = pa.array([0, 2, 1])
+ >>> shape = (2, 3)
+ >>> tensor = pa.SparseCSRMatrix(indptr, indices, shape)
+ >>> print(tensor)
Review Comment:
Did you meant to use one of the `from_*` methods here?
We do not use `SparseCSRMatrix`'s constructor directly, see: https://github.com/apache/arrow/blob/ada8750917cd2ec2ae8a605d2673d78ef04c82e4/python/pyarrow/tensor.pxi#L617-L619
Could you change the example to use one of `pyarrow.SparseCSRMatrix.from_*` functions and also add examples in separate `pyarrow.SparseCSRMatrix.from_*` functions?
Attributes part should also be removed here (note we use NumPy style docstrings).
Could we also then add similar examples (with outputs) to other tensor formats/classes?
##########
docs/source/python/api/tensors.rst:
##########
@@ -0,0 +1,114 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements. See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership. The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied. See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+
+.. _api.tensor:
+
+Tensors
+=======
+
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+^^^^^^^^^^^^^
+
+.. autosummary::
+ :toctree: ../generated/
+
+ Tensor
+
+Sparse Tensors
+^^^^^^^^^^^^^
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+"""SparseCOOTensor"""
+
+The ``SparseCOOTensor`` represents a sparse tensor in Coordinate (COO) format, where non-zero elements are stored as tuples of row and column indices.
+
+Example:
+.. code-block:: python
+
+ import pyarrow as pa
+
+ indices = pa.array([[0, 0], [1, 2]])
+ data = pa.array([1, 2])
+ shape = (2, 3)
+
+ tensor = pa.SparseCOOTensor(indices, data, shape)
Review Comment:
We should use one of the `pyarrow.SparseCOOTensor.from_*` functions here and add the output from the print statement.
##########
docs/source/python/api/tensors.rst:
##########
@@ -0,0 +1,114 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements. See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership. The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied. See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+
+.. _api.tensor:
+
+Tensors
+=======
+
+PyArrow supports both dense and sparse tensors. Dense tensors store all data values explicitly, while sparse tensors represent only the non-zero elements and their locations, making them efficient for storage and computation.
+
+Dense Tensors
+^^^^^^^^^^^^^
+
+.. autosummary::
+ :toctree: ../generated/
+
+ Tensor
+
+Sparse Tensors
+^^^^^^^^^^^^^
+
+PyArrow supports the following sparse tensor formats:
+
+.. autosummary::
+ :toctree: ../generated/
+
+ SparseCOOTensor
+ SparseCSRMatrix
+ SparseCSCMatrix
+ SparseCSFTensor
+
+"""SparseCOOTensor"""
+
+The ``SparseCOOTensor`` represents a sparse tensor in Coordinate (COO) format, where non-zero elements are stored as tuples of row and column indices.
Review Comment:
I would add code examples to `docs/source/python/data.rst` and keep the reference docs cleaner.
We do not have a unified way of writing code blocks, [unfortunately](https://github.com/apache/arrow/issues/28859). But we do use prompt characters and add output, see example https://raw.githubusercontent.com/apache/arrow/refs/heads/main/docs/source/python/numpy.rst.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43352: [Docs][Python] Add all tensor classes documentation [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #45160:
URL: https://github.com/apache/arrow/pull/45160#issuecomment-2583910492
Hmm. What `git` commands did you use...? There are needless changes...
It may be better that you create a new branch and open a new PR from it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org