def test(): """ Verify that channels lower in the hierarchy inherit the default state of their parent """ # get the journal import journal # make a channel parent = journal.warning(name="test.index.parent") # verify that the state is on assert parent.active is True # it's non-fatal assert parent.fatal is False # and the device is at the default value assert parent.device is journal.warning.chronicler.device # deactivate it parent.active = False # make it fatal parent.fatal = True # and set the device to a trash can parent.device = journal.trash() # lookup a name that is lower in the hierarchy child = journal.warning(name="test.index.parent.blah.blah.child") # that it's state is the same as the parent assert child.active == parent.active assert child.fatal == parent.fatal # and that it inherited the device correctly assert child.device is parent.device # all done return
def findLayout(self, layout): '''Assigning controller/solver/coupler/communicator to this processor. ''' if layout.ccomm: # This process belongs to the containing solver self.controller = self.inventory.ccontroller self.solver = self.inventory.csolver self.coupler = self.inventory.ccoupler self.solverCommunicator = layout.ccomm self.myPlus = layout.ccommPlus self.remotePlus = layout.ecommPlus elif layout.ecomm: # This process belongs to the embedded solver self.controller = self.inventory.econtroller self.solver = self.inventory.esolver self.coupler = self.inventory.ecoupler self.solverCommunicator = layout.ecomm self.myPlus = layout.ecommPlus self.remotePlus = layout.ccommPlus else: # This process doesn't belong to any solver import journal journal.warning(self.name).log("node '%d' is an orphan" % layout.rank) self.comm = layout.comm self.rank = layout.rank self.nodes = layout.nodes return
def retrievePackageAlternatives(self): """ Retrieve selection information for all known package groups """ # template for the command line args settings = { 'executable': str(self.client), 'args': (str(self.client), 'select', '--summary'), 'stdout': subprocess.PIPE, 'stderr': subprocess.PIPE, 'universal_newlines': True, 'shell': False } # run the command with subprocess.Popen(**settings) as pipe: # get the text source stream = pipe.stdout # the first two lines are headers; skip them next(stream) next(stream) # process the rest for line in stream: # strip, split, and unpack group, selection, alternatives = line.strip().split(maxsplit=2) # make a set out of the alternatives alternatives = list(alternatives.split()) # remove the dummy marker 'none'; it should always be there alternatives.remove('none') # handle the selection: if it is 'none' if selection == 'none': # it contributes nothing to the net alternatives selection = [] # if not else: # attempt to try: # remove it from the alternatives alternatives.remove(selection) # if this fails except ValueError: # port selections are in an inconsistent state import journal # build a message msg = "the {!r} port selection is in inconsistent state".format( group) # and warn the user journal.warning("pyre.platforms").log(msg) # and put it at the top of the pile selection = [selection] # turn the pile into a properly ordered tuple alternatives = tuple(selection + alternatives) # hand the pair to the caller yield group, alternatives # all done return
def main(): #debug.activate() #journal.debug("CompositeNeutronScatterer_Impl").activate() journal.warning('mcstas2.parsers.ComponentInfo').deactivate() # comment out this line to hide the error msg in searching for component journal.debug("mcstas2.pyre_support").activate() import mcstas2.mcstas2bp pytests = pysuite() alltests = unittest.TestSuite( (pytests, ) ) res = unittest.TextTestRunner(verbosity=2).run(alltests) import sys; sys.exit(not res.wasSuccessful())
def main(): #debug.activate() #journal.debug("CompositeNeutronScatterer_Impl").activate() journal.warning('mcstas2.parsers.ComponentInfo').deactivate() # comment out this line to hide the error msg in searching for component journal.debug("mcstas2.pyre_support").activate() import mcstas2.mcstas2bp pytests = pysuite() alltests = unittest.TestSuite((pytests, )) res = unittest.TextTestRunner(verbosity=2).run(alltests) import sys sys.exit(not res.wasSuccessful())
def language(self, language): """retrieve <language> handler from the persistent store""" agent = self.retrieveComponent( name=language, factory='language', args=[self], vault=['languages']) if agent: self._info.log("loaded '%s' from %s" % (language, agent.getLocator())) else: import journal journal.warning('merlin').log("language '%s' not found" % language) return agent
def complain(msg): """ Print error messages """ # if there is journal try: # use it import journal journal.warning('mm').log(msg) # otherwise except ImportError: # print the error message print('mm:', msg, file=sys.stderr) # return return
def language(self, language): """retrieve <language> handler from the persistent store""" agent = self.retrieveComponent(name=language, factory='language', args=[self], vault=['languages']) if agent: self._info.log("loaded '%s' from %s" % (language, agent.getLocator())) else: import journal journal.warning('merlin').log("language '%s' not found" % language) return agent
def test(): """ Exercise the channel with a realistic example when it is fatal """ # get the journal import journal # make a channel channel = journal.warning(name="tests.journal.warning") # make it fatal channel.fatal = True # send the output to the trash channel.device = journal.trash() # add some metadata channel.notes["time"] = "now" # we asked for this to be fatal, so carefully try: # inject something channel.line("warning channel:") channel.log(" hello world!") # this should be unreachable assert False, "unreachable" # if all goes well except channel.ApplicationError: # all good pass # all done return
def __init__(self, name=None, **kwds): # chain up super().__init__(name=name, **kwds) # attach my renderer to the console import journal journal.console.renderer = self.pyre_renderer # make a name for my channels channel = self.pyre_namespace or name # if I have a name if channel: # build my channels self.debug = journal.debug(channel) self.firewall = journal.firewall(channel) self.info = journal.info(channel).activate() self.warning = journal.warning(channel).activate() self.error = journal.error(channel).activate() # if i am in debugging mode if self.DEBUG: # activate the debug channel self.debug.active = True # sniff around for my environment self.pyre_home, self.pyre_prefix, self.pyre_defaults = self.pyre_explore( ) # instantiate my layout self.layout = self.pyre_loadLayout() # mount my folders self.pfs = self.pyre_mountPrivateFilespace() # go through my requirements and build my dependency map # self.dependencies = self.pyre_resolveDependencies() # all done return
def __init__(self, name=None): Traceable.__init__(self) if name is None: name = self.name # class attribute else: self.name = name self.inventory = self.createInventory() # provide simple, convenient access to descriptors self.metainventory = self.createMetaInventory() # other names by which I am known for configuration purposes self.aliases = [ name ] import journal self._debug = journal.debug(name) self._info = journal.info(name) self._error = journal.error(name) self._warning = journal.warning(name) # modify the inventory defaults that were hardwired at compile time # gives derived components an opportunity to modify their default behavior # from what was inherited from their parent's inventory self._defaults() return
def __init__(self, name=None, **kwds): # chain up super().__init__(name=name, **kwds) # set up my nickname nickname = self.pyre_namespace or name # if i have one if nickname: # register it with the journal journal.application(name=nickname) # build my channels self.debug = journal.debug(nickname) self.firewall = journal.firewall(nickname) self.info = journal.info(nickname).activate() self.warning = journal.warning(nickname).activate() self.error = journal.error(nickname).activate() # if i am in debugging mode if self.DEBUG: # activate the debug channel self.debug.active = True # sniff around for my environment self.pyre_home, self.pyre_prefix, self.pyre_defaults = self.pyre_explore( ) # instantiate my layout self.layout = self.pyre_loadLayout() # mount my folders self.pfs = self.pyre_mountPrivateFilespace() # go through my requirements and build my dependency map # self.dependencies = self.pyre_resolveDependencies() # all done return
def test(): """ Verify the channel initial state """ # get the journal import journal # make a channel channel = journal.warning(name="tests.journal.warning") # verify the channel name assert channel.name == "tests.journal.warning" # the verbosity should be at the default level assert channel.verbosity == 1 # the channel should be active assert channel.active == True # and non fatal assert channel.fatal == False # the page should be empty assert list(channel.page) == [] # verify the metadata assert channel.notes["application"] == "journal" assert channel.notes["channel"] == channel.name assert channel.notes["severity"] == channel.severity # all done return
def __init__(self, name=None, **kwds): # chain up super().__init__(name=name, **kwds) # attach my renderer to the console import journal journal.console.renderer = self.pyre_renderer # make a name for my channels channel = self.pyre_namespace or name # if I have a name if channel: # build my channels self.debug = journal.debug(channel) self.firewall = journal.firewall(channel) self.info = journal.info(channel).activate() self.warning = journal.warning(channel).activate() self.error = journal.error(channel).activate() # if i am in debugging mode if self.DEBUG: # activate the debug channel self.debug.active = True # sniff around for my environment self.pyre_home, self.pyre_prefix, self.pyre_defaults = self.pyre_explore() # instantiate my layout self.layout = self.pyre_loadLayout() # mount my folders self.pfs = self.pyre_mountPrivateFilespace() # go through my requirements and build my dependency map # self.dependencies = self.pyre_resolveDependencies() # all done return
def __init__(self, name=None, timer=None, **kwds): # chain up super().__init__(name=name, **kwds) # i may not have a name, but i need one in what follows name = name or self.pyre_family() or "pyre.nexus.peers" # if i didn't get handed a timer to use if timer is None: # make a new one timer = self.pyre_executive.newTimer(name=name) # start it timer.start() # save it self.timer = timer # journal channels import journal self.info = journal.info(name=name) self.debug = journal.debug(name=name) self.warning = journal.warning(name=name) self.error = journal.error(name=name) # all done return
def __init__(self, name = 'geometer'): Component.__init__(self, name, 'geometer') base.__init__(self) import journal self._warning = journal.warning( 'mcni.pyre_support.geometer' ) return
def __init__(self, name=None, timer=None, **kwds): # chain up super().__init__(name=name, **kwds) # i am not have a name, but i need one in what follows name = name or self.pyre_family() or "pyre.nexus.peers" # if i were handed a timer to use if timer is not None: # save it self.timer = timer # otherwise else: # make a new one and start it self.timer = self.pyre_executive.newTimer(name=name).start() # journal channels import journal self.info = journal.info(name=name) self.debug = journal.debug(name=name) self.warning = journal.warning(name=name) self.error = journal.error(name=name) # all done return
def thermoDone(self): unresolvedSpecies = [] for species in self._species.find(): if not species.thermo: if not self._externalDb: self._externalDb = self._readExternalThermoDb() resolution = self._externalDb.species(species.symbol) resolution.trans = species.trans if not resolution: unresolvedSpecies.append(species) else: self._info.log( "resolving species '%s' against '%s'" % (species.symbol, self._thermdb)) self._species.replace(species.symbol, species, resolution) if unresolvedSpecies: warning = journal.warning("fuego") warning.line("unresolved species in mechanism") warning.line("species: %s" % [ x.symbol for x in unresolvedSpecies]) return 0
def test(): """ Verify access to the channel metadata """ # access import journal # make a channel channel = journal.warning("test.channel") # get its metadata notes = channel.notes # adjust the application name notes["application"] = "warning_notes" # add something notes["author"] = "michael" # make sure the adjustments stick by getting the value once again notes = channel.notes # and comparing against expectations assert notes["application"] == "warning_notes" assert notes["author"] == "michael" assert notes["channel"] == "test.channel" assert notes["severity"] == "warning" # all done return
def __init__(self, name='geometer'): Component.__init__(self, name, 'geometer') base.__init__(self) import journal self._warning = journal.warning('mcni.pyre_support.geometer') return
def test(): """ Verify access to the channel properties """ # access import journal # make a channel channel = journal.warning("test.channel") # verify its name assert channel.name == "test.channel" # check that it is read-only try: # by attempting to modify channel.name = "foo" # hence, we can't get here assert False, "unreachable" # if all goes well except AttributeError as error: # no problem pass # verify its verbosity is at 1 by default assert channel.verbosity == 1 # that it can be modified channel.verbosity = 5 # and the assignment sticks assert channel.verbosity == 5 # verify its activation state is on by default assert channel.active is True # that it can be modified channel.active = False # and the assignment sticks assert channel.active is False # verify its not fatal assert channel.fatal is False # that it can be modified channel.fatal = True # and the assignment sticks assert channel.fatal is True # verify that the accessible device is the console assert channel.device.name == "cout" # make a trash can trash = journal.trash() # register it as the device channel.device = trash # and verify that the assignment sticks assert channel.device is trash # check the name assert channel.device.name == "trash" # and verify that it's different from the default device held by the class assert channel.device is not channel.defaultDevice # all done return
def agents(self, project, actions): """retrieve the agents for <actions> from the persistent store""" agents = [] for action in actions: agent = self.retrieveComponent( name=action, factory='agent', args=[self, project], vault=['actions']) if agent: self._info.log("loaded action '%s' from %s" % (action, agent.getLocator())) else: import journal journal.warning('merlin').log("action '%s': no corresponding agent" % action) continue agents.append(agent) return agents
def build( binding, site_package_path = None ): if site_package_path is not None: import journal warning = journal.warning( 'binding_builder.mm' ) warning.log( 'mm can only export python modules to predefined $EXPORT_ROOT/modules' ) pass from builder import build build( binding ) return
def main(self, *args, **kwds): if self._doClient and self._doServer: self._info.log("in split mode") self._both() elif self._doClient: self._info.log("in client mode") self.onClient() self._info.log("client finished") elif self._doServer: self._info.log("in server mode") self.onServer() self._info.log("server finished") else: import journal journal.warning(self.name).log("nothing to do; exiting") return
def _configurationLoader(self, key, value, locator): """ Handler for the {config} command line argument """ # if the value is empty if not value: # form the name of the command line argument name = ".".join(key) # grab the journal import journal # issue a warning journal.warning('pyre.framework').log(f"{name}: no uri") # and go no further return # load the configuration self.loadConfiguration(uri=value, locator=locator, priority=self.priority.command) # and return return
def warning(message): """ Generate a warning """ # get the logging mechanism import journal # build a warning object in my namespace warning = journal.warning('merlin') # log and return return warning.log(message)
def registrar(): global _registrar if not _registrar: from pyre.support.Registrar import Registrar _registrar = Registrar() # register the always available python factory from pyre.chemistry import mechanisms _registrar.register(mechanisms, "pyre", "native") # try to load fuego try: from pyre.solvers import fuego _registrar.register(fuego, "fuego") except: import journal journal.warning("fuego").log("could not register 'fuego'") return _registrar
def findLayout(self, layout): if layout.coarse: self.solver = self.inventory.coarse self.exchanger = self.inventory.cge self.solverCommunicator = layout.coarse self.myPlus = layout.coarsePlus self.remotePlus = layout.finePlus elif layout.fine: self.solver = self.inventory.fine self.exchanger = self.inventory.fge self.solverCommunicator = layout.fine self.myPlus = layout.finePlus self.remotePlus = layout.coarsePlus else: import journal journal.warning(self.name).log("node '%d' is an orphan" % layout.rank) return
def build(binding, site_package_path=None): if site_package_path is not None: import journal warning = journal.warning('binding_builder.mm') warning.log( 'mm can only export python modules to predefined $EXPORT_ROOT/modules' ) pass from builder import build build(binding) return
def test(): # access the package import journal # build a warning channel warning = journal.warning("journal.test1") # deactivate it warning.active = False # and make it say something warning.log("hello world!") # all done return
def test(): # access the package import journal # build a warning channel warning = journal.warning("journal.test1") # verify that it is on by default assert warning.active == True # disable it warning.active = False # access the same channel through another object clone = journal.warning("journal.test1") # verify that it is now off assert clone.active == False # build a warning channel with a different name another = journal.warning("journal.test2") # verify that it is on by default, to make sure that there is no crosstalk between channels assert another.active == True # all done return
def test(): # access the package import journal # build a warning channel warning = journal.warning("activation") # verify that it is off by default, deactivated from a configuration source assert warning.active == False # enable it warning.active = True # access the same channel through another object clone = journal.warning("activation") # verify that it is on assert clone.active == True # disable it clone.active = False # check that the other channel has been deactivated as well assert warning.active == False # all done return
def agents(self, project, actions): """retrieve the agents for <actions> from the persistent store""" agents = [] for action in actions: agent = self.retrieveComponent(name=action, factory='agent', args=[self, project], vault=['actions']) if agent: self._info.log("loaded action '%s' from %s" % (action, agent.getLocator())) else: import journal journal.warning('merlin').log( "action '%s': no corresponding agent" % action) continue agents.append(agent) return agents
def __init__(cls, name, bases, dict): type.__init__(cls, name, bases, dict) trash = {} # initialize the lookup table with inherited tags dtd = {} bases = list(bases) bases.reverse() for base in bases: try: dtd.update(base._mydtd) except AttributeError: pass # process the list of nested tag factories for node in dict.get('tags', []): symbols = {} # parse out any explicit package specs nsplit = node.split('.') factory = nsplit[-1] # build the path to the tag module # if there is no explicit package, build a path to the location of this node if len(nsplit) == 1: path = cls.__module__.split('.')[:-1] path.append(node) module = '.'.join(path) else: # respect the explicit path supplied module = node # attempt to load the node constructor symbols = __import__(module, {}, {}, factory).__dict__ # install the (tag,constructor) pair in our lookup table record = symbols[factory] dtd[record.tag] = record if DTDBuilder.CALLBACK_CHECK == 'strict': # verify that there is a handler for the endElement event callback = 'on' + factory if callback not in cls.__dict__: import journal warning = journal.warning("pyre.xml.parsing") warning.log("class '%s' should define a method 'on%s'" % (name, factory)) cls._mydtd = dtd return
def __init__(cls, name, bases, dict): type.__init__(name, bases, dict) trash = {} # initialize the lookup table with inherited tags dtd = {} bases = list(bases) bases.reverse() for base in bases: try: dtd.update(base._mydtd) except AttributeError: pass # process the list of nested tag factories for node in dict.get('tags', []): symbols = {} # parse out any explicit package specs nsplit = node.split('.') factory = nsplit[-1] # build the path to the tag module # if there is no explicit package, build a path to the location of this node if len(nsplit) == 1: path = cls.__module__.split('.')[:-1] path.append(node) module = '.'.join(path) else: # respect the explicit path supplied module = node # attempt to load the node constructor symbols = __import__(module, {}, {}, factory).__dict__ # install the (tag,constructor) pair in our lookup table record = symbols[factory] dtd[record.tag] = record if DTDBuilder.CALLBACK_CHECK == 'strict': # verify that there is a handler for the endElement event callback = 'on' + factory if callback not in cls.__dict__: import journal warning = journal.warning("pyre.xml.parsing") warning.log("class '%s' should define a method 'on%s'" % (name, factory)) cls._mydtd = dtd return
def findLayout(self, layout): import ExchangerLib if layout.coarse: self.exchanger = self.inventory.coarse self.communicator = layout.coarse self.all_variables = ExchangerLib.CoarsereturnE() elif layout.fine: self.exchanger = self.inventory.fine self.communicator = layout.fine self.all_variables = ExchangerLib.FinereturnE() else: import journal journal.warning(self.name).log("node '%d' is an orphan" % layout.rank) self.intercomm = layout.intercomm self.rank = layout.rank self.nodes = layout.nodes self.leader = layout.leader self.remoteLeader = layout.remoteLeader print "%s exchanger: rank=%d leader=%d remoteLeader=%d" % ( self.exchanger.name, self.rank, self.leader, self.remoteLeader) return
def test(): """ Verify that empty log messages get handled properly """ # get the journal import journal # make a channel channel = journal.warning(name="tests.journal.warning") # inject an empty message channel.log() # all done return
def test(): """ Exercise the simplest non-trivial use case """ # get the journal import journal # make a channel channel = journal.warning(name="tests.journal.warning") # send the output to the trash channel.device = journal.trash() # inject channel.log("hello world!") # all done return
def test(): """ Exercise adding multiple lines at once """ # get the journal import journal # make a channel channel = journal.warning(name="test.journal.warning") # activate it channel.activate() # but send the output to trash channel.device = journal.trash() # content in a tuple reptuple = ( "report from tuple:", " tuple line 1", " tuple line 2", ) # content in a list replist = [ "report from list:", " list line 1", " list line 2", ] # content in a generator def repgen(): yield "report from generator:" yield " generator line 1" yield " generator line 2" return # inject channel.report(report=reptuple) channel.report(report=replist) channel.report(report=repgen()) # flush channel.log() # all done return
def test(): # access the package import journal # build a channel of each kind using the same name debug = journal.debug("journal.test") firewall = journal.firewall("journal.test") info = journal.info("journal.test") warning = journal.warning("journal.test") error = journal.error("journal.test") # check their expected default state assert debug.active == False assert firewall.active == True assert info.active == True assert warning.active == True assert error.active == True # all done return
def test(): import journal from jtest import jtest print " ** testing C++ informationals" info = journal.info("jtest") info.activate() jtest.info("jtest") print " ** testing C++ warnings" warning = journal.warning("jtest") #warning.deactivate() warning = jtest.warning("jtest") print " ** testing C++ errors" error = journal.error("jtest") #error.deactivate() jtest.error("jtest") return
def test(): import journal # force the initialization journal.journal() from jtest import jtest print " ** testing informationals" info = journal.info("jtest") info.activate() info.log("this is an info from python") jtest.info("jtest") print " ** testing warnings" warning = journal.warning("jtest") warning.log("this a warning from python") #jtest.warning("jtest") print " ** testing errors" error = journal.error("jtest") error.log("this an error from python") #jtest.error("jtest") return
# (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # from Connectable import Connectable from Passer import Passer import _convenient_functions as dsm import journal jrnltag = 'DataStreamModel' warning = journal.warning( jrnltag ) class AmbiguousComponentSpecifier(Exception): pass class Composite(Connectable): '''Support of connection of connectable to form a composite connectable. ''' def __init__(self, components, connections): '''__init__(connections, components) -> new composite connectable connections: a list of connections specified by strings
# # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # standalone = True import unittestX as unittest import journal debug = journal.debug( "samplecomponent_TestCase" ) warning = journal.warning( "samplecomponent_TestCase" ) class TestCase(unittest.TestCase): def test1(self): 'mccomponents.sample.samplecomponent' import mcni neutron = mcni.neutron( r = (0,0,0), v = (0,0,4149.48), time = 0, prob = 1 ) from mcni.components.MonochromaticSource import MonochromaticSource component1 = MonochromaticSource('source', neutron) from mccomponents.sample import samplecomponent component2 = samplecomponent( 'V-constantE', 'sampleassemblies/V-constantE/sampleassembly.xml' ) instrument = mcni.instrument( [component1, component2] )
# Jiao Lin # California Institute of Technology # (C) 2008 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # import unittestX as unittest import journal debug = journal.debug( "ChangeCoordinateSystem_forDispersion_3D_TestCase" ) warning = journal.warning( "ChangeCoordinateSystem_forDispersion_3D_TestCase" ) import mcni from mcni import mcnibp from mccomposite import mccompositebp from mccomponents import mccomponentsbp class TestCase(unittest.TestCase): def test(self): from LinearlyInterpolatedDispersion_Example import example dispersion = example() M = mcnibp.Matrix3_double Q = mcnibp.Vector3_double
Ei_params = self.inventory.Ei_params emission_time = self.inventory.emission_time return ARCSxml, Ei_params, emission_time def _defaults(self): base._defaults(self) from arcseventdata.parallel_histogrammers.components.IpdpEiHistogrammer import IpdpEiHistogrammer as Engine self.inventory.engine = Engine( ) return pass # end of Application def main(): Application('ipdpI').run( ) return if __name__ == '__main__': import journal journal.warning( 'arcseventdata.Histogrammer2' ).deactivate() main() # version __id__ = "$Id$" # End of file
# # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # standalone = True long_test = True import unittestX as unittest import journal debug = journal.debug( "detectorcomponent_TestCase" ) warning = journal.warning( "detectorcomponent_TestCase" ) import mcni import mccomponents.detector as md import numpy as N instrumentxml = 'ARCS.xml' outfilename = 'detectorcomponent_TestCase-events.dat' nevents = 100000 absorption_weight = 0.9 tofparams = 0, 10e-3, 1e-4 coordinate_system = 'McStas' class TestCase(unittest.TestCase):
# Jiao Lin # California Institute of Technology # (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # import unittestX as unittest import journal debug = journal.debug( "mcni.components.test" ) warning = journal.warning( "mcni.components.test" ) class TestCase(unittest.TestCase): def test(self): 'mcni.components factory methods' from mcni.components import listallcomponentcategories, listcomponentsincategory print 'component categories:', listallcomponentcategories() print 'components in "sources" category:', listcomponentsincategory( 'sources' ) return pass # end of TestCase
# (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # standalone = True import unittestX as unittest import journal debug = journal.debug( "mcni.neutron_storage.test" ) warning = journal.warning( "mcni.neutron_storage.test" ) class TestCase(unittest.TestCase): def test(self): 'neutron_storage.merge' oldstorage_path = 'test-merge-old' newstorage_path = 'test-merge-new' newpacketsize = 10 for path in [ oldstorage_path, newstorage_path ]: if os.path.exists( path ):
# (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # standalone = True import unittestX as unittest import journal debug = journal.debug("scattererxml_TestCase") warning = journal.warning("scattererxml_TestCase") scattererxml = "scatterers/fccNi/Ni-scatterer-SQEkernel.xml" class scattererxml_TestCase(unittest.TestCase): def test1(self): "mccomponents.sample.kernelxml.parser" from mccomponents.sample.kernelxml import parse_file scatterer = parse_file(scattererxml) kernel = scatterer.kernel() self.assert_(isKernel(kernel)) return
# Jiao Lin # California Institute of Technology # (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # import unittestX as unittest import journal debug = journal.debug( "SimplePowderDiffractionKernel_TestCase" ) warning = journal.warning( "SimplePowderDiffractionKernel_TestCase" ) import mcni from mcni import mcnibp from mccomposite import mccompositebp from mccomponents import mccomponentsbp class TestCase(unittest.TestCase): def test1(self): 'vector<SimplePowderDiffractionData_Peak>' peaks = mccomponentsbp.vector_SimplePowderDiffractionData_Peak(2) return
# (C) 2006-2011 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # """ Test neutron and neutron buffer interfaces """ import journal debug = journal.debug( "conversion_TestCase" ) warning = journal.warning( "conversion_TestCase" ) from mcni.utils import conversion import unittestX as unittest class TestCase(unittest.TestCase): def test1(self): "conversion: e2v" e = 100 v = conversion.e2v(e) self.assertAlmostEqual(v, 4373.9331, 3) e1 = conversion.v2e(v)