Args:
            d (dict): A dict with all data for a band structure symm line
                object.
        Returns:
            A BandStructureSymmLine object
559207
def from_old_dict(cls, d):
        
        # Strip the label to recover initial string (see trick used in as_dict to handle $ chars)
        labels_dict = {k.strip(): v for k, v in d['labels_dict'].items()}
        projections = {}
        structure = None
        if 'projections' in d and len(d['projections']) != 0:
            structure = Structure.from_dict(d['structure'])
            projections = {}
            for spin in d['projections']:
                dd = []
                for i in range(len(d['projections'][spin])):
                    ddd = []
                    for j in range(len(d['projections'][spin][i])):
                        dddd = []
                        ddd.append(d['projections'][spin][i][j])
                    dd.append(np.array(ddd))
                projections[Spin(int(spin))] = np.array(dd)

        return LobsterBandStructureSymmLine(
            d['kpoints'], {Spin(int(k)): d['bands'][k]
                           for k in d['bands']},
            Lattice(d['lattice_rec']['matrix']), d['efermi'],
            labels_dict, structure=structure, projections=projections)
47042
def _interp1d(self):
        
        lines = len(self.hrow_indices)

        for num, data in enumerate(self.tie_data):
            self.new_data[num] = np.empty((len(self.hrow_indices),
                                           len(self.hcol_indices)),
                                          data.dtype)

            for cnt in range(lines):
                tck = splrep(self.col_indices, data[cnt, :], k=self.ky_, s=0)
                self.new_data[num][cnt, :] = splev(
                    self.hcol_indices, tck, der=0)
454905
def to_dict(self):
        
        return {'n':self.n, 'delta':self.delta, 'K':self.K, 'centroids':self.centroids_to_list()}
1096210
def geom(self):
        """"""
        adj_nodes = self._grid._graph.nodes_from_line(self)

        return LineString([adj_nodes[0].geom, adj_nodes[1].geom])
487110
def tuple(self):
        
        return (self.value, {dv.id: dv.value for dv in self.dimensionvalues})
458248
def getLipdNames(D=None):
    
    _names = []
    try:
        if not D:
            print("Error: LiPD data not provided. Pass LiPD data into the function.")
        else:
            _names = D.keys()
    except Exception:
        pass
    return _names
1241632
def from_dict(cls, d):
        
        structure = Structure.from_dict(d['structure'])
        voronoi_list2 = from_bson_voronoi_list2(d['bson_nb_voro_list2'], structure)
        maximum_distance_factor = d['maximum_distance_factor'] if 'maximum_distance_factor' in d else None
        minimum_angle_factor = d['minimum_angle_factor'] if 'minimum_angle_factor' in d else None
        return cls(structure=structure, voronoi_list2=voronoi_list2,
                   # neighbors_lists=neighbors_lists,
                   normalized_angle_tolerance=d['normalized_angle_tolerance'],
                   normalized_distance_tolerance=d['normalized_distance_tolerance'],
                   additional_conditions=d['additional_conditions'],
                   valences=d['valences'],
                   maximum_distance_factor=maximum_distance_factor,
                   minimum_angle_factor=minimum_angle_factor)
374143
def element_data_from_sym(sym):
    '''
    '''

    sym_lower = sym.lower()
    if sym_lower not in _element_sym_map:
        raise KeyError('No element data for symbol \'{}\''.format(sym))
    return _element_sym_map[sym_lower]
947035
def _synDelayParams(self):
        '''
        
        '''
        delays = {}
        #mean delays
        loc = np.zeros((len(self.y), len(self.X)))
        loc[:, 0] = self.delays[0]
        loc[:, 1::2] = self.delays[0]
        loc[:, 2::2] = self.delays[1]
        #standard deviations
        scale = loc * self.delay_rel_sd
        
        #prepare output
        delay_loc = {}
        for i, y in enumerate(self.y):
            delay_loc.update({y : loc[i]})
        
        delay_scale = {}
        for i, y in enumerate(self.y):
            delay_scale.update({y : scale[i]})
                
        return delay_loc, delay_scale
613463
def readiter(d):
    

    da = ms.getdata([d['datacol'],'axis_info','u','v','w','flag','data_desc_id'], ifraxis=True)
    good = n.where((da['data_desc_id']) == d['spwlist'][0])[0]   # take first spw                                                
    time0 = da['axis_info']['time_axis']['MJDseconds'][good]
    data0 = n.transpose(da[d['datacol']], axes=[3,2,1,0])[good]
    flag0 = n.transpose(da['flag'], axes=[3,2,1,0])[good]
    u0 = da['u'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)    # uvw are in m, so divide by wavelength of first chan to set in lambda
    v0 = da['v'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)
    w0 = da['w'].transpose()[good] * d['freq_orig'][0] * (1e9/3e8)

    if len(d['spwlist']) > 1:
        for spw in d['spwlist'][1:]:
            good = n.where((da['data_desc_id']) == spw)[0]
            data1 = n.transpose(da[d['datacol']], axes=[3,2,1,0])[good]
            data0 = n.concatenate( (data0, data1), axis=2 )
            flag0 = n.concatenate( (flag0, n.transpose(da['flag'], axes=[3,2,1,0])[good]), axis=2 )

    del da
    data0 = data0[:,:,d['chans'],:] * n.invert(flag0[:,:,d['chans'],:])   # flag==1 means bad data (for vla)                     
    iterstatus = ms.iternext() 

    return data0.astype('complex64'), u0.astype('float32'), v0.astype('float32'), w0.astype('float32'), time0.astype('float32')
456387
def sm_dict2lha(d):
    """"""
    blocks = OrderedDict([
        ('GAUGE', {'values': [[1, d['g'].real], [2, d['gp'].real], [3, d['gs'].real]]}),
        ('SCALAR', {'values': [[1, d['Lambda'].real], [2, d['m2'].real]]}),
        ('GU', {'values': matrix2lha(d['Gu'].real)}),
        ('IMGU', {'values': matrix2lha(d['Gu'].imag)}),
        ('GD', {'values': matrix2lha(d['Gd'].real)}),
        ('IMGD', {'values': matrix2lha(d['Gd'].imag)}),
        ('GE', {'values': matrix2lha(d['Ge'].real)}),
        ('IMGE', {'values': matrix2lha(d['Ge'].imag)}),
        ('THETA', {'values': [[1, d['Theta'].real], [2, d['Thetap'].real], [3, d['Thetas'].real]]}),
        ])
    return {'BLOCK': blocks}
731981
def __get_mapping(self, structures):
        
        for c in permutations(structures, len(self.__patterns)):
            for m in product(*(x.get_substructure_mapping(y, limit=0) for x, y in zip(self.__patterns, c))):
                mapping = {}
                for i in m:
                    mapping.update(i)
                if mapping:
                    yield mapping
776154
def structs2pandas(structs):
    """"""
    try:
        import pandas
        records = list(structs2records(structs))
        df = pandas.DataFrame.from_records(records)
        # TODO: do this for string columns, for now just for id
        # How can we check for string columns, this is not nice:
        # df.columns[df.dtypes == object]
        if 'id' in df:
            df["id"] = df["id"].apply(str.rstrip)
        return df
    except ImportError:
        # pandas not found, that's ok        
        return structs
623595
def dmag(self,band):
        
        mag2 = self.stars['{}_mag_B'.format(band)]
        mag1 = self.stars['{}_mag_A'.format(band)]
        return mag2-mag1
679684
def joint_shape(*args) -> tuple:
    
    if len(args) == 0:
        return ()
    shape = []
    shapes = [a.shape for a in args]
    ndim = args[0].ndim
    for i in range(ndim):
        shape.append(max([s[i] for s in shapes]))
    return tuple(shape)
672617
def from_old_dict(cls, d):
        
        # Strip the label to recover initial string (see trick used in as_dict to handle $ chars)
        labels_dict = {k.strip(): v for k, v in d['labels_dict'].items()}
        projections = {}
        structure = None
        if 'projections' in d and len(d['projections']) != 0:
            structure = Structure.from_dict(d['structure'])
            projections = {}
            for spin in d['projections']:
                dd = []
                for i in range(len(d['projections'][spin])):
                    ddd = []
                    for j in range(len(d['projections'][spin][i])):
                        dddd = []
                        for k in range(len(d['projections'][spin][i][j])):
                            ddddd = []
                            orb = Orbital(k).name
                            for l in range(len(d['projections'][spin][i][j][
                                                   orb])):
                                ddddd.append(d['projections'][spin][i][j][
                                                 orb][l])
                            dddd.append(np.array(ddddd))
                        ddd.append(np.array(dddd))
                    dd.append(np.array(ddd))
                projections[Spin(int(spin))] = np.array(dd)

        return BandStructureSymmLine(
            d['kpoints'], {Spin(int(k)): d['bands'][k]
                           for k in d['bands']},
            Lattice(d['lattice_rec']['matrix']), d['efermi'],
            labels_dict, structure=structure, projections=projections)
926846
def compare_sym_bands(bands_obj, bands_ref_obj, nb=None):
    

    nkpt = len(bands_obj.kpoints)
    if bands_ref_obj.is_spin_polarized:
        nbands = min(bands_obj.nb_bands, 2 * bands_ref_obj.nb_bands)
    else:
        # TODO: why is this needed? Shouldn't pmg take care of nb_bands?
        nbands = min(len(bands_obj.bands[Spin.up]),
                     len(bands_ref_obj.bands[Spin.up]))
    # print(nbands)
    arr_bands = np.array(bands_obj.bands[Spin.up][:nbands])
    # arr_bands_lavg = (arr_bands-np.mean(arr_bands,axis=1).reshape(nbands,1))

    if bands_ref_obj.is_spin_polarized:
        arr_bands_ref_up = np.array(bands_ref_obj.bands[Spin.up])
        arr_bands_ref_dw = np.array(bands_ref_obj.bands[Spin.down])
        # print(arr_bands_ref_up.shape)
        arr_bands_ref = np.vstack((arr_bands_ref_up, arr_bands_ref_dw))
        arr_bands_ref = np.sort(arr_bands_ref, axis=0)[:nbands]
        # print(arr_bands_ref.shape)
    else:
        arr_bands_ref = np.array(bands_ref_obj.bands[Spin.up][:nbands])

    # arr_bands_ref_lavg =
    # (arr_bands_ref-np.mean(arr_bands_ref,axis=1).reshape(nbands,1))

    # err = np.sum((arr_bands_lavg-arr_bands_ref_lavg)**2,axis=1)/nkpt
    corr = np.array(
        [distance.correlation(arr_bands[idx], arr_bands_ref[idx]) for idx in
         range(nbands)])

    if type(nb) == int: nb = [nb]

    bcheck = {}

    if max(nb) < nbands:
        branches = [[s['start_index'], s['end_index'], s['name']] for s in
                    bands_ref_obj.branches]

        if not bands_obj.is_metal() and not bands_ref_obj.is_metal():
            zero_ref = bands_ref_obj.get_vbm()['energy']
            zero = bands_obj.get_vbm()['energy']
            if not zero:
                vbm = bands_ref_obj.get_vbm()['band_index'][Spin.up][-1]
                zero = max(arr_bands[vbm])
        else:
            zero_ref = 0  # bands_ref_obj.efermi
            zero = 0  # bands_obj.efermi
            print(zero, zero_ref)

        for nbi in nb:
            bcheck[nbi] = {}

            bcheck[nbi]['Dist'] = np.mean(abs(arr_bands[nbi] - zero
                                              - arr_bands_ref[nbi] + zero_ref))
            bcheck[nbi]['Corr'] = corr[nbi]

            for start, end, name in branches:
                # werr.append((sum((arr_bands_corr[nb][start:end+1] -
                # arr_bands_ref_corr[nb][start:end+1])**2)/(end+1-start)*100,name))
                bcheck[nbi][name] = np.mean(abs(arr_bands[nbi][start:end + 1]
                                                - zero
                                                - arr_bands_ref[nbi][
                                                  start:end + 1] + zero_ref))
    else:
        bcheck = "No nb given"

    return bcheck