Exemplo n.º 1
0
    def refresh_source(self, ldf):
        """
        Loading the source into the visualizations in the VisList, then populating each visualization
        based on the new source data, effectively "materializing" the visualization collection.
        Parameters
        ----------
        ldf : LuxDataframe
                Input Dataframe to be attached to the VisList
        Returns
        -------
        VisList
                Complete VisList with fully-specified fields

        See Also
        --------
        lux.vis.Vis.refresh_source
        Note
        ----
        Function derives a new _inferred_intent by instantiating the intent specification on the new data
        """
        if ldf is not None:
            from lux.processor.Parser import Parser
            from lux.processor.Validator import Validator
            from lux.processor.Compiler import Compiler

            self._source = ldf
            self._source.maintain_metadata()
            if len(self._input_lst) > 0:
                approx = False
                if self._is_vis_input():
                    compiled_collection = []
                    for vis in self._collection:
                        vis._inferred_intent = Parser.parse(vis._intent)
                        Validator.validate_intent(vis._inferred_intent, ldf)
                        Compiler.compile_vis(ldf, vis)
                        compiled_collection.append(vis)
                    self._collection = compiled_collection
                else:
                    self._inferred_intent = Parser.parse(self._intent)
                    Validator.validate_intent(self._inferred_intent, ldf)
                    self._collection = Compiler.compile_intent(
                        ldf, self._inferred_intent)

                # Early pruning determination criteria
                width_criteria = len(self._collection) > (lux.config.topk + 3)
                length_criteria = len(
                    ldf) > lux.config.early_pruning_sample_start
                if lux.config.early_pruning and width_criteria and length_criteria:
                    # print("Apply approx to this VisList")
                    ldf._message.add_unique(
                        "Large search space detected: Lux is approximating the interestingness of recommended visualizations.",
                        priority=1,
                    )
                    approx = True
                lux.config.executor.execute(self._collection,
                                            ldf,
                                            approx=approx)
Exemplo n.º 2
0
 def _parse_validate_compile_intent(self):
     from lux.processor.Parser import Parser
     from lux.processor.Validator import Validator
     self._intent = Parser.parse(self._intent)
     Validator.validate_intent(self._intent, self)
     self.maintain_metadata()
     from lux.processor.Compiler import Compiler
     self.current_vis = Compiler.compile_intent(self, self._intent)
Exemplo n.º 3
0
    def refresh_source(self, ldf):
        """
		Loading the source into the visualizations in the VisList, then populating each visualization 
		based on the new source data, effectively "materializing" the visualization collection.

		Parameters
		----------
		ldf : LuxDataframe
			Input Dataframe to be attached to the VisList

		Returns
		-------
		VisList
			Complete VisList with fully-specified fields
		
		See Also
		--------
		lux.vis.Vis.refresh_source

		Note
		----
		Function derives a new _inferred_intent by instantiating the intent specification on the new data
		"""
        if (ldf is not None):
            from lux.processor.Parser import Parser
            from lux.processor.Validator import Validator
            from lux.processor.Compiler import Compiler
            self._source = ldf
            self._source.maintain_metadata()
            if len(self._input_lst) > 0:
                if (self._is_vis_input()):
                    compiled_collection = []
                    for vis in self._collection:
                        vis._inferred_intent = Parser.parse(vis._intent)
                        Validator.validate_intent(vis._inferred_intent, ldf)
                        vislist = Compiler.compile_vis(ldf, vis)
                        if (len(vislist) > 0):
                            vis = vislist[0]
                            compiled_collection.append(vis)
                    self._collection = compiled_collection
                else:
                    self._inferred_intent = Parser.parse(self._intent)
                    Validator.validate_intent(self._inferred_intent, ldf)
                    self._collection = Compiler.compile_intent(
                        ldf, self._inferred_intent)
                ldf.executor.execute(self._collection, ldf)
Exemplo n.º 4
0
Arquivo: Vis.py Projeto: Qutubkhan/lux
    def refresh_source(self, ldf):  # -> Vis:
        """
        Loading the source data into the Vis by instantiating the specification and
        populating the Vis based on the source data, effectively "materializing" the Vis.

        Parameters
        ----------
        ldf : LuxDataframe
                Input Dataframe to be attached to the Vis

        Returns
        -------
        Vis
                Complete Vis with fully-specified fields

        See Also
        --------
        lux.Vis.VisList.refresh_source

        Note
        ----
        Function derives a new _inferred_intent by instantiating the intent specification on the new data
        """
        if ldf is not None:
            from lux.processor.Parser import Parser
            from lux.processor.Validator import Validator
            from lux.processor.Compiler import Compiler
            from lux.executor.PandasExecutor import (
                PandasExecutor,
            )  # TODO: temporary (generalize to executor)

            self.check_not_vislist_intent()

            ldf.maintain_metadata()
            self._source = ldf
            self._inferred_intent = Parser.parse(self._intent)
            Validator.validate_intent(self._inferred_intent, ldf)
            vlist = Compiler.compile_vis(ldf, self)
            ldf.executor.execute(vlist, ldf)
            # Copying properties over since we can not redefine `self` within class function
            if len(vlist) > 0:
                vis = vlist[0]
                self.title = vis.title
                self._mark = vis._mark
                self._inferred_intent = vis._inferred_intent
                self._vis_data = vis.data
                self._min_max = vis._min_max
Exemplo n.º 5
0
    def refresh_source(self, ldf):  # -> Vis:
        """
        Loading the source data into the Vis by instantiating the specification and
        populating the Vis based on the source data, effectively "materializing" the Vis.

        Parameters
        ----------
        ldf : LuxDataframe
                Input Dataframe to be attached to the Vis

        Returns
        -------
        Vis
                Complete Vis with fully-specified fields

        See Also
        --------
        lux.Vis.VisList.refresh_source

        Note
        ----
        Function derives a new _inferred_intent by instantiating the intent specification on the new data
        """
        if ldf is not None:
            from lux.processor.Parser import Parser
            from lux.processor.Validator import Validator
            from lux.processor.Compiler import Compiler

            self.check_not_vislist_intent()

            ldf.maintain_metadata()
            self._source = ldf
            self._inferred_intent = Parser.parse(self._intent)
            Validator.validate_intent(self._inferred_intent, ldf)

            Compiler.compile_vis(ldf, self)
            lux.config.executor.execute([self], ldf)