Esempio n. 1
0
    def __init__(self, liedataframe, **kwargs):

        self.liedataframe = liedataframe.copy(deep=True)

        # Get copy of the global configuration for this class
        self.settings = pylie_config.get(instance=type(self).__name__)
        self.settings.update(kwargs)
Esempio n. 2
0
    def __init__(self, dataframe, **kwargs):

        # Register source dataset. Reset test/train cases
        self.dataframe = dataframe
        self.dataframe['train_mask'] = 0

        # Get class settings
        self.settings = pylie_config.get(instance=type(self).__name__)
        self.settings.update(kwargs)

        self._cluster_matrix = pandas.DataFrame(
            {'cases': self.dataframe.cases})
Esempio n. 3
0
    def __init__(self, liemdframe, **kwargs):
        if getattr(liemdframe, '_class_name', None) != 'mdframe':
            raise TypeError(
                "FilterSplines requires an LIEMDFrames instance, got {0}".
                format(type(liemdframe)))

        # Get copy of the global configuration for this class
        self.settings = pylie_config.get(instance=type(self).__name__)
        self.settings.update(kwargs)

        # Make a deep copy of the frame
        self.liemdframe = liemdframe.copy(deep=True)

        # Store the stable regions
        self.stable = {}
Esempio n. 4
0
    def __init__(self, dataframe, **kwargs):

        # Register source dataset
        self.dataframe = dataframe

        # Get class settings
        self.settings = pylie_config.get(instance=type(self).__name__)
        self.settings.update(kwargs)

        # Prepaire the report
        self._report = StringIO.StringIO()
        self._print_header()

        # Create clustering dataframe
        self._clust_frame = None
        self._model_count = 1
Esempio n. 5
0
    def __init__(self, data, clusters=None, **kwargs):

        # Store original dataframe(s) and list of processed dataframe(s)
        self.data = data

        # Get copy of the global configuration for this class
        self.settings = pylie_config.get(
            instance=[type(self).__name__, 'LIEScanDataFrame'])
        self.settings.update(kwargs)

        # Obtain initial clusters based on Alpha/Beta scan if no other
        # clusters as input.
        if type(clusters) == type(None):
            clusters = self._init_clusters()

        # Run modelling routine
        self._init_models(clusters)
Esempio n. 6
0
    def __init__(self, data, **kwargs):

        # Store original dataframe(s) and list of processed dataframe(s)
        self._orig_data = data
        self._processed = []

        # Get copy of the global configuration for this class
        self.settings = pylie_config.get(instance=[type(self).__name__, 'FilterGaussian'])
        self.settings.update(kwargs)

        # Cast all input objects to a list
        if not isinstance(self._orig_data, list):
            self._orig_data = [self._orig_data]

        # Prepare the report
        self._report = StringIO()
        self._report_config = StringIO()
        self._print_header()

        # For each object: choose filter based on mdframe or dataframe types
        self._mdframe_import_count = 0
        self._dataframe_import_count = 0
        for lieobject in self._orig_data:
            object_type = getattr(lieobject, '_class_name', None)
            if object_type == 'mdframe':
                averaged = self._filterMDFrame(lieobject)
                self._processed.append(averaged)
                self._mdframe_import_count += 1
            elif object_type == 'dataframe':
                self._processed.append(lieobject)
                self._dataframe_import_count += 1

        if len(self._processed) > 1:
            self._combined = pandas.concat(self._processed, ignore_index=True)
        else:
            self._combined = self._processed[0]

        # Sort the dataframe on case and poses
        self._combined.sort_values(by=['case', 'poses'])

        self.result = self._filterLIEDataFrame(self._combined)
Esempio n. 7
0
    def __init__(self, *args, **kwargs):
        """
        Overload class __init__

        Calls the parent DataFrame __init__ method.
        Registers any custom column header names the user may have provided.
        Initiate default columns in case not yet available and ensures that the
        default values for the train and filter columns are set to 0 instead of NaN.
        """

        for meta in ('_metadata', 'plot_functions'):
            if meta not in self.__dict__:
                self.__dict__[meta] = {}

        for colname in [var for var in kwargs if var in self._column_names]:
            self._column_names[colname] = kwargs[colname]
            kwargs.pop(colname)

        super(LIEDataFrameBase, self).__init__(*args, **kwargs)

        # Init default data columns only at first init
        if self.empty:
            for col in self._column_names.values():
                self[col] = 0
            if 'parent' not in self._metadata:
                self._metadata['parent'] = self

        # Ensure the train and filter masks are filled with 0's instead of NaN
        for col in ('train_mask', 'filter_mask'):
            if self._column_names.get(col, col) in self.columns:
                self[self._column_names.get(col, col)].fillna(0, inplace=True)

        # Register plotting functions for custom dataframes.
        self._init_plot_functions()

        # Get copy of the global configuration for this class once so the user
        # can modify the configuration dict later
        # TODO: Even new classes get populated with base class instance so all the
        #       metadata also gets inherited from base (like settings)
        self.settings = pylie_config.get(instance=type(self).__name__)
Esempio n. 8
0
    def _get_config(self, config, name):

        ref_config = pylie_config.get(name).dict()
        ref_config.update(config)

        return ref_config