Loading DMT/core/data_frame.py +18 −0 Original line number Diff line number Diff line Loading @@ -2450,6 +2450,12 @@ class DataFrame(DataProcessor, pd.DataFrame): else: Path(file_name).parent.mkdir(parents=True, exist_ok=True) for col in self.columns: if pd.api.types.is_complex_dtype(self[col]): self[col + sub_specifiers.REAL] = np.real(self[col]) self[col + sub_specifiers.IMAG] = np.imag(self[col]) del self[col] dict_convert = {} for col in self.columns: try: Loading Loading @@ -2496,6 +2502,18 @@ class DataFrame(DataProcessor, pd.DataFrame): if not df.columns.is_unique: raise IOError() for col in df.columns: if ( isinstance(col, SpecifierStr) and (sub_specifiers.REAL.sub_specifiers <= col.sub_specifiers) and (col - sub_specifiers.REAL + sub_specifiers.IMAG in df.columns) ): df[col - sub_specifiers.REAL] = ( df[col] + 1j * df[col - sub_specifiers.REAL + sub_specifiers.IMAG] ) del df[col] del df[col - sub_specifiers.REAL + sub_specifiers.IMAG] return df @classmethod Loading DMT/core/naming.py +14 −0 Original line number Diff line number Diff line Loading @@ -690,6 +690,20 @@ def add(self: SpecifierStr, other: Union[SpecifierStr, str, List[Union[str, Spec SpecifierStr.__add__ = add def sub(self: SpecifierStr, other: Union[SpecifierStr, str, List[Union[str, SpecifierStr]]]): """Method is defined later, since we need the SUB_SPECIFIERS_STR list here...thanks python""" if isinstance(other, SpecifierStr) and not other.specifier and not other.nodes: spec_new = self.specifier nodes_new = self.nodes sub_specifiers_new = self.sub_specifiers - other.sub_specifiers return SpecifierStr(spec_new, *nodes_new, sub_specifiers=sub_specifiers_new) else: return NotImplemented SpecifierStr.__sub__ = sub unit_converter = { specifiers_ss_para.SS_PARA_Y: unit_registry.siemens, specifiers_ss_para.SS_PARA_H: unit_registry.dimensionless, Loading Loading
DMT/core/data_frame.py +18 −0 Original line number Diff line number Diff line Loading @@ -2450,6 +2450,12 @@ class DataFrame(DataProcessor, pd.DataFrame): else: Path(file_name).parent.mkdir(parents=True, exist_ok=True) for col in self.columns: if pd.api.types.is_complex_dtype(self[col]): self[col + sub_specifiers.REAL] = np.real(self[col]) self[col + sub_specifiers.IMAG] = np.imag(self[col]) del self[col] dict_convert = {} for col in self.columns: try: Loading Loading @@ -2496,6 +2502,18 @@ class DataFrame(DataProcessor, pd.DataFrame): if not df.columns.is_unique: raise IOError() for col in df.columns: if ( isinstance(col, SpecifierStr) and (sub_specifiers.REAL.sub_specifiers <= col.sub_specifiers) and (col - sub_specifiers.REAL + sub_specifiers.IMAG in df.columns) ): df[col - sub_specifiers.REAL] = ( df[col] + 1j * df[col - sub_specifiers.REAL + sub_specifiers.IMAG] ) del df[col] del df[col - sub_specifiers.REAL + sub_specifiers.IMAG] return df @classmethod Loading
DMT/core/naming.py +14 −0 Original line number Diff line number Diff line Loading @@ -690,6 +690,20 @@ def add(self: SpecifierStr, other: Union[SpecifierStr, str, List[Union[str, Spec SpecifierStr.__add__ = add def sub(self: SpecifierStr, other: Union[SpecifierStr, str, List[Union[str, SpecifierStr]]]): """Method is defined later, since we need the SUB_SPECIFIERS_STR list here...thanks python""" if isinstance(other, SpecifierStr) and not other.specifier and not other.nodes: spec_new = self.specifier nodes_new = self.nodes sub_specifiers_new = self.sub_specifiers - other.sub_specifiers return SpecifierStr(spec_new, *nodes_new, sub_specifiers=sub_specifiers_new) else: return NotImplemented SpecifierStr.__sub__ = sub unit_converter = { specifiers_ss_para.SS_PARA_Y: unit_registry.siemens, specifiers_ss_para.SS_PARA_H: unit_registry.dimensionless, Loading