summaryrefslogtreecommitdiff
path: root/torch/_utils.py
diff options
context:
space:
mode:
authorAdam Paszke <adam.paszke@gmail.com>2016-09-19 09:15:12 -0700
committerAdam Paszke <adam.paszke@gmail.com>2016-09-20 08:40:28 -0700
commit8fdec15a55527001c2692675126146529e158fcc (patch)
tree5f1a5aa9883dec8e43147e35ad5fe0be96837f3a /torch/_utils.py
parent0f7a1e27d0ad1b85d5e26f51552228e818b83d5f (diff)
downloadpytorch-8fdec15a55527001c2692675126146529e158fcc.tar.gz
pytorch-8fdec15a55527001c2692675126146529e158fcc.tar.bz2
pytorch-8fdec15a55527001c2692675126146529e158fcc.zip
Codemod to remove camel case method naming
Diffstat (limited to 'torch/_utils.py')
-rw-r--r--torch/_utils.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/torch/_utils.py b/torch/_utils.py
index be1e2bf4e7..9667c1e2aa 100644
--- a/torch/_utils.py
+++ b/torch/_utils.py
@@ -1,5 +1,3 @@
-import torch
-
def _type(self, t=None):
if isinstance(t, str) or t is None:
@@ -9,9 +7,21 @@ def _type(self, t=None):
if t == current:
return self
_, _, typename = t.partition('.')
- return torch._import_dotted_name(t)(self.size()).copy_(self)
+ return _import_dotted_name(t)(self.size()).copy_(self)
else:
if t == type(self):
return self
return t(self.size()).copy_(self)
+
+def _range(*args, **kwargs):
+ return __builtins__['range'](*args, **kwargs)
+
+
+def _import_dotted_name(name):
+ components = name.split('.')
+ obj = __import__(components[0])
+ for component in components[1:]:
+ obj = getattr(obj, component)
+ return obj
+