You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/01 12:56:31 UTC

[GitHub] [arrow] lidavidm opened a new pull request #10641: ARROW-13236: [Python] Include options class name in repr

lidavidm opened a new pull request #10641:
URL: https://github.com/apache/arrow/pull/10641


   


-- 
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



[GitHub] [arrow] kszucs commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
kszucs commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662944354



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,14 +137,17 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)
         buf = option.serialize()
         deserialized = pc.FunctionOptions.deserialize(buf)
         assert option == deserialized
         assert repr(option) == repr(deserialized)
     for option1, option2 in zip(options, options[1:]):
         assert option1 != option2
 
+    assert repr(pc.IndexOptions(pa.scalar(1))) == "IndexOptions{value=int64:1}"
+    assert repr(pc.ArraySortOptions()) == "ArraySortOptions{order=Ascending}"

Review comment:
       ~~I'd prefer `(..)` as well.~~ Seems like it has been updated already.




-- 
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



[GitHub] [arrow] pitrou commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662392655



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,7 +137,7 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)

Review comment:
       Can you test the actual repr for one or two classes somewhere?




-- 
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



[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662405131



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,14 +137,17 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)
         buf = option.serialize()
         deserialized = pc.FunctionOptions.deserialize(buf)
         assert option == deserialized
         assert repr(option) == repr(deserialized)
     for option1, option2 in zip(options, options[1:]):
         assert option1 != option2
 
+    assert repr(pc.IndexOptions(pa.scalar(1))) == "IndexOptions{value=int64:1}"
+    assert repr(pc.ArraySortOptions()) == "ArraySortOptions{order=Ascending}"

Review comment:
       Small nit, for Python it might be nice to use `(..)` instead of `{..}` (do the curly braces make more sense for C++? Also there instantiating the class uses round brackets?)




-- 
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



[GitHub] [arrow] lidavidm commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
lidavidm commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662398619



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,7 +137,7 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)

Review comment:
       I added some assertions at the bottom of the test.




-- 
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



[GitHub] [arrow] kszucs closed pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
kszucs closed pull request #10641:
URL: https://github.com/apache/arrow/pull/10641


   


-- 
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



[GitHub] [arrow] pitrou commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662439221



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,14 +137,17 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)
         buf = option.serialize()
         deserialized = pc.FunctionOptions.deserialize(buf)
         assert option == deserialized
         assert repr(option) == repr(deserialized)
     for option1, option2 in zip(options, options[1:]):
         assert option1 != option2
 
+    assert repr(pc.IndexOptions(pa.scalar(1))) == "IndexOptions{value=int64:1}"
+    assert repr(pc.ArraySortOptions()) == "ArraySortOptions{order=Ascending}"

Review comment:
       `()` would be more typical, but here the representation isn't roundtrippable anyway.




-- 
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



[GitHub] [arrow] lidavidm commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
lidavidm commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662438080



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,14 +137,17 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)
         buf = option.serialize()
         deserialized = pc.FunctionOptions.deserialize(buf)
         assert option == deserialized
         assert repr(option) == repr(deserialized)
     for option1, option2 in zip(options, options[1:]):
         assert option1 != option2
 
+    assert repr(pc.IndexOptions(pa.scalar(1))) == "IndexOptions{value=int64:1}"
+    assert repr(pc.ArraySortOptions()) == "ArraySortOptions{order=Ascending}"

Review comment:
       Would `<>` be more typical for Python? We can slice in __repr__ here and replace with our own braces.
   
   For C++, you can generally use either parens or curly braces. But the only reason why curly braces are used here is because that's what Expression::ToString did before the refactor, and I assume there it's so things would print like `cast(..., {...})` instead of `cast(..., (...))`, i.e. to not nest parentheses too much.




-- 
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



[GitHub] [arrow] kszucs commented on a change in pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
kszucs commented on a change in pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#discussion_r662944354



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -137,14 +137,17 @@ def test_option_class_equality():
                 pytest.fail(f"Options class is not tested: {cls}")
     for option in options:
         assert option == option
-        assert repr(option)
+        assert repr(option).startswith(option.__class__.__name__)
         buf = option.serialize()
         deserialized = pc.FunctionOptions.deserialize(buf)
         assert option == deserialized
         assert repr(option) == repr(deserialized)
     for option1, option2 in zip(options, options[1:]):
         assert option1 != option2
 
+    assert repr(pc.IndexOptions(pa.scalar(1))) == "IndexOptions{value=int64:1}"
+    assert repr(pc.ArraySortOptions()) == "ArraySortOptions{order=Ascending}"

Review comment:
       I'd prefer `(..)` as well.




-- 
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



[GitHub] [arrow] github-actions[bot] commented on pull request #10641: ARROW-13236: [Python] Include options class name in repr

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10641:
URL: https://github.com/apache/arrow/pull/10641#issuecomment-872223237


   https://issues.apache.org/jira/browse/ARROW-13236


-- 
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