Skip to main content
Ctrl+K

McStasScript documentation

Getting started

  • Overview
  • Installation
  • Version history
  • Quick start

User guide

  • Instrument object
  • Component object
  • Parameters and variables
  • Data
  • Plotting
  • Functions
  • Widgets
  • Instrument reader

McStasScript Tutorial

  • McStasScript introduction
  • Advanced McStas features: SPLIT
  • Advanced McStas features: EXTEND and WHEN
  • Advanced McStas features: JUMP
  • Dynamic instrument cuts with MCPL bridges
  • Diagnostics

McStas Union Tutorial

  • The Union components
  • Advanced geometry using the Union components
  • Visualizing what happens in Union master
  • Using conditional component to modify loggers
  • Union tutorial on masks
  • Advanced geometry component concepts: Exit geometry and number of activations
  • Union tagging system

Reference

  • mcstasscript
  • mcstasscript.data
    • mcstasscript.data.MCPLDataFormat
      • mcstasscript.data.MCPLDataFormat.MCPLDataFormat
    • mcstasscript.data.McStasDataFormat
      • mcstasscript.data.McStasDataFormat.McStasFormat
    • mcstasscript.data.data
      • mcstasscript.data.data.parse_coordinates
      • mcstasscript.data.data.ComponentData
      • mcstasscript.data.data.McStasData
      • mcstasscript.data.data.McStasDataBinned
      • mcstasscript.data.data.McStasDataEvent
      • mcstasscript.data.data.McStasMetaData
      • mcstasscript.data.data.McStasPlotOptions
    • mcstasscript.data.pyvinylData
      • mcstasscript.data.pyvinylData.pyvinylMCPLData
      • mcstasscript.data.pyvinylData.pyvinylMcStasData
  • mcstasscript.instr_reader
    • mcstasscript.instr_reader.control
      • mcstasscript.instr_reader.control.InstrumentReader
    • mcstasscript.instr_reader.read_declare
      • mcstasscript.instr_reader.read_declare.DeclareReader
    • mcstasscript.instr_reader.read_definition
      • mcstasscript.instr_reader.read_definition.DefinitionReader
    • mcstasscript.instr_reader.read_finally
      • mcstasscript.instr_reader.read_finally.FinallyReader
    • mcstasscript.instr_reader.read_initialize
      • mcstasscript.instr_reader.read_initialize.InitializeReader
    • mcstasscript.instr_reader.read_trace
      • mcstasscript.instr_reader.read_trace.TraceReader
    • mcstasscript.instr_reader.read_uservars
      • mcstasscript.instr_reader.read_uservars.UservarsReader
    • mcstasscript.instr_reader.util
      • mcstasscript.instr_reader.util.SectionReader
  • mcstasscript.interface
    • mcstasscript.interface.functions
      • mcstasscript.interface.functions.load_data
      • mcstasscript.interface.functions.load_metadata
      • mcstasscript.interface.functions.load_monitor
      • mcstasscript.interface.functions.name_plot_options
      • mcstasscript.interface.functions.name_search
      • mcstasscript.interface.functions.Configurator
    • mcstasscript.interface.instr
      • mcstasscript.interface.instr.McCode_instr
      • mcstasscript.interface.instr.McStas_instr
      • mcstasscript.interface.instr.McXtrace_instr
    • mcstasscript.interface.plotter
      • mcstasscript.interface.plotter.make_animation
      • mcstasscript.interface.plotter.make_plot
      • mcstasscript.interface.plotter.make_sub_plot
    • mcstasscript.interface.reader
      • mcstasscript.interface.reader.McStas_file
  • mcstasscript.jb_interface
    • mcstasscript.jb_interface.plot_interface
      • mcstasscript.jb_interface.plot_interface.ColormapDropdown
      • mcstasscript.jb_interface.plot_interface.LogCheckbox
      • mcstasscript.jb_interface.plot_interface.MonitorDropdown
      • mcstasscript.jb_interface.plot_interface.OrdersOfMagField
      • mcstasscript.jb_interface.plot_interface.PlotInterface
    • mcstasscript.jb_interface.show_interface
      • mcstasscript.jb_interface.show_interface.show
      • mcstasscript.jb_interface.show_interface.show_instrunent
      • mcstasscript.jb_interface.show_interface.show_plot
    • mcstasscript.jb_interface.simulation_interface
      • mcstasscript.jb_interface.simulation_interface.add_data
      • mcstasscript.jb_interface.simulation_interface.ParameterWidget
      • mcstasscript.jb_interface.simulation_interface.SimInterface
    • mcstasscript.jb_interface.widget_helpers
      • mcstasscript.jb_interface.widget_helpers.get_parameter_default
      • mcstasscript.jb_interface.widget_helpers.parameter_has_default
      • mcstasscript.jb_interface.widget_helpers.HiddenPrints
  • mcstasscript.tools

Reference (libpyvinyl)

  • libpyvinyl
  • Repository
  • Suggest edit
  • Open issue
  • .rst

mcstasscript.tests.test_functions.Test_name_search

Contents

  • Test_name_search
    • Test_name_search.__init__()
    • Test_name_search.test_name_search_filename_read()
    • Test_name_search.test_name_search_read()
    • Test_name_search.test_name_search_read_duplicate()
    • Test_name_search.test_name_search_read_error()
    • Test_name_search.test_name_search_read_repeat()
    • Test_name_search.test_name_search_type_error_not_McStasData()
    • Test_name_search.test_name_search_type_error_not_list()

mcstasscript.tests.test_functions.Test_name_search#

class mcstasscript.tests.test_functions.Test_name_search(methodName='runTest')#

Test the utility function called name_search which finds and returns a McStasData set with a given name from a list of McStasData objects.

__init__(methodName='runTest')#

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

Methods

__init__([methodName])

Create an instance of the class that will use the named test method when executed.

addClassCleanup(function, /, *args, **kwargs)

Same as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).

addCleanup(function, /, *args, **kwargs)

Add a function, with arguments, to be called when the test is completed.

addTypeEqualityFunc(typeobj, function)

Add a type specific assertEqual style function to compare a type.

assertAlmostEqual(first, second[, places, ...])

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.

assertAlmostEquals(**kwargs)

assertCountEqual(first, second[, msg])

Asserts that two iterables have the same elements, the same number of times, without regard to order.

assertDictContainsSubset(subset, dictionary)

Checks whether dictionary is a superset of subset.

assertDictEqual(d1, d2[, msg])

assertEqual(first, second[, msg])

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(**kwargs)

assertFalse(expr[, msg])

Check that the expression is false.

assertGreater(a, b[, msg])

Just like self.assertTrue(a > b), but with a nicer default message.

assertGreaterEqual(a, b[, msg])

Just like self.assertTrue(a >= b), but with a nicer default message.

assertIn(member, container[, msg])

Just like self.assertTrue(a in b), but with a nicer default message.

assertIs(expr1, expr2[, msg])

Just like self.assertTrue(a is b), but with a nicer default message.

assertIsInstance(obj, cls[, msg])

Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

assertIsNone(obj[, msg])

Same as self.assertTrue(obj is None), with a nicer default message.

assertIsNot(expr1, expr2[, msg])

Just like self.assertTrue(a is not b), but with a nicer default message.

assertIsNotNone(obj[, msg])

Included for symmetry with assertIsNone.

assertLess(a, b[, msg])

Just like self.assertTrue(a < b), but with a nicer default message.

assertLessEqual(a, b[, msg])

Just like self.assertTrue(a <= b), but with a nicer default message.

assertListEqual(list1, list2[, msg])

A list-specific equality assertion.

assertLogs([logger, level])

Fail unless a log message of level level or higher is emitted on logger_name or its children.

assertMultiLineEqual(first, second[, msg])

Assert that two multi-line strings are equal.

assertNoLogs([logger, level])

Fail unless no log messages of level level or higher are emitted on logger_name or its children.

assertNotAlmostEqual(first, second[, ...])

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.

assertNotAlmostEquals(**kwargs)

assertNotEqual(first, second[, msg])

Fail if the two objects are equal as determined by the '!=' operator.

assertNotEquals(**kwargs)

assertNotIn(member, container[, msg])

Just like self.assertTrue(a not in b), but with a nicer default message.

assertNotIsInstance(obj, cls[, msg])

Included for symmetry with assertIsInstance.

assertNotRegex(text, unexpected_regex[, msg])

Fail the test if the text matches the regular expression.

assertNotRegexpMatches(**kwargs)

assertRaises(expected_exception, *args, **kwargs)

Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments.

assertRaisesRegex(expected_exception, ...)

Asserts that the message in a raised exception matches a regex.

assertRaisesRegexp(**kwargs)

assertRegex(text, expected_regex[, msg])

Fail the test unless the text matches the regular expression.

assertRegexpMatches(**kwargs)

assertSequenceEqual(seq1, seq2[, msg, seq_type])

An equality assertion for ordered sequences (like lists and tuples).

assertSetEqual(set1, set2[, msg])

A set-specific equality assertion.

assertTrue(expr[, msg])

Check that the expression is true.

assertTupleEqual(tuple1, tuple2[, msg])

A tuple-specific equality assertion.

assertWarns(expected_warning, *args, **kwargs)

Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments.

assertWarnsRegex(expected_warning, ...)

Asserts that the message in a triggered warning matches a regexp.

assert_(**kwargs)

countTestCases()

debug()

Run the test without collecting errors in a TestResult

defaultTestResult()

doClassCleanups()

Execute all class cleanup functions.

doCleanups()

Execute all cleanup functions.

enterClassContext(cm)

Same as enterContext, but class-wide.

enterContext(cm)

Enters the supplied context manager.

fail([msg])

Fail immediately, with the given message.

failIf(**kwargs)

failIfAlmostEqual(**kwargs)

failIfEqual(**kwargs)

failUnless(**kwargs)

failUnlessAlmostEqual(**kwargs)

failUnlessEqual(**kwargs)

failUnlessRaises(**kwargs)

id()

run([result])

setUp()

Hook method for setting up the test fixture before exercising it.

setUpClass()

Hook method for setting up class fixture before running tests in the class.

shortDescription()

Returns a one-line description of the test, or None if no description has been provided.

skipTest(reason)

Skip this test.

subTest([msg])

Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters.

tearDown()

Hook method for deconstructing the test fixture after testing it.

tearDownClass()

Hook method for deconstructing the class fixture after running all tests in the class.

test_name_search_filename_read()

Test that Hero object can be found and check the unique dimension

test_name_search_read()

Test that Hero object can be found and check the unique dimension

test_name_search_read_duplicate()

Test simple case with duplicated name, search should return list

test_name_search_read_error()

Check an NameError is returned when no match is found

test_name_search_read_repeat()

Test that Hero object can be found and check the unique dimension Here the used data set has two monitors with Hero in the name

test_name_search_type_error_not_McStasData()

Checks that an error is returned if the given dataset contains non McStasData objects

test_name_search_type_error_not_list()

Check error is given even when data list is just single object

Attributes

longMessage

maxDiff

test_name_search_filename_read()#

Test that Hero object can be found and check the unique dimension

Here the name of the datafile is used

test_name_search_read()#

Test that Hero object can be found and check the unique dimension

Here the name is used

test_name_search_read_duplicate()#

Test simple case with duplicated name, search should return list

test_name_search_read_error()#

Check an NameError is returned when no match is found

test_name_search_read_repeat()#

Test that Hero object can be found and check the unique dimension Here the used data set has two monitors with Hero in the name

Here the name of the monitor is used

test_name_search_type_error_not_McStasData()#

Checks that an error is returned if the given dataset contains non McStasData objects

test_name_search_type_error_not_list()#

Check error is given even when data list is just single object

Contents
  • Test_name_search
    • Test_name_search.__init__()
    • Test_name_search.test_name_search_filename_read()
    • Test_name_search.test_name_search_read()
    • Test_name_search.test_name_search_read_duplicate()
    • Test_name_search.test_name_search_read_error()
    • Test_name_search.test_name_search_read_repeat()
    • Test_name_search.test_name_search_type_error_not_McStasData()
    • Test_name_search.test_name_search_type_error_not_list()

By Mads Bertelsen

© Copyright 2022, Mads Bertelsen.