Esempio n. 1
0
    def load(self, ldf) -> View:
        """
		Loading the data into the view by instantiating the specification and populating the view based on the data, effectively "materializing" the view.

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

		Returns
		-------
		View
			Complete View with fully-specified fields

		See Also
		--------
		lux.view.ViewCollection.load
		"""
        from lux.compiler.Parser import Parser
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.executor.PandasExecutor import PandasExecutor  #TODO: temporary (generalize to executor)
        #TODO: handle case when user input vanilla Pandas dataframe
        self.specLst = Parser.parse(self.specLst)
        Validator.validateSpec(self.specLst, ldf)
        vc = Compiler.compile(ldf,
                              ldf.context, [self],
                              enumerateCollection=False)
        PandasExecutor.execute(vc, ldf)
        return vc[0]
Esempio n. 2
0
    def _refresh_intent(self):
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.compiler.Parser import Parser

        if self.SQLconnection == "":
            self.compute_stats()
            self.compute_dataset_metadata()
        self.intent = Parser.parse(self.get_intent())
        Validator.validate_spec(self.intent, self)
        self.current_vis = Compiler.compile(self, self.intent,
                                            self.current_vis)
Esempio n. 3
0
    def _refreshContext(self):
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.compiler.Parser import Parser

        if self.SQLconnection == "":
            self.computeStats()
            self.computeDatasetMetadata()
        self.context = Parser.parse(self.getContext())
        Validator.validateSpec(self.context, self)
        viewCollection = Compiler.compile(self, self.context,
                                          self.viewCollection)
        self.setViewCollection(viewCollection)
Esempio n. 4
0
    def _refresh_context(self):
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.compiler.Parser import Parser

        if self.SQLconnection == "":
            self.compute_stats()
            self.compute_dataset_metadata()
        self.context = Parser.parse(self.get_context())
        Validator.validate_spec(self.context, self)
        view_collection = Compiler.compile(self, self.context,
                                           self.current_view)
        self.set_view_collection(view_collection)
Esempio n. 5
0
File: Vis.py Progetto: smritim/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
		"""
        from lux.compiler.Parser import Parser
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.executor.PandasExecutor import PandasExecutor  #TODO: temporary (generalize to executor)
        self.source = ldf
        #TODO: handle case when user input vanilla Pandas dataframe
        self._inferred_intent = Parser.parse(self.intent)
        Validator.validate_spec(self._inferred_intent, ldf)
        vc = Compiler.compile(ldf,
                              self._inferred_intent, [self],
                              enumerate_collection=False)
        ldf.executor.execute(vc, ldf)
        # Copying properties over since we can not redefine `self` within class function
        vis = vc[0]
        self.title = vis.title
        self.mark = vis.mark
        self._inferred_intent = vis._inferred_intent
        self.data = vis.data
        self.min_max = vis.min_max
Esempio n. 6
0
    def load(self, ldf) -> ViewCollection:
        """
		Loading the data into the views in the ViewCollection by instantiating the specification and populating the view based on the data, effectively "materializing" the view.

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

		Returns
		-------
		ViewCollection
			Complete ViewCollection with fully-specified fields
		
		See Also
		--------
		lux.view.View.load
		"""
        from lux.compiler.Parser import Parser
        from lux.compiler.Validator import Validator
        from lux.compiler.Compiler import Compiler
        from lux.executor.PandasExecutor import PandasExecutor  #TODO: temporary (generalize to executor)
        if len(self.inputLst) > 0:
            if (self._isViewInput()):
                for view in self.collection:
                    view.specLst = Parser.parse(view.specLst)
                    Validator.validateSpec(view.specLst, ldf)
                vc = Compiler.compile(ldf,
                                      ldf.context,
                                      self,
                                      enumerateCollection=False)
            else:
                self.specLst = Parser.parse(self.specLst)
                Validator.validateSpec(self.specLst, ldf)
                vc = Compiler.compile(ldf, self.specLst, self)
            PandasExecutor.execute(vc, ldf)
            return vc
        else:
            return self