Exemple #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:
                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)
Exemple #2
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
            from lux.executor.PandasExecutor import PandasExecutor  #TODO: temporary (generalize to executor)
            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