TheNeuralBit commented on code in PR #23296:
URL: https://github.com/apache/beam/pull/23296#discussion_r996170680


##########
sdks/python/apache_beam/typehints/pytorch_type_compatibility_test.py:
##########
@@ -0,0 +1,138 @@
+#
+# 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.
+#
+
+"""Unit tests for pytorch_type_compabitility."""
+
+import unittest
+
+import pytest
+from parameterized import parameterized
+from parameterized import parameterized_class
+
+from apache_beam.typehints import typehints
+from apache_beam.typehints.batch import BatchConverter
+from apache_beam.typehints.batch import N
+
+# Protect against environments where pytorch library is not available.
+# pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports
+try:
+  import torch
+  from apache_beam.typehints.pytorch_type_compatibility import PytorchTensor
+except ImportError:
+  raise unittest.SkipTest('PyTorch dependencies are not installed')
+
+
+@parameterized_class([
+    {
+        'batch_typehint': torch.Tensor,
+        'element_typehint': PytorchTensor[torch.int32, ()],
+        'batch': torch.tensor(range(100), dtype=torch.int32)
+    },
+    {
+        'batch_typehint': PytorchTensor[torch.int64, (N, 10)],
+        'element_typehint': PytorchTensor[torch.int64, (10, )],
+        'batch': torch.tensor([list(range(i, i + 10)) for i in range(100)],
+                              dtype=torch.int64),
+    },
+])
[email protected]_pytorch
+class DataFrameBatchConverterTest(unittest.TestCase):

Review Comment:
   nit: copy-paste error
   ```suggestion
   class PytorchBatchConverterTest(unittest.TestCase):
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to