:param kwargs: Pass lists to distribute as lists, lists that should be passed intact as tuples.
  :return: results, in the format [(arguments, results)].  Also saved to json at resultName, in the same format.
437800
def runMultiprocessNoiseExperiment(resultName=None, numWorkers = 0, **kwargs):
  

  if resultName is None:
    resultName = str(kwargs) + ".json"

  experiments = [{}]
  for key, values in kwargs.items():
    if type(values) is list:
      newExperiments = []
      for experiment in experiments:
        for val in values:
          newExperiment = copy(experiment)
          newExperiment[key] = val
          newExperiments.append(newExperiment)
      experiments = newExperiments
    else:
      [a.__setitem__(key, values) for a in experiments]

  if numWorkers == 0:
    numWorkers = cpu_count()
  if numWorkers > 1:
    pool = Pool(processes=numWorkers)
    rs = pool.map_async(experimentWrapper, experiments, chunksize=1)
    while not rs.ready():
      remaining = rs._number_left
      pctDone = 100.0 - (100.0*remaining) / len(experiments)
      print "    => {} experiments remaining, percent complete={}".format(\
        remaining, pctDone)
      time.sleep(5)
    pool.close()  # No more work
    pool.join()
    result = rs.get()
  else:
    result = []
    for arg in experiments:
      result.append(doExperiment(**arg))

  # Save results for later use
  results = [(arg,res) for arg, res in zip(experiments, result)]
  with open(resultName,"wb") as f:
    json.dump(results,f)

  return results
313810
def saturate_kwargs(keys, **kwargs):
    
    # Validate if keys are in kwargs and if they are iterable
    if isinstance(keys, str): keys = [keys]
    keys = [k for k in keys if k in kwargs and hasattr(kwargs.get(k, None), '__iter__')]
    if len(keys) == 0: return []

    # Saturate coordinates of kwargs
    kw_corr = list(product(*(range(len(kwargs[k])) for k in keys)))

    # Append all possible values
    kw_arr = []
    for corr in kw_corr: kw_arr.append(
        dict(zip(keys, [kwargs[keys[i]][corr[i]] for i in range(len(keys))]))
    )

    # All combinations of kwargs of inputs
    for k in keys: kwargs.pop(k, None)
    kw_arr = [{**k, **kwargs} for k in kw_arr]

    return kw_arr
1241894
def pop_kwargs(kwargs,
               names_with_defaults,  # type: List[Tuple[str, Any]]
               allow_others=False
               ):
    
    all_arguments = []
    for name, default_ in names_with_defaults:
        try:
            val = kwargs.pop(name)
        except KeyError:
            val = default_
        all_arguments.append(val)

    if not allow_others and len(kwargs) > 0:
        raise ValueError("Unsupported arguments: %s" % kwargs)

    if len(names_with_defaults) == 1:
        return all_arguments[0]
    else:
        return all_arguments
585665
def map_arguments(self, arguments):
        
        if self.argument_mappings is None:
            return arguments

        return [f(a) for f, a in zip(self.argument_mappings, arguments)]
56411
def get_kwargs(**kwargs):
        
        d = dict()
        for k, v in kwargs.iteritems():
            if v is not NOTSET:
                d[k] = v
        return d
499674
def results(self):
        
        self.__init()
        for k,v in self._results.items():
            param = self._get_json(v['paramUrl'])
            if param['dataType'] == "GPFeatureRecordSetLayer":
                self._results[k] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
            elif param['dataType'].lower().find('gpmultivalue') > -1:
                self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPString":
                self._results[k] = GPString.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPLong":
                self._results[k] = GPLong.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPDouble":
                self._results[k] = GPDouble.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPDate":
                self._results[k] = GPDate.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPBoolean":
                self._results[k] = GPBoolean.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPDataFile":
                self._results[k] = GPDataFile.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPLinearUnit":
                self._results[k] = GPLinearUnit.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPMultiValue":
                self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPRasterData":
                self._results[k] = GPRasterData.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPRasterDataLayer":
                self._results[k] = GPRasterDataLayer.fromJSON(json.dumps(param))
            elif param['dataType'] == "GPRecordSet":
                self._results[k] = GPRecordSet.fromJSON(json.dumps(param))
        return self._results
1211602
def expandParameters(*args):
    
    count = 1
    for arg in args:
        count = max(len(arg[0]), count)
    results = []
    for arg in args:
        results.append(expandValues(arg[0], count, args[1]))
    return tuple(results)
753575
def extract_kwargs(names:Collection[str], kwargs:KWArgs):
    ""
    new_kwargs = {}
    for arg_name in names:
        if arg_name in kwargs:
            arg_val = kwargs.pop(arg_name)
            new_kwargs[arg_name] = arg_val
    return new_kwargs, kwargs
533788
def result(self, *args, **kwargs):
        
        prettify = kwargs.get('pretty', False)

        sql = 'CREATE %s %s' % (self._type, self._class)
        
        if prettify:
            sql += '\n'
        else:
            sql += ' '

        if self._type.lower() == 'edge':
            sql += " FROM %s TO %s " % (self._from, self._to)
        
        if self._cluster:
            sql += 'CLUSTER %s' % self._cluster
            if prettify:
                sql += '\n'
            else:
                sql += ' '
        
        if self.data:
            sql += 'CONTENT ' + json.dumps(self.data)
        return sql
565326
def list(self, **kwds):
        
        tags = self._client.get("/tags/list.json", **kwds)["result"]
        tags = self._result_to_list(tags)
        return [Tag(self._client, tag) for tag in tags]
700824
def list(self, **kwargs):
        
        projects = Project.select().order_by(Project.name)
        if len(projects) == 0:
            self._print('No projects available', 'yellow')
            return

        for project in projects:
            project_repr = self._PROJECT_ITEM.format(project.name, project.path)
            row = '- {}'.format(self._PROJECT_ITEM.format(project.name, project.path))
            six.print_(row)
331823
def results(self):
        ""
        if self._results is None:
            results = self._json_struct['results']
            def result_iterator():
                for result in results:
                    datatype = None
                    conversion = None
                    for param in self.parent.parameters:
                        if param['name'] == result['paramName']:
                            datatype = param['datatype']
                    if datatype is None:
                        conversion = str
                    else:
                        conversion = datatype.fromJson
                    dt = result['paramName']
                    val = conversion(result['value'])
                    yield (dt, val)
            self._results = dict(res for res in result_iterator())
        return self._results
196849
def lists(self, **kwargs):
        
        path = self._get_path('lists')

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response
799257
def print_results(results):
    
    if not isinstance(results, list):
        results = [results]

    for r in results:
        try:
            r.log()
        except AttributeError:
            raise ValueError('Argument to print_results() must be a list of '
                             'FileValidationResults or ObjectValidationResults.')
1242899
def kwargs(self):
        
        keywords = self.keywords or []
        return [keyword for keyword in keywords if keyword.arg is None]
136906
def prepare_args(self, args, kwargs):
        
        args, kwargs = super().prepare_args(args, kwargs)
        form_kwargs = self.get_form_kwargs()
        self.form = self.Form(**form_kwargs)
        return args, kwargs
196313
def _prepare_results(self, results):
        
        if self._instances:
            results = self._to_instances(results)
        else:
            results = list(results)

        # cache the len for future use
        self._len = len(results)

        return results