How to use the pysnooper.utils function in PySnooper

To help you get started, we’ve selected a few PySnooper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zasdfgbnm / TorchSnooper / torchsnooper / View on Github external
def compute_repr(self, x):
        orig_repr_func = pysnooper.utils.get_repr_function(x, self.orig_custom_repr)
        if torch.is_tensor(x):
            return self.tensor_format(x)
        elif isinstance(x, numpy.ndarray):
            return self.numpy_format(x)
        elif self.is_return_types(x):
            return self.return_types_repr(x)
        elif orig_repr_func is not repr:
            return orig_repr_func(x)
        elif isinstance(x, (list, tuple)):
            content = ''
            for i in x:
                if content != '':
                    content += ', '
                content += self.compute_repr(i)
            if isinstance(x, tuple) and len(x) == 1:
                content += ','