Skip to content
Permalink
Browse files

Fixes *a or **kw calls

'* or ** magic' as pylint calls it.
  • Loading branch information...
remram44 committed Apr 21, 2014
1 parent dc6e0b2 commit a8cc47591a97a1d61ffefe0cc9155384026675aa
@@ -39,7 +39,6 @@
import scipy
import tempfile

from vistrails.core.bundles import py_import
from vistrails.core.data_structures.bijectivedict import Bidict
from vistrails.core.utils import append_to_dict_of_lists

@@ -53,15 +52,11 @@
# EigenBase

def mzeros(*args, **kwargs):
nkwargs = copy.copy(kwargs)
nkwargs['dtype'] = float
az = scipy.zeros(*args, **nkwargs)
az = scipy.zeros(*args, dtype=float, **kwargs)
return scipy.matrix(az)

def mones(*args, **kwargs):
nkwargs = copy.copy(kwargs)
nkwargs['dtype'] = float
az = scipy.ones(*args, **nkwargs)
az = scipy.ones(*args, dtype=float, **kwargs)
return scipy.matrix(az)

#mzeros = lambda *args, **kwargs: scipy.matrix(scipy.zeros(*args, **kwargs))
@@ -404,10 +399,9 @@ def solve(self):
class EigenPipelineSimilarity2(EigenBase):

def __init__(self, *args, **kwargs):
basekwargs = copy.copy(kwargs)
del basekwargs['alpha']
EigenBase.__init__(self, *args, **basekwargs)
self.init_operator(alpha=kwargs['alpha'])
alpha = kwargs.pop('alpha')
EigenBase.__init__(self, *args, **kwargs)
self.init_operator(alpha=alpha)

def init_operator(self, alpha):
def edges(pip, v_id):
@@ -66,13 +66,11 @@ def _process_attr_value(self, attr_name, value):
if self._module.has_port_spec(attr_name, 'input'):
port_spec = self._module.get_port_spec(attr_name, 'input')

args = None
# FIXME want this to be any iterable
if isinstance(value, tuple):
args = value
self._update_func(port_spec, *value)
else:
args = (value,)
self._update_func(port_spec, *args)
self._update_func(port_spec, value)
else:
raise AttributeError("type object '%s' has no "
"attribute '%s'" % \
@@ -132,15 +130,15 @@ def _update_func(self, port_spec, *args, **kwargs):
# print 'update literal', type(value), value
num_params += 1
if num_ports > 1 or (num_ports == 1 and num_params > 0):
reg = vistrails.core.modules.module_registry.get_module_registry()
reg = get_module_registry()
tuple_desc = reg.get_descriptor_by_name(basic_pkg, 'Tuple')
tuple_module = vt_api.add_module_from_descriptor(tuple_desc)
output_port_spec = PortSpec(id=-1,
name='value',
type='output',
sigstring=port_spec.sigstring)
vt_api.add_port_spec(tuple_module, output_port_spec)
self._update_func(port_spec, *[tuple_module.value()])
self._update_func(port_spec, tuple_module.value())
assert len(port_spec.descriptors()) == len(args)
for i, descriptor in enumerate(port_spec.descriptors()):
arg_name = 'arg%d' % i
@@ -290,17 +290,18 @@ def create_vistrail_entity(self, vistrail):

def update_from_database(self, db_locator):
# db_conn = db_locator.get_connection()
config = (('host', db_locator._host),
('port', int(db_locator._port)),
('db', db_locator._db),
('user', db_locator._user),
('passwd', db_locator._passwd))
rows = vistrails.db.services.io.get_db_object_list(dict(config), 'vistrail')
config = {'host': db_locator._host,
'port': int(db_locator._port),
'db': db_locator._db,
'user': db_locator._user,
'passwd': db_locator._passwd}
rows = vistrails.db.services.io.get_db_object_list(config, 'vistrail')
for row in rows:
if row[0] in [1,]:
continue
kwargs = {'obj_type': 'vistrail', 'obj_id': row[0]}
locator = DBLocator(*[x[1] for x in config], **kwargs)
locator = DBLocator(config['host'], config['port'], config['db'],
config['user'], config['passwd'],
obj_type='vistrail', obj_id=row[0])
(vistrail, abstractions, thumbnails, mashups) = load_vistrail(locator)
vistrail.abstractions = abstractions
vistrail.thumbnails = thumbnails
@@ -379,14 +379,13 @@ def test_tuple(self):
package='org.vistrails.vistrails.console_mode_test',
version='0.9.1')
module.add_function(function)

p.add_module(module)

kwargs = {'locator': XMLFileLocator('foo'),
'current_version': 1L,
'view': v,
}
interpreter.execute(p, **kwargs)

interpreter.execute(p,
locator=XMLFileLocator('foo'),
current_version=1L,
view=v)

def test_python_source(self):
locator = XMLFileLocator(vistrails.core.system.vistrails_root_directory() +
@@ -144,9 +144,19 @@ def parse_port_spec_string(p_string, cur_package=None):


def create_port_spec_string(specs_list, old_style=False):
return '(' + ','.join(create_port_spec_item_string(
*(specs + ((None, old_style) if len(specs) < 3 else (old_style,))))
for specs in specs_list) + ')'
spec_items = []
for specs in specs_list:
if len(specs) == 3:
pkg, name, ns = specs
elif len(specs) == 2:
pkg, name = specs
ns = None
else:
raise TypeError("create_port_spec_string() got spec tuple "
"with %d elements" % len(specs))
spec_items.append(create_port_spec_item_string(pkg, name, ns,
old_style))
return '(%s)' % ','.join(spec_items)

def expand_port_spec_string(p_string, cur_package=None,
old_style=False):
@@ -801,11 +801,8 @@ def create_functions_static(id_scope, module, functions):
-> [ModuleFunction]
"""
new_functions = []
static_call = VistrailController.create_function_static
for f in functions:
new_functions.append(static_call(id_scope, module, *f))
return new_functions
return [static_call(id_scope, module, *f) for f in functions]

def create_port_spec(self, *args, **kwargs):
return self.create_port_spec_static(self.id_scope, *args, **kwargs)

0 comments on commit a8cc475

Please sign in to comment.
You can’t perform that action at this time.