# Buggy code
def run(self, workspace):
    if self.show_window:
        m = workspace.get_measurements()
        # Get plates
        plates = m.get_all_measurements(cpmeas.IMAGE, self.plate_name.value)
        # Get wells
        if self.well_format == WF_NAME:
            wells = m.get_all_measurements(cpmeas.IMAGE, self.well_name.value)
        elif self.well_format == WF_ROWCOL:
            wells = [
                "%s%s" % (x, y)
                for x, y in zip(
                    m.get_all_measurements(cpmeas.IMAGE, self.well_row.value),
                    m.get_all_measurements(cpmeas.IMAGE, self.well_col.value),
                )
            ]
        # Get data to plot
        data = m.get_all_measurements(self.get_object(), self.plot_measurement.value)

        # Construct a dict mapping plates and wells to lists of measurements
        pm_dict = {}
        for plate, well, data in zip(plates, wells, data):
            if data is None:
                continue
            if plate in pm_dict:
                if well in pm_dict[plate]:
                    pm_dict[plate][well] += [data]
                else:
                    pm_dict[plate].update({well: [data]})
            else:
                pm_dict[plate] = {well: [data]}

        for plate, sub_dict in pm_dict.items():
            for well, vals in sub_dict.items():
                vals = np.hstack(vals)
                if self.agg_method == AGG_AVG:
                    pm_dict[plate][well] = np.mean(vals)
                elif self.agg_method == AGG_STDEV:
                    pm_dict[plate][well] = np.std(vals)
                elif self.agg_method == AGG_MEDIAN:
                    pm_dict[plate][well] = np.median(vals)
                elif self.agg_method == AGG_CV:
                    pm_dict[plate][well] = np.std(vals) / np.mean(vals)
                else:
                    raise NotImplemented
        workspace.display_data.pm_dict = pm_dict


# Traceback (TypeError)
Traceback (most recent call last):
File "D:\Trunk\CellProfiler\cellprofiler\gui\pipelinecontroller.py", line 2777, in do_step
module.display(workspace, fig)
File "D:\Trunk\CellProfiler\cellprofiler\modules\displayplatemap.py", line 232, in display
title=title)
File "D:\Trunk\CellProfiler\cellprofiler\gui\cpfigure.py", line 1753, in subplot_platemap
self.plate_choice = wx.Choice(self.ToolBar, -1, choices=plate_names)
File "D:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 494, in __init__
_controls_.Choice_swiginit(self,_controls_.new_Choice(*args, **kwargs))
TypeError: String or Unicode type required

# Fixed code
def run(self, workspace):
    if self.show_window:
        m = workspace.get_measurements()
        # Get plates
        plates = map(
            unicode, m.get_all_measurements(cpmeas.IMAGE, self.plate_name.value)
        )
        # Get wells
        if self.well_format == WF_NAME:
            wells = m.get_all_measurements(cpmeas.IMAGE, self.well_name.value)
        elif self.well_format == WF_ROWCOL:
            wells = [
                "%s%s" % (x, y)
                for x, y in zip(
                    m.get_all_measurements(cpmeas.IMAGE, self.well_row.value),
                    m.get_all_measurements(cpmeas.IMAGE, self.well_col.value),
                )
            ]
        # Get data to plot
        data = m.get_all_measurements(self.get_object(), self.plot_measurement.value)

        # Construct a dict mapping plates and wells to lists of measurements
        pm_dict = {}
        for plate, well, data in zip(plates, wells, data):
            if data is None:
                continue
            if plate in pm_dict:
                if well in pm_dict[plate]:
                    pm_dict[plate][well] += [data]
                else:
                    pm_dict[plate].update({well: [data]})
            else:
                pm_dict[plate] = {well: [data]}

        for plate, sub_dict in pm_dict.items():
            for well, vals in sub_dict.items():
                vals = np.hstack(vals)
                if self.agg_method == AGG_AVG:
                    pm_dict[plate][well] = np.mean(vals)
                elif self.agg_method == AGG_STDEV:
                    pm_dict[plate][well] = np.std(vals)
                elif self.agg_method == AGG_MEDIAN:
                    pm_dict[plate][well] = np.median(vals)
                elif self.agg_method == AGG_CV:
                    pm_dict[plate][well] = np.std(vals) / np.mean(vals)
                else:
                    raise NotImplemented
        workspace.display_data.pm_dict = pm_dict