def read_char_lengths(self, filename, electrode_filename):
        if os.path.isfile(filename):
            data = np.atleast_1d(np.loadtxt(filename))
            if data.size == 4:
                characteristic_length = data
                if characteristic_length[0] < 0:
                    try:
                        elec_positions = np.loadtxt(electrode_filename)
                    except:
                        raise IOError(
                            'The was an error opening the electrode file')
                    import scipy.spatial.distance
                    distances = scipy.spatial.distance.pdist(elec_positions)
                    characteristic_length[0] = min(distances) * np.abs(
                        characteristic_length[0])
                    if characteristic_length[0] == 0:
                        raise Exception(
                            'Error computing electrode ' +
                            'distances (got a minimal distance of zero')
            else:
                characteristic_length = np.ones(4) * data[0]
        else:
            characteristic_length = np.ones(4)
        if np.any(characteristic_length <= 0):
            raise Exception('No negative characteristic lengths allowed ' +
                            '(except for electrode length')
        self.char_lengths = {}
        for key, item in zip(('electrode',
                              'boundary',
                              'extra_line',
                              'extra_node'),
                             characteristic_length):
            self.char_lengths[key] = item