Skip to content

Commit

Permalink
access to python packages improved; they are now accessible directly …
Browse files Browse the repository at this point in the history
…using pysgpp.extensions.<package name

> in python; the building process has been adjusted accordingly


git-svn-id: https://ipvs.informatik.uni-stuttgart.de/SGpp/repos/trunk@4815 4eea3252-f0fb-4393-894d-40516dce545b
  • Loading branch information
Fabian Franzelin committed Aug 20, 2015
1 parent 5872cac commit 2e3d7a0
Show file tree
Hide file tree
Showing 133 changed files with 502 additions and 475 deletions.
2 changes: 1 addition & 1 deletion INSTRUCTIONS
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export LD_LIBRARY_PATH=$SGPP_BUILD_PATH:$LD_LIBRARY_PATH
# If you installed Python support execute the following code or add it
# to your ~/.bashrc file

export PYTHONPATH=$PYSGPP_BUILD_PATH:$PYSGPP_MODULE_PATHS:$PYTHONPATH
export PYTHONPATH=$PYSGPP_PACKAGE_PATH:$PYTHONPATH
# ------------------------------------------------------------------------
25 changes: 4 additions & 21 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ for wrapper in languageSupport:
print "Available modules:", ", ".join(moduleNames)
print "Available language support:", ", ".join(languageSupportNames)

pythonModuleFolders = []
if 'pysgpp' in languageSupport:
# find all python modules
def getPythonModules():
"""
Returns all modules, which have a separate python modules
"""
return [moduleFolder
for moduleFolder in moduleFolders
if os.path.exists(os.path.join(moduleFolder, "python"))]

pythonModuleFolders = getPythonModules()
print "Available python modules:", ", ".join(["pysgpp_" + pythonModuleFolder
for pythonModuleFolder in pythonModuleFolders])

vars = Variables("custom.py")

# define the flags
Expand Down Expand Up @@ -151,7 +136,9 @@ vars.GenerateHelpText(env))
# adds trailing slashes were required and if not present
BUILD_DIR = Dir(os.path.join(env['OUTPUT_PATH'], 'lib', 'sgpp'))
Export('BUILD_DIR')
PYSGPP_BUILD_PATH = Dir(os.path.join(env['OUTPUT_PATH'], 'lib', 'pysgpp'))
PYSGPP_PACKAGE_PATH = Dir(os.path.join(env['OUTPUT_PATH'], 'lib'))
Export('PYSGPP_PACKAGE_PATH')
PYSGPP_BUILD_PATH = Dir(os.path.join(PYSGPP_PACKAGE_PATH.abspath, 'pysgpp'))
Export('PYSGPP_BUILD_PATH')
JSGPP_BUILD_PATH = Dir(os.path.join(env['OUTPUT_PATH'], 'lib', 'jsgpp'))
Export('JSGPP_BUILD_PATH')
Expand Down Expand Up @@ -272,12 +259,8 @@ def finish(target, source, env):
instructionsTemplate = Template(fd.read())
fd.close()

pythonModulePaths = ":".join([os.path.join(os.getcwd(), pythonModuleFolder, "python")
for pythonModuleFolder in pythonModuleFolders])

s = instructionsTemplate.safe_substitute(SGPP_BUILD_PATH=BUILD_DIR.abspath,
PYSGPP_BUILD_PATH=PYSGPP_BUILD_PATH.abspath,
PYSGPP_MODULE_PATHS=pythonModulePaths)
PYSGPP_PACKAGE_PATH=PYSGPP_PACKAGE_PATH.abspath)
print
print s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
#############################################################################

from pysgpp import createOperationLaplace, createOperationIdentity
from pysgpp_datadriven.learner import Classifier, Regressor, LearnerEvents, LearnedKnowledge
from pysgpp_datadriven.controller.LearnerEventController import LearnerEventController
# from pysgpp_datadriven.data.ARFFAdapter import ARFFAdapter

import pysgpp_datadriven.utils.json as json
from pysgpp_datadriven.learner.formatter import LearnedKnowledgeFormatter, GridFormatter, LearnerFormatter
from pysgpp_datadriven.controller.InfoToScreenRegressor import InfoToScreenRegressor
from pysgpp_datadriven.controller.InfoToScreen import InfoToScreen
from pysgpp_datadriven.controller.InfoToFile import InfoToFile
from pysgpp.extensions.datadriven.learner import Classifier, Regressor, LearnerEvents, LearnedKnowledge
from pysgpp.extensions.datadriven.controller.LearnerEventController import LearnerEventController
# from pysgpp.extensions.datadriven.data.ARFFAdapter import ARFFAdapter

import pysgpp.extensions.datadriven.utils.json as json
from pysgpp.extensions.datadriven.learner.formatter import LearnedKnowledgeFormatter, GridFormatter, LearnerFormatter
from pysgpp.extensions.datadriven.controller.InfoToScreenRegressor import InfoToScreenRegressor
from pysgpp.extensions.datadriven.controller.InfoToScreen import InfoToScreen
from pysgpp.extensions.datadriven.controller.InfoToFile import InfoToFile
try:
from pysgpp_datadriven.controller.InfoToGraph import InfoToGraph
from pysgpp.extensions.datadriven.controller.InfoToGraph import InfoToGraph
except ImportError: pass
import gzip, copy

Expand Down Expand Up @@ -190,7 +190,7 @@ def setGrid(self, grid):


## Setter for the current LearnedKnowledge object
#@param knowledge: @link pysgpp_datadriven.learner.LearnedKnowledge.LearnedKnowledge LearnedKnowledge @endlink object
#@param knowledge: @link pysgpp.extensions.datadriven.learner.LearnedKnowledge.LearnedKnowledge LearnedKnowledge @endlink object
def setLearnedKnowledge(self, knowledge):
self.knowledge = knowledge

Expand All @@ -206,7 +206,7 @@ def loadGrid(self, iteration):

## Loads knowledge from the checkpoint of given iteration
#@param iteration: integer iteration number
#@return @link pysgpp_datadriven.learner.LearnedKnowledge.LearnedKnowledge LearnedKnowledge @endlink object
#@return @link pysgpp.extensions.datadriven.learner.LearnedKnowledge.LearnedKnowledge LearnedKnowledge @endlink object
def loadLearnedKnowledge(self, iteration):
knowledgeFile = self.composeName(iteration) + ".arff.gz"
knowledgeMemento = LearnedKnowledgeFormatter().deserializeFromFile(knowledgeFile)
Expand Down Expand Up @@ -289,7 +289,7 @@ def __loadLearner(self, iteration):
return learner


# # Learning event @link pysgpp_datadriven.controller.LearnerEventController.LearnerEventController.handleLearningEvent handler routine @endlink of LearnerEventController
# # Learning event @link pysgpp.extensions.datadriven.controller.LearnerEventController.LearnerEventController.handleLearningEvent handler routine @endlink of LearnerEventController
def handleLearningEvent(self, subject, status):
if status == LearnerEvents.LEARNING_STEP_COMPLETE or status == LearnerEvents.LEARNING_WITH_TESTING_STEP_COMPLETE:
if subject.iteration % self.interval == 0:
Expand Down Expand Up @@ -352,7 +352,7 @@ def generateFoldValidationJob(self, email=""):
#$-m e
#$-v SGPP,OPT_TMP,PATH,LD_LIBRARY_PATH
. /etc/profile
echo "from pysgpp_datadriven.controller.CheckpointController import CheckpointController\nlearner = CheckpointController('""" \
echo "from pysgpp.extensions.datadriven.controller.CheckpointController import CheckpointController\nlearner = CheckpointController('""" \
+ self.title + """', '.', 1, $SGE_TASK_ID).loadAll(0)\nlearner.learnDataWithTest()" | python
echo "JOB_ID: $JOB_ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
#############################################################################

from pysgpp_datadriven.controller.InfoToScreen import InfoToScreen
from pysgpp.extensions.datadriven.controller.InfoToScreen import InfoToScreen
import sys

## The class processes the progress information from Learner and LinearSolver and
Expand Down
10 changes: 5 additions & 5 deletions datadriven/python/pysgpp_datadriven/controller/InfoToGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
# use, please see the copyright notice provided with SG++ or at
# sgpp.sparsegrids.org

from pysgpp_datadriven.learner.solver.LinearSolver import LinearSolverEvents
from pysgpp_datadriven.learner.Learner import LearnerEvents
from pysgpp_datadriven.controller.LearnerEventController import LearnerEventController
from pysgpp_datadriven.controller.SolverEventController import SolverEventController
from pysgpp.extensions.datadriven.learner.solver.LinearSolver import LinearSolverEvents
from pysgpp.extensions.datadriven.learner.Learner import LearnerEvents
from pysgpp.extensions.datadriven.controller.LearnerEventController import LearnerEventController
from pysgpp.extensions.datadriven.controller.SolverEventController import SolverEventController
import matplotlib
matplotlib.use('Agg') #to prevent the bug with matplot unable to open display
from matplotlib import pyplot
from matplotlib.lines import Line2D

# @package from pysgpp_datadriven.controller
# @package from pysgpp.extensions.datadriven.controller
## This class processes the information about the current state of the learning
# process and presents it in form of a graph.
# In order to use this class the <a href="http://matplotlib.sourceforge.net" target="new">matplotlib library</a> is required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# use, please see the copyright notice provided with SG++ or at
# sgpp.sparsegrids.org

from pysgpp_datadriven.learner.solver.LinearSolver import LinearSolverEvents
from pysgpp_datadriven.learner.Learner import LearnerEvents
from pysgpp_datadriven.controller.LearnerEventController import LearnerEventController
from pysgpp_datadriven.controller.SolverEventController import SolverEventController
from pysgpp.extensions.datadriven.learner.solver.LinearSolver import LinearSolverEvents
from pysgpp.extensions.datadriven.learner.Learner import LearnerEvents
from pysgpp.extensions.datadriven.controller.LearnerEventController import LearnerEventController
from pysgpp.extensions.datadriven.controller.SolverEventController import SolverEventController

## The class processes the progress information from Learner and LinearSolver and
# shows it on the terminal screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# sgpp.sparsegrids.org


from pysgpp_datadriven.controller.InfoToScreen import InfoToScreen
from pysgpp_datadriven.learner.Learner import LearnerEvents
from pysgpp.extensions.datadriven.controller.InfoToScreen import InfoToScreen
from pysgpp.extensions.datadriven.learner.Learner import LearnerEvents

# @package pysgpp_datadriven.controller
# @package pysgpp.extensions.datadriven.controller
## Prints some regression specific information together with information
# processed by @link pysgpp_datadriven.controller.InfoToScreen.InfoToScreen InfoToScreen @endlink
# processed by @link pysgpp.extensions.datadriven.controller.InfoToScreen.InfoToScreen InfoToScreen @endlink
class InfoToScreenRegressor(InfoToScreen):


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Abstract class of Subscribers of LearnerEvents. The classes that wants to obtain
# the progress notifications from Learner should implement this class. See @link
# pysgpp_datadriven.learner.Learner.Learner documentation of Learner@endlink for details.
# pysgpp.extensions.datadriven.learner.Learner.Learner documentation of Learner@endlink for details.
class LearnerEventController(object):

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Abstract class of Subscribers of LinearSolverEvents. The classes that wants to obtain
# the progress notifications from LinearSolver subclasses should implement this class. See @link
# pysgpp_datadriven.learner.solver.LinearSolver.LinearSolver documentation of Learner@endlink for details.
# pysgpp.extensions.datadriven.learner.solver.LinearSolver.LinearSolver documentation of Learner@endlink for details.
class SolverEventController(object):

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#############################################################################
#
#############################################################################
from pysgpp_datadriven.data.DataContainer import DataContainer
from pysgpp.extensions.datadriven.data.DataContainer import DataContainer


import ConfigParser, os
Expand All @@ -18,11 +18,11 @@
pathsgpp = os.path.abspath(pathname) + '/../..'
if pathsgpp not in sys.path: sys.path.append(pathsgpp)

from pysgpp_datadriven.controller import InfoToScreen, InfoToScreenRegressor, InfoToFile, CheckpointController
from pysgpp_datadriven.learner.LearnerBuilder import LearnerBuilder
from pysgpp_datadriven.data.ARFFAdapter import ARFFAdapter
from pysgpp_datadriven.data.DataContainer import DataContainer
from pysgpp_datadriven.learner.Types import BorderTypes
from pysgpp.extensions.datadriven.controller import InfoToScreen, InfoToScreenRegressor, InfoToFile, CheckpointController
from pysgpp.extensions.datadriven.learner.LearnerBuilder import LearnerBuilder
from pysgpp.extensions.datadriven.data.ARFFAdapter import ARFFAdapter
from pysgpp.extensions.datadriven.data.DataContainer import DataContainer
from pysgpp.extensions.datadriven.learner.Types import BorderTypes
import types


Expand Down
6 changes: 3 additions & 3 deletions datadriven/python/pysgpp_datadriven/learner/Learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from pysgpp import *
from solver.CGSolver import CGSolver
from folding.FoldingPolicy import FoldingPolicy
import pysgpp_datadriven.utils.json as json
import pysgpp.extensions.datadriven.utils.json as json
from TrainingStopPolicy import TrainingStopPolicy
from TrainingSpecification import TrainingSpecification
from pysgpp_datadriven.data.DataContainer import DataContainer
from pysgpp.extensions.datadriven.data.DataContainer import DataContainer
import types


Expand All @@ -37,7 +37,7 @@
# - Concrete Observer: e.g. InfoToScreen
#
# Observer can also want to retrieve the process information from LinearSolver.
# See documentation of@link pysgpp_datadriven.learner.solver.LinearSolver.LinearSolver LinearSolver@endlink for more information.
# See documentation of@link pysgpp.extensions.datadriven.learner.solver.LinearSolver.LinearSolver LinearSolver@endlink for more information.
#
class Learner(object):

Expand Down
Loading

0 comments on commit 2e3d7a0

Please sign in to comment.