mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15250 This adds `__repr__` methods to all of the classes under task.py. This makes the objects much easier to interact with when using them in an interactive manner, such as in a Jupyter notebook. The default `__repr__` method just returns the object ID which is very unhelpful. Reviewed By: hanli0612 Differential Revision: D13475758 fbshipit-source-id: 6e1b166ec35163b9776c797b6a2e0d002560cd29
25 lines
858 B
Python
25 lines
858 B
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
|
|
import unittest
|
|
from caffe2.python import task
|
|
|
|
|
|
class TestTask(unittest.TestCase):
|
|
def testRepr(self):
|
|
cases = [
|
|
(task.Cluster(), "Cluster(nodes=[], node_kwargs={})"),
|
|
(task.Node(), "Node(name=local, kwargs={})"),
|
|
(
|
|
task.TaskGroup(),
|
|
"TaskGroup(tasks=[], workspace_type=None, remote_nets=[])",
|
|
),
|
|
(task.TaskOutput([]), "TaskOutput(names=[], values=None)"),
|
|
(task.Task(), "Task(name=local/task, node=local, outputs=[])"),
|
|
(task.SetupNets(), "SetupNets(init_nets=None, exit_nets=None)"),
|
|
]
|
|
for obj, want in cases:
|
|
self.assertEqual(obj.__repr__(), want)
|