
from collections import namedtuple


def identity(results):
    return results


def tuplify(results, class_name='Result'):
    if 'fields' in results and 'items' in results:
        return _tuplify_timeseries(results, class_name)
    return _tuplify_dict(results, class_name)


def _tuplify_timeseries(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results['fields'])
    return map(nt._make, results['items'])


def _tuplify_dict(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results.keys())
    return nt(**results)


from collections import namedtuple


def identity(results):
    return results


def tuplify(results, class_name='Result'):
    if 'fields' in results and 'items' in results:
        return _tuplify_timeseries(results, class_name)
    return _tuplify_dict(results, class_name)


def _tuplify_timeseries(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results['fields'])
    return [nt(*item) for item in results['items']]


def _tuplify_dict(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results.keys())
    return nt(**results)

Replace map with a list comprehension.
Replace map with a list comprehension.

  
  from collections import namedtuple
  
  
  def identity(results):
      return results
  
  
  def tuplify(results, class_name='Result'):
      if 'fields' in results and 'items' in results:
          return _tuplify_timeseries(results, class_name)
      return _tuplify_dict(results, class_name)
  
  
  def _tuplify_timeseries(results, class_name):
      tuple_name = '{name}Tuple'.format(name=class_name)
      nt = namedtuple(tuple_name, results['fields'])
-     return map(nt._make, results['items'])
+     return [nt(*item) for item in results['items']]
  
  
  def _tuplify_dict(results, class_name):
      tuple_name = '{name}Tuple'.format(name=class_name)
      nt = namedtuple(tuple_name, results.keys())
      return nt(**results)
  
Replace map with a list comprehension.
## Code Before:

from collections import namedtuple


def identity(results):
    return results


def tuplify(results, class_name='Result'):
    if 'fields' in results and 'items' in results:
        return _tuplify_timeseries(results, class_name)
    return _tuplify_dict(results, class_name)


def _tuplify_timeseries(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results['fields'])
    return map(nt._make, results['items'])


def _tuplify_dict(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results.keys())
    return nt(**results)

## Instruction:
Replace map with a list comprehension.
## Code After:

from collections import namedtuple


def identity(results):
    return results


def tuplify(results, class_name='Result'):
    if 'fields' in results and 'items' in results:
        return _tuplify_timeseries(results, class_name)
    return _tuplify_dict(results, class_name)


def _tuplify_timeseries(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results['fields'])
    return [nt(*item) for item in results['items']]


def _tuplify_dict(results, class_name):
    tuple_name = '{name}Tuple'.format(name=class_name)
    nt = namedtuple(tuple_name, results.keys())
    return nt(**results)
