sas.sascalc.data_util package

Submodules

sas.sascalc.data_util.calcthread module

class sas.sascalc.data_util.calcthread.CalcCommandline(n=20000)[source]

Bases: object

Test method

__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.calcthread', '__doc__': '\n        Test method\n    ', '__init__': <function CalcCommandline.__init__>, 'update': <function CalcCommandline.update>, 'complete': <function CalcCommandline.complete>, '__dict__': <attribute '__dict__' of 'CalcCommandline' objects>, '__weakref__': <attribute '__weakref__' of 'CalcCommandline' objects>, '__annotations__': {}})
__doc__ = '\n        Test method\n    '
__init__(n=20000)[source]
__module__ = 'sas.sascalc.data_util.calcthread'
__weakref__

list of weak references to the object (if defined)

complete(total=0.0)[source]
update(i=0)[source]
class sas.sascalc.data_util.calcthread.CalcDemo(completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01, exception_handler=None)[source]

Bases: CalcThread

Example of a calculation thread.

__doc__ = 'Example of a calculation thread.'
__module__ = 'sas.sascalc.data_util.calcthread'
compute(n)[source]

Perform a work unit. The subclass will provide details of the arguments.

class sas.sascalc.data_util.calcthread.CalcThread(completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01, exception_handler=None)[source]

Bases: object

Threaded calculation class. Inherit from here and specialize the compute() method to perform the appropriate operations for the class.

If you specialize the __init__ method be sure to call CalcThread.__init__, passing it the keyword arguments for yieldtime, worktime, update and complete.

When defining the compute() method you need to include code which allows the GUI to run. They are as follows:

self.isquit()          # call frequently to check for interrupts
self.update(kw=...)    # call when the GUI could be updated
self.complete(kw=...)  # call before exiting compute()

The update() and complete() calls accept field=value keyword arguments which are passed to the called function. complete() should be called before exiting the GUI function. A KeyboardInterrupt event is triggered if the GUI signals that the computation should be halted.

The following documentation should be included in the description of the derived class.

The user of this class will call the following:

thread = Work(...,kw=...)  # prepare the work thread.
thread.queue(...,kw=...)   # queue a work unit
thread.requeue(...,kw=...) # replace work unit on the end of queue
thread.reset(...,kw=...)   # reset the queue to the given work unit
thread.stop()              # clear the queue and halt
thread.interrupt()         # halt the current work unit but continue
thread.ready(delay=0.)     # request an update signal after delay
thread.isrunning()         # returns true if compute() is running

Use queue() when all work must be done. Use requeue() when intermediate work items don’t need to be done (e.g., in response to a mouse move event). Use reset() when the current item doesn’t need to be completed before the new event (e.g., in response to a mouse release event). Use stop() to halt the current and pending computations (e.g., in response to a stop button).

The methods queue(), requeue() and reset() are proxies for the compute() method in the subclass. Look there for a description of the arguments. The compute() method can be called directly to run the computation in the main thread, but it should not be called if isrunning() returns true.

The constructor accepts additional keywords yieldtime=0.01 and worktime=0.01 which determine the cooperative multitasking behaviour. Yield time is the duration of the sleep period required to give other processes a chance to run. Work time is the duration between sleep periods.

Notifying the GUI thread of work in progress and work complete is done with updatefn=updatefn and completefn=completefn arguments to the constructor. Details of the parameters to the functions depend on the particular calculation class, but they will all be passed as keyword arguments. Details of how the functions should be implemented vary from framework to framework.

For wx, something like the following is needed:

import wx, wx.lib.newevent
(CalcCompleteEvent, EVT_CALC_COMPLETE) = wx.lib.newevent.NewEvent()

# methods in the main window class of your application
def __init__():
    ...
    # Prepare the calculation in the GUI thread.
    self.work = Work(completefn=self.CalcComplete)
    self.Bind(EVT_CALC_COMPLETE, self.OnCalcComplete)
    ...
    # Bind work queue to a menu event.
    self.Bind(wx.EVT_MENU, self.OnCalcStart, id=idCALCSTART)
    ...

def OnCalcStart(self,event):
    # Start the work thread from the GUI thread.
    self.work.queue(...work unit parameters...)

def CalcComplete(self,**kwargs):
    # Generate CalcComplete event in the calculation thread.
    # kwargs contains field1, field2, etc. as defined by
    # the Work thread class.
    event = CalcCompleteEvent(**kwargs)
    wx.PostEvent(self, event)

def OnCalcComplete(self,event):
    # Process CalcComplete event in GUI thread.
    # Use values from event.field1, event.field2 etc. as
    # defined by the Work thread class to show the results.
    ...
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.calcthread', '__doc__': "Threaded calculation class.  Inherit from here and specialize\n    the compute() method to perform the appropriate operations for the\n    class.\n\n    If you specialize the __init__ method be sure to call\n    CalcThread.__init__, passing it the keyword arguments for\n    yieldtime, worktime, update and complete.\n\n    When defining the compute() method you need to include code which\n    allows the GUI to run.  They are as follows: ::\n\n        self.isquit()          # call frequently to check for interrupts\n        self.update(kw=...)    # call when the GUI could be updated\n        self.complete(kw=...)  # call before exiting compute()\n\n    The update() and complete() calls accept field=value keyword\n    arguments which are passed to the called function.  complete()\n    should be called before exiting the GUI function.  A KeyboardInterrupt\n    event is triggered if the GUI signals that the computation should\n    be halted.\n\n    The following documentation should be included in the description\n    of the derived class.\n\n    The user of this class will call the following: ::\n\n        thread = Work(...,kw=...)  # prepare the work thread.\n        thread.queue(...,kw=...)   # queue a work unit\n        thread.requeue(...,kw=...) # replace work unit on the end of queue\n        thread.reset(...,kw=...)   # reset the queue to the given work unit\n        thread.stop()              # clear the queue and halt\n        thread.interrupt()         # halt the current work unit but continue\n        thread.ready(delay=0.)     # request an update signal after delay\n        thread.isrunning()         # returns true if compute() is running\n\n    Use queue() when all work must be done.  Use requeue() when intermediate\n    work items don't need to be done (e.g., in response to a mouse move\n    event).  Use reset() when the current item doesn't need to be completed\n    before the new event (e.g., in response to a mouse release event).  Use\n    stop() to halt the current and pending computations (e.g., in response to\n    a stop button).\n\n    The methods queue(), requeue() and reset() are proxies for the compute()\n    method in the subclass.  Look there for a description of the arguments.\n    The compute() method can be called directly to run the computation in\n    the main thread, but it should not be called if isrunning() returns true.\n\n    The constructor accepts additional keywords yieldtime=0.01 and\n    worktime=0.01 which determine the cooperative multitasking\n    behaviour.  Yield time is the duration of the sleep period\n    required to give other processes a chance to run.  Work time\n    is the duration between sleep periods.\n\n    Notifying the GUI thread of work in progress and work complete\n    is done with updatefn=updatefn and completefn=completefn arguments\n    to the constructor.  Details of the parameters to the functions\n    depend on the particular calculation class, but they will all\n    be passed as keyword arguments.  Details of how the functions\n    should be implemented vary from framework to framework.\n\n    For wx, something like the following is needed::\n\n        import wx, wx.lib.newevent\n        (CalcCompleteEvent, EVT_CALC_COMPLETE) = wx.lib.newevent.NewEvent()\n\n        # methods in the main window class of your application\n        def __init__():\n            ...\n            # Prepare the calculation in the GUI thread.\n            self.work = Work(completefn=self.CalcComplete)\n            self.Bind(EVT_CALC_COMPLETE, self.OnCalcComplete)\n            ...\n            # Bind work queue to a menu event.\n            self.Bind(wx.EVT_MENU, self.OnCalcStart, id=idCALCSTART)\n            ...\n\n        def OnCalcStart(self,event):\n            # Start the work thread from the GUI thread.\n            self.work.queue(...work unit parameters...)\n\n        def CalcComplete(self,**kwargs):\n            # Generate CalcComplete event in the calculation thread.\n            # kwargs contains field1, field2, etc. as defined by\n            # the Work thread class.\n            event = CalcCompleteEvent(**kwargs)\n            wx.PostEvent(self, event)\n\n        def OnCalcComplete(self,event):\n            # Process CalcComplete event in GUI thread.\n            # Use values from event.field1, event.field2 etc. as\n            # defined by the Work thread class to show the results.\n            ...\n    ", '__init__': <function CalcThread.__init__>, 'queue': <function CalcThread.queue>, 'requeue': <function CalcThread.requeue>, 'reset': <function CalcThread.reset>, 'stop': <function CalcThread.stop>, 'interrupt': <function CalcThread.interrupt>, 'isrunning': <function CalcThread.isrunning>, 'ready': <function CalcThread.ready>, 'isquit': <function CalcThread.isquit>, 'update': <function CalcThread.update>, 'complete': <function CalcThread.complete>, 'compute': <function CalcThread.compute>, 'exception': <function CalcThread.exception>, '_run': <function CalcThread._run>, '__dict__': <attribute '__dict__' of 'CalcThread' objects>, '__weakref__': <attribute '__weakref__' of 'CalcThread' objects>, '__annotations__': {}})
__doc__ = "Threaded calculation class.  Inherit from here and specialize\n    the compute() method to perform the appropriate operations for the\n    class.\n\n    If you specialize the __init__ method be sure to call\n    CalcThread.__init__, passing it the keyword arguments for\n    yieldtime, worktime, update and complete.\n\n    When defining the compute() method you need to include code which\n    allows the GUI to run.  They are as follows: ::\n\n        self.isquit()          # call frequently to check for interrupts\n        self.update(kw=...)    # call when the GUI could be updated\n        self.complete(kw=...)  # call before exiting compute()\n\n    The update() and complete() calls accept field=value keyword\n    arguments which are passed to the called function.  complete()\n    should be called before exiting the GUI function.  A KeyboardInterrupt\n    event is triggered if the GUI signals that the computation should\n    be halted.\n\n    The following documentation should be included in the description\n    of the derived class.\n\n    The user of this class will call the following: ::\n\n        thread = Work(...,kw=...)  # prepare the work thread.\n        thread.queue(...,kw=...)   # queue a work unit\n        thread.requeue(...,kw=...) # replace work unit on the end of queue\n        thread.reset(...,kw=...)   # reset the queue to the given work unit\n        thread.stop()              # clear the queue and halt\n        thread.interrupt()         # halt the current work unit but continue\n        thread.ready(delay=0.)     # request an update signal after delay\n        thread.isrunning()         # returns true if compute() is running\n\n    Use queue() when all work must be done.  Use requeue() when intermediate\n    work items don't need to be done (e.g., in response to a mouse move\n    event).  Use reset() when the current item doesn't need to be completed\n    before the new event (e.g., in response to a mouse release event).  Use\n    stop() to halt the current and pending computations (e.g., in response to\n    a stop button).\n\n    The methods queue(), requeue() and reset() are proxies for the compute()\n    method in the subclass.  Look there for a description of the arguments.\n    The compute() method can be called directly to run the computation in\n    the main thread, but it should not be called if isrunning() returns true.\n\n    The constructor accepts additional keywords yieldtime=0.01 and\n    worktime=0.01 which determine the cooperative multitasking\n    behaviour.  Yield time is the duration of the sleep period\n    required to give other processes a chance to run.  Work time\n    is the duration between sleep periods.\n\n    Notifying the GUI thread of work in progress and work complete\n    is done with updatefn=updatefn and completefn=completefn arguments\n    to the constructor.  Details of the parameters to the functions\n    depend on the particular calculation class, but they will all\n    be passed as keyword arguments.  Details of how the functions\n    should be implemented vary from framework to framework.\n\n    For wx, something like the following is needed::\n\n        import wx, wx.lib.newevent\n        (CalcCompleteEvent, EVT_CALC_COMPLETE) = wx.lib.newevent.NewEvent()\n\n        # methods in the main window class of your application\n        def __init__():\n            ...\n            # Prepare the calculation in the GUI thread.\n            self.work = Work(completefn=self.CalcComplete)\n            self.Bind(EVT_CALC_COMPLETE, self.OnCalcComplete)\n            ...\n            # Bind work queue to a menu event.\n            self.Bind(wx.EVT_MENU, self.OnCalcStart, id=idCALCSTART)\n            ...\n\n        def OnCalcStart(self,event):\n            # Start the work thread from the GUI thread.\n            self.work.queue(...work unit parameters...)\n\n        def CalcComplete(self,**kwargs):\n            # Generate CalcComplete event in the calculation thread.\n            # kwargs contains field1, field2, etc. as defined by\n            # the Work thread class.\n            event = CalcCompleteEvent(**kwargs)\n            wx.PostEvent(self, event)\n\n        def OnCalcComplete(self,event):\n            # Process CalcComplete event in GUI thread.\n            # Use values from event.field1, event.field2 etc. as\n            # defined by the Work thread class to show the results.\n            ...\n    "
__init__(completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01, exception_handler=None)[source]

Prepare the calculator

__module__ = 'sas.sascalc.data_util.calcthread'
__weakref__

list of weak references to the object (if defined)

_run()[source]

Internal function to manage the thread.

complete(**kwargs)[source]

Update the GUI with the completed results from a work unit.

compute(*args, **kwargs)[source]

Perform a work unit. The subclass will provide details of the arguments.

exception()[source]

An exception occurred during computation, so call the exception handler if there is one. If not, then log the exception and continue.

interrupt()[source]

Stop the current work item. To clear the work queue as well call the stop() method.

isquit()[source]

Check for interrupts. Should be called frequently to provide user responsiveness. Also yields to other running threads, which is required for good performance on OS X.

isrunning()[source]
queue(*args, **kwargs)[source]

Add a work unit to the end of the queue. See the compute() method for details of the arguments to the work unit.

ready(delay=0.0)[source]

Ready for another update after delay=t seconds. Call this for threads which can show intermediate results from long calculations.

requeue(*args, **kwargs)[source]

Replace the work unit on the end of the queue. See the compute() method for details of the arguments to the work unit.

reset(*args, **kwargs)[source]

Clear the queue and start a new work unit. See the compute() method for details of the arguments to the work unit.

stop()[source]

Clear the queue and stop the thread. New items may be queued after stop. To stop just the current work item, and continue the rest of the queue call the interrupt method

update(**kwargs)[source]

Update GUI with the lastest results from the current work unit.

sas.sascalc.data_util.err1d module

Error propogation algorithms for simple arithmetic

Warning: like the underlying numpy library, the inplace operations may return values of the wrong type if some of the arguments are integers, so be sure to create them with floating point inputs.

sas.sascalc.data_util.err1d.add(X, varX, Y, varY)[source]

Addition with error propagation

sas.sascalc.data_util.err1d.add_inplace(X, varX, Y, varY)[source]

In-place addition with error propagation

sas.sascalc.data_util.err1d.div(X, varX, Y, varY)[source]

Division with error propagation

sas.sascalc.data_util.err1d.div_inplace(X, varX, Y, varY)[source]

In-place division with error propagation

sas.sascalc.data_util.err1d.exp(X, varX)[source]

Exponentiation with error propagation

sas.sascalc.data_util.err1d.log(X, varX)[source]

Logarithm with error propagation

sas.sascalc.data_util.err1d.mul(X, varX, Y, varY)[source]

Multiplication with error propagation

sas.sascalc.data_util.err1d.mul_inplace(X, varX, Y, varY)[source]

In-place multiplication with error propagation

sas.sascalc.data_util.err1d.pow(X, varX, n)[source]

X**n with error propagation

sas.sascalc.data_util.err1d.pow_inplace(X, varX, n)[source]

In-place X**n with error propagation

sas.sascalc.data_util.err1d.sub(X, varX, Y, varY)[source]

Subtraction with error propagation

sas.sascalc.data_util.err1d.sub_inplace(X, varX, Y, varY)[source]

In-place subtraction with error propagation

sas.sascalc.data_util.formatnum module

Format values and uncertainties nicely for printing.

format_uncertainty_pm() produces the expanded format v +/- err.

format_uncertainty_compact() produces the compact format v(##), where the number in parenthesis is the uncertainty in the last two digits of v.

format_uncertainty() uses the compact format by default, but this can be changed to use the expanded +/- format by setting format_uncertainty.compact to False.

The formatted string uses only the number of digits warranted by the uncertainty in the measurement.

If the uncertainty is 0 or not otherwise provided, the simple %g floating point format option is used.

Infinite and indefinite numbers are represented as inf and NaN.

Example:

>>> v,dv = 757.2356,0.01032
>>> print format_uncertainty_pm(v,dv)
757.236 +/- 0.010
>>> print format_uncertainty_compact(v,dv)
757.236(10)
>>> print format_uncertainty(v,dv)
757.236(10)
>>> format_uncertainty.compact = False
>>> print format_uncertainty(v,dv)
757.236 +/- 0.010

UncertaintyFormatter() returns a private formatter with its own formatter.compact flag.

class sas.sascalc.data_util.formatnum.UncertaintyFormatter[source]

Bases: object

Value and uncertainty formatter.

The formatter instance will use either the expanded v +/- dv form or the compact v(##) form depending on whether formatter.compact is True or False. The default is True.

__call__(value, uncertainty)[source]

Given value and uncertainty, return a string representation.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.formatnum', '__doc__': '\n    Value and uncertainty formatter.\n\n    The *formatter* instance will use either the expanded v +/- dv form\n    or the compact v(##) form depending on whether *formatter.compact* is\n    True or False.  The default is True.\n    ', 'compact': True, '__call__': <function UncertaintyFormatter.__call__>, '__dict__': <attribute '__dict__' of 'UncertaintyFormatter' objects>, '__weakref__': <attribute '__weakref__' of 'UncertaintyFormatter' objects>, '__annotations__': {}})
__doc__ = '\n    Value and uncertainty formatter.\n\n    The *formatter* instance will use either the expanded v +/- dv form\n    or the compact v(##) form depending on whether *formatter.compact* is\n    True or False.  The default is True.\n    '
__module__ = 'sas.sascalc.data_util.formatnum'
__weakref__

list of weak references to the object (if defined)

compact = True
sas.sascalc.data_util.formatnum._format_uncertainty(value, uncertainty, compact)[source]

Implementation of both the compact and the +/- formats.

sas.sascalc.data_util.formatnum.format_uncertainty_compact(value, uncertainty)[source]

Given value v and uncertainty dv, return the compact representation v(##), where ## are the first two digits of the uncertainty.

sas.sascalc.data_util.formatnum.format_uncertainty_pm(value, uncertainty)[source]

Given value v and uncertainty dv, return a string v +/- dv.

sas.sascalc.data_util.formatnum.main()[source]

Run all tests.

This is equivalent to “nosetests –with-doctest”

sas.sascalc.data_util.formatnum.test_compact()[source]
sas.sascalc.data_util.formatnum.test_default()[source]
sas.sascalc.data_util.formatnum.test_pm()[source]

sas.sascalc.data_util.nxsunit module

Define unit conversion support for NeXus style units.

The unit format is somewhat complicated. There are variant spellings and incorrect capitalization to worry about, as well as forms such as “mili*metre” and “1e-7 seconds”.

This is a minimal implementation of units including only what I happen to need now. It does not support the complete dimensional analysis provided by the package udunits on which NeXus is based, or even the units used in the NeXus definition files.

Unlike other units packages, this package does not carry the units along with the value but merely provides a conversion function for transforming values.

Usage example:

import nxsunit
u = nxsunit.Converter('mili*metre')  # Units stored in mm
v = u(3000,'m')  # Convert the value 3000 mm into meters

NeXus example:

# Load sample orientation in radians regardless of how it is stored.
# 1. Open the path
file.openpath('/entry1/sample/sample_orientation')
# 2. scan the attributes, retrieving 'units'
units = [for attr,value in file.attrs() if attr == 'units']
# 3. set up the converter (assumes that units actually exists)
u = nxsunit.Converter(units[0])
# 4. read the data and convert to the correct units
v = u(file.read(),'radians')

This is a standalone module, not relying on either DANSE or NeXus, and can be used for other unit conversion tasks.

Note: minutes are used for angle and seconds are used for time. We cannot tell what the correct interpretation is without knowing something about the fields themselves. If this becomes an issue, we will need to allow the application to set the dimension for the unit rather than inferring the dimension from an example unit.

class sas.sascalc.data_util.nxsunit.Converter(name)[source]

Bases: object

Unit converter for NeXus style units.

__call__(value, units='')[source]

Call self as a function.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.nxsunit', '__doc__': '\n    Unit converter for NeXus style units.\n    ', 'scalemap': None, 'scalebase': 1, 'dims': [{'m': 1, 'Pm': 1000000000000000.0, 'Tm': 1000000000000.0, 'Gm': 1000000000.0, 'Mm': 1000000.0, 'km': 1000.0, 'dm': 0.1, 'cm': 0.01, 'mm': 0.001, 'um': 1e-06, 'nm': 1e-09, 'pm': 1e-12, 'fm': 1e-15, 'meter': 1, 'meters': 1, 'petameter': 1000000000000000.0, 'terameter': 1000000000000.0, 'gigameter': 1000000000.0, 'megameter': 1000000.0, 'kilometer': 1000.0, 'decimeter': 0.1, 'centimeter': 0.01, 'millimeter': 0.001, 'milimeter': 0.001, 'micrometer': 1e-06, 'nanometer': 1e-09, 'picometer': 1e-12, 'femtometer': 1e-15, 'peta*meter': 1000000000000000.0, 'tera*meter': 1000000000000.0, 'giga*meter': 1000000000.0, 'mega*meter': 1000000.0, 'kilo*meter': 1000.0, 'deci*meter': 0.1, 'centi*meter': 0.01, 'milli*meter': 0.001, 'mili*meter': 0.001, 'micro*meter': 1e-06, 'nano*meter': 1e-09, 'pico*meter': 1e-12, 'femto*meter': 1e-15, 'petameters': 1000000000000000.0, 'terameters': 1000000000000.0, 'gigameters': 1000000000.0, 'megameters': 1000000.0, 'kilometers': 1000.0, 'decimeters': 0.1, 'centimeters': 0.01, 'millimeters': 0.001, 'milimeters': 0.001, 'micrometers': 1e-06, 'nanometers': 1e-09, 'picometers': 1e-12, 'femtometers': 1e-15, 'Meter': 1, 'Meters': 1, 'petaMeter': 1000000000000000.0, 'teraMeter': 1000000000000.0, 'gigaMeter': 1000000000.0, 'megaMeter': 1000000.0, 'kiloMeter': 1000.0, 'deciMeter': 0.1, 'centiMeter': 0.01, 'milliMeter': 0.001, 'miliMeter': 0.001, 'microMeter': 1e-06, 'nanoMeter': 1e-09, 'picoMeter': 1e-12, 'femtoMeter': 1e-15, 'peta*Meter': 1000000000000000.0, 'tera*Meter': 1000000000000.0, 'giga*Meter': 1000000000.0, 'mega*Meter': 1000000.0, 'kilo*Meter': 1000.0, 'deci*Meter': 0.1, 'centi*Meter': 0.01, 'milli*Meter': 0.001, 'mili*Meter': 0.001, 'micro*Meter': 1e-06, 'nano*Meter': 1e-09, 'pico*Meter': 1e-12, 'femto*Meter': 1e-15, 'petaMeters': 1000000000000000.0, 'teraMeters': 1000000000000.0, 'gigaMeters': 1000000000.0, 'megaMeters': 1000000.0, 'kiloMeters': 1000.0, 'deciMeters': 0.1, 'centiMeters': 0.01, 'milliMeters': 0.001, 'miliMeters': 0.001, 'microMeters': 1e-06, 'nanoMeters': 1e-09, 'picoMeters': 1e-12, 'femtoMeters': 1e-15, 'metre': 1, 'metres': 1, 'petametre': 1000000000000000.0, 'terametre': 1000000000000.0, 'gigametre': 1000000000.0, 'megametre': 1000000.0, 'kilometre': 1000.0, 'decimetre': 0.1, 'centimetre': 0.01, 'millimetre': 0.001, 'milimetre': 0.001, 'micrometre': 1e-06, 'nanometre': 1e-09, 'picometre': 1e-12, 'femtometre': 1e-15, 'peta*metre': 1000000000000000.0, 'tera*metre': 1000000000000.0, 'giga*metre': 1000000000.0, 'mega*metre': 1000000.0, 'kilo*metre': 1000.0, 'deci*metre': 0.1, 'centi*metre': 0.01, 'milli*metre': 0.001, 'mili*metre': 0.001, 'micro*metre': 1e-06, 'nano*metre': 1e-09, 'pico*metre': 1e-12, 'femto*metre': 1e-15, 'petametres': 1000000000000000.0, 'terametres': 1000000000000.0, 'gigametres': 1000000000.0, 'megametres': 1000000.0, 'kilometres': 1000.0, 'decimetres': 0.1, 'centimetres': 0.01, 'millimetres': 0.001, 'milimetres': 0.001, 'micrometres': 1e-06, 'nanometres': 1e-09, 'picometres': 1e-12, 'femtometres': 1e-15, 'Metre': 1, 'Metres': 1, 'petaMetre': 1000000000000000.0, 'teraMetre': 1000000000000.0, 'gigaMetre': 1000000000.0, 'megaMetre': 1000000.0, 'kiloMetre': 1000.0, 'deciMetre': 0.1, 'centiMetre': 0.01, 'milliMetre': 0.001, 'miliMetre': 0.001, 'microMetre': 1e-06, 'nanoMetre': 1e-09, 'picoMetre': 1e-12, 'femtoMetre': 1e-15, 'peta*Metre': 1000000000000000.0, 'tera*Metre': 1000000000000.0, 'giga*Metre': 1000000000.0, 'mega*Metre': 1000000.0, 'kilo*Metre': 1000.0, 'deci*Metre': 0.1, 'centi*Metre': 0.01, 'milli*Metre': 0.001, 'mili*Metre': 0.001, 'micro*Metre': 1e-06, 'nano*Metre': 1e-09, 'pico*Metre': 1e-12, 'femto*Metre': 1e-15, 'petaMetres': 1000000000000000.0, 'teraMetres': 1000000000000.0, 'gigaMetres': 1000000000.0, 'megaMetres': 1000000.0, 'kiloMetres': 1000.0, 'deciMetres': 0.1, 'centiMetres': 0.01, 'milliMetres': 0.001, 'miliMetres': 0.001, 'microMetres': 1e-06, 'nanoMetres': 1e-09, 'picoMetres': 1e-12, 'femtoMetres': 1e-15, 'micron': 1e-06, 'Angstrom': 1e-10, 'microns': 1e-06, 'Angstroms': 1e-10, 'A': 1e-10, 'Ang': 1e-10}, {'s': 1, 'Ps': 1000000000000000.0, 'Ts': 1000000000000.0, 'Gs': 1000000000.0, 'Ms': 1000000.0, 'ks': 1000.0, 'ds': 0.1, 'cs': 0.01, 'ms': 0.001, 'us': 1e-06, 'ns': 1e-09, 'ps': 1e-12, 'fs': 1e-15, 'second': 1, 'seconds': 1, 'petasecond': 1000000000000000.0, 'terasecond': 1000000000000.0, 'gigasecond': 1000000000.0, 'megasecond': 1000000.0, 'kilosecond': 1000.0, 'decisecond': 0.1, 'centisecond': 0.01, 'millisecond': 0.001, 'milisecond': 0.001, 'microsecond': 1e-06, 'nanosecond': 1e-09, 'picosecond': 1e-12, 'femtosecond': 1e-15, 'peta*second': 1000000000000000.0, 'tera*second': 1000000000000.0, 'giga*second': 1000000000.0, 'mega*second': 1000000.0, 'kilo*second': 1000.0, 'deci*second': 0.1, 'centi*second': 0.01, 'milli*second': 0.001, 'mili*second': 0.001, 'micro*second': 1e-06, 'nano*second': 1e-09, 'pico*second': 1e-12, 'femto*second': 1e-15, 'petaseconds': 1000000000000000.0, 'teraseconds': 1000000000000.0, 'gigaseconds': 1000000000.0, 'megaseconds': 1000000.0, 'kiloseconds': 1000.0, 'deciseconds': 0.1, 'centiseconds': 0.01, 'milliseconds': 0.001, 'miliseconds': 0.001, 'microseconds': 1e-06, 'nanoseconds': 1e-09, 'picoseconds': 1e-12, 'femtoseconds': 1e-15, 'Second': 1, 'Seconds': 1, 'petaSecond': 1000000000000000.0, 'teraSecond': 1000000000000.0, 'gigaSecond': 1000000000.0, 'megaSecond': 1000000.0, 'kiloSecond': 1000.0, 'deciSecond': 0.1, 'centiSecond': 0.01, 'milliSecond': 0.001, 'miliSecond': 0.001, 'microSecond': 1e-06, 'nanoSecond': 1e-09, 'picoSecond': 1e-12, 'femtoSecond': 1e-15, 'peta*Second': 1000000000000000.0, 'tera*Second': 1000000000000.0, 'giga*Second': 1000000000.0, 'mega*Second': 1000000.0, 'kilo*Second': 1000.0, 'deci*Second': 0.1, 'centi*Second': 0.01, 'milli*Second': 0.001, 'mili*Second': 0.001, 'micro*Second': 1e-06, 'nano*Second': 1e-09, 'pico*Second': 1e-12, 'femto*Second': 1e-15, 'petaSeconds': 1000000000000000.0, 'teraSeconds': 1000000000000.0, 'gigaSeconds': 1000000000.0, 'megaSeconds': 1000000.0, 'kiloSeconds': 1000.0, 'deciSeconds': 0.1, 'centiSeconds': 0.01, 'milliSeconds': 0.001, 'miliSeconds': 0.001, 'microSeconds': 1e-06, 'nanoSeconds': 1e-09, 'picoSeconds': 1e-12, 'femtoSeconds': 1e-15, 'hour': 3600, 'day': 86400, 'week': 604800, 'hours': 3600, 'days': 86400, 'weeks': 604800}, {'degree': 1, 'minute': 0.016666666666666666, 'arcminute': 0.016666666666666666, 'arcsecond': 0.0002777777777777778, 'radian': 57.29577951308232, 'degrees': 1, 'minutes': 0.016666666666666666, 'arcminutes': 0.016666666666666666, 'arcseconds': 0.0002777777777777778, 'radians': 57.29577951308232, 'deg': 1, 'arcmin': 0.016666666666666666, 'arcsec': 0.0002777777777777778, 'rad': 57.29577951308232}, {'Hz': 1, 'PHz': 1000000000000000.0, 'THz': 1000000000000.0, 'GHz': 1000000000.0, 'MHz': 1000000.0, 'kHz': 1000.0, 'dHz': 0.1, 'cHz': 0.01, 'mHz': 0.001, 'uHz': 1e-06, 'nHz': 1e-09, 'pHz': 1e-12, 'fHz': 1e-15, 'hertz': 1, 'hertzs': 1, 'petahertz': 1000000000000000.0, 'terahertz': 1000000000000.0, 'gigahertz': 1000000000.0, 'megahertz': 1000000.0, 'kilohertz': 1000.0, 'decihertz': 0.1, 'centihertz': 0.01, 'millihertz': 0.001, 'milihertz': 0.001, 'microhertz': 1e-06, 'nanohertz': 1e-09, 'picohertz': 1e-12, 'femtohertz': 1e-15, 'peta*hertz': 1000000000000000.0, 'tera*hertz': 1000000000000.0, 'giga*hertz': 1000000000.0, 'mega*hertz': 1000000.0, 'kilo*hertz': 1000.0, 'deci*hertz': 0.1, 'centi*hertz': 0.01, 'milli*hertz': 0.001, 'mili*hertz': 0.001, 'micro*hertz': 1e-06, 'nano*hertz': 1e-09, 'pico*hertz': 1e-12, 'femto*hertz': 1e-15, 'petahertzs': 1000000000000000.0, 'terahertzs': 1000000000000.0, 'gigahertzs': 1000000000.0, 'megahertzs': 1000000.0, 'kilohertzs': 1000.0, 'decihertzs': 0.1, 'centihertzs': 0.01, 'millihertzs': 0.001, 'milihertzs': 0.001, 'microhertzs': 1e-06, 'nanohertzs': 1e-09, 'picohertzs': 1e-12, 'femtohertzs': 1e-15, 'Hertz': 1, 'Hertzs': 1, 'petaHertz': 1000000000000000.0, 'teraHertz': 1000000000000.0, 'gigaHertz': 1000000000.0, 'megaHertz': 1000000.0, 'kiloHertz': 1000.0, 'deciHertz': 0.1, 'centiHertz': 0.01, 'milliHertz': 0.001, 'miliHertz': 0.001, 'microHertz': 1e-06, 'nanoHertz': 1e-09, 'picoHertz': 1e-12, 'femtoHertz': 1e-15, 'peta*Hertz': 1000000000000000.0, 'tera*Hertz': 1000000000000.0, 'giga*Hertz': 1000000000.0, 'mega*Hertz': 1000000.0, 'kilo*Hertz': 1000.0, 'deci*Hertz': 0.1, 'centi*Hertz': 0.01, 'milli*Hertz': 0.001, 'mili*Hertz': 0.001, 'micro*Hertz': 1e-06, 'nano*Hertz': 1e-09, 'pico*Hertz': 1e-12, 'femto*Hertz': 1e-15, 'petaHertzs': 1000000000000000.0, 'teraHertzs': 1000000000000.0, 'gigaHertzs': 1000000000.0, 'megaHertzs': 1000000.0, 'kiloHertzs': 1000.0, 'deciHertzs': 0.1, 'centiHertzs': 0.01, 'milliHertzs': 0.001, 'miliHertzs': 0.001, 'microHertzs': 1e-06, 'nanoHertzs': 1e-09, 'picoHertzs': 1e-12, 'femtoHertzs': 1e-15, 'rpm': 0.016666666666666666, 'rpms': 0.016666666666666666}, {'K': 1, 'PK': 1000000000000000.0, 'TK': 1000000000000.0, 'GK': 1000000000.0, 'MK': 1000000.0, 'kK': 1000.0, 'dK': 0.1, 'cK': 0.01, 'mK': 0.001, 'uK': 1e-06, 'nK': 1e-09, 'pK': 1e-12, 'fK': 1e-15, 'kelvin': 1, 'kelvins': 1, 'petakelvin': 1000000000000000.0, 'terakelvin': 1000000000000.0, 'gigakelvin': 1000000000.0, 'megakelvin': 1000000.0, 'kilokelvin': 1000.0, 'decikelvin': 0.1, 'centikelvin': 0.01, 'millikelvin': 0.001, 'milikelvin': 0.001, 'microkelvin': 1e-06, 'nanokelvin': 1e-09, 'picokelvin': 1e-12, 'femtokelvin': 1e-15, 'peta*kelvin': 1000000000000000.0, 'tera*kelvin': 1000000000000.0, 'giga*kelvin': 1000000000.0, 'mega*kelvin': 1000000.0, 'kilo*kelvin': 1000.0, 'deci*kelvin': 0.1, 'centi*kelvin': 0.01, 'milli*kelvin': 0.001, 'mili*kelvin': 0.001, 'micro*kelvin': 1e-06, 'nano*kelvin': 1e-09, 'pico*kelvin': 1e-12, 'femto*kelvin': 1e-15, 'petakelvins': 1000000000000000.0, 'terakelvins': 1000000000000.0, 'gigakelvins': 1000000000.0, 'megakelvins': 1000000.0, 'kilokelvins': 1000.0, 'decikelvins': 0.1, 'centikelvins': 0.01, 'millikelvins': 0.001, 'milikelvins': 0.001, 'microkelvins': 1e-06, 'nanokelvins': 1e-09, 'picokelvins': 1e-12, 'femtokelvins': 1e-15, 'Kelvin': 1, 'Kelvins': 1, 'petaKelvin': 1000000000000000.0, 'teraKelvin': 1000000000000.0, 'gigaKelvin': 1000000000.0, 'megaKelvin': 1000000.0, 'kiloKelvin': 1000.0, 'deciKelvin': 0.1, 'centiKelvin': 0.01, 'milliKelvin': 0.001, 'miliKelvin': 0.001, 'microKelvin': 1e-06, 'nanoKelvin': 1e-09, 'picoKelvin': 1e-12, 'femtoKelvin': 1e-15, 'peta*Kelvin': 1000000000000000.0, 'tera*Kelvin': 1000000000000.0, 'giga*Kelvin': 1000000000.0, 'mega*Kelvin': 1000000.0, 'kilo*Kelvin': 1000.0, 'deci*Kelvin': 0.1, 'centi*Kelvin': 0.01, 'milli*Kelvin': 0.001, 'mili*Kelvin': 0.001, 'micro*Kelvin': 1e-06, 'nano*Kelvin': 1e-09, 'pico*Kelvin': 1e-12, 'femto*Kelvin': 1e-15, 'petaKelvins': 1000000000000000.0, 'teraKelvins': 1000000000000.0, 'gigaKelvins': 1000000000.0, 'megaKelvins': 1000000.0, 'kiloKelvins': 1000.0, 'deciKelvins': 0.1, 'centiKelvins': 0.01, 'milliKelvins': 0.001, 'miliKelvins': 0.001, 'microKelvins': 1e-06, 'nanoKelvins': 1e-09, 'picoKelvins': 1e-12, 'femtoKelvins': 1e-15, 'C': 1, 'PC': 1000000000000000.0, 'TC': 1000000000000.0, 'GC': 1000000000.0, 'MC': 1000000.0, 'kC': 1000.0, 'dC': 0.1, 'cC': 0.01, 'mC': 0.001, 'uC': 1e-06, 'nC': 1e-09, 'pC': 1e-12, 'fC': 1e-15, 'Celcius': 1, 'Celciuss': 1, 'petaCelcius': 1000000000000000.0, 'teraCelcius': 1000000000000.0, 'gigaCelcius': 1000000000.0, 'megaCelcius': 1000000.0, 'kiloCelcius': 1000.0, 'deciCelcius': 0.1, 'centiCelcius': 0.01, 'milliCelcius': 0.001, 'miliCelcius': 0.001, 'microCelcius': 1e-06, 'nanoCelcius': 1e-09, 'picoCelcius': 1e-12, 'femtoCelcius': 1e-15, 'peta*Celcius': 1000000000000000.0, 'tera*Celcius': 1000000000000.0, 'giga*Celcius': 1000000000.0, 'mega*Celcius': 1000000.0, 'kilo*Celcius': 1000.0, 'deci*Celcius': 0.1, 'centi*Celcius': 0.01, 'milli*Celcius': 0.001, 'mili*Celcius': 0.001, 'micro*Celcius': 1e-06, 'nano*Celcius': 1e-09, 'pico*Celcius': 1e-12, 'femto*Celcius': 1e-15, 'petaCelciuss': 1000000000000000.0, 'teraCelciuss': 1000000000000.0, 'gigaCelciuss': 1000000000.0, 'megaCelciuss': 1000000.0, 'kiloCelciuss': 1000.0, 'deciCelciuss': 0.1, 'centiCelciuss': 0.01, 'milliCelciuss': 0.001, 'miliCelciuss': 0.001, 'microCelciuss': 1e-06, 'nanoCelciuss': 1e-09, 'picoCelciuss': 1e-12, 'femtoCelciuss': 1e-15, 'celcius': 1, 'celciuss': 1, 'petacelcius': 1000000000000000.0, 'teracelcius': 1000000000000.0, 'gigacelcius': 1000000000.0, 'megacelcius': 1000000.0, 'kilocelcius': 1000.0, 'decicelcius': 0.1, 'centicelcius': 0.01, 'millicelcius': 0.001, 'milicelcius': 0.001, 'microcelcius': 1e-06, 'nanocelcius': 1e-09, 'picocelcius': 1e-12, 'femtocelcius': 1e-15, 'peta*celcius': 1000000000000000.0, 'tera*celcius': 1000000000000.0, 'giga*celcius': 1000000000.0, 'mega*celcius': 1000000.0, 'kilo*celcius': 1000.0, 'deci*celcius': 0.1, 'centi*celcius': 0.01, 'milli*celcius': 0.001, 'mili*celcius': 0.001, 'micro*celcius': 1e-06, 'nano*celcius': 1e-09, 'pico*celcius': 1e-12, 'femto*celcius': 1e-15, 'petacelciuss': 1000000000000000.0, 'teracelciuss': 1000000000000.0, 'gigacelciuss': 1000000000.0, 'megacelciuss': 1000000.0, 'kilocelciuss': 1000.0, 'decicelciuss': 0.1, 'centicelciuss': 0.01, 'millicelciuss': 0.001, 'milicelciuss': 0.001, 'microcelciuss': 1e-06, 'nanocelciuss': 1e-09, 'picocelciuss': 1e-12, 'femtocelciuss': 1e-15}, {'C': 1, 'PC': 1000000000000000.0, 'TC': 1000000000000.0, 'GC': 1000000000.0, 'MC': 1000000.0, 'kC': 1000.0, 'dC': 0.1, 'cC': 0.01, 'mC': 0.001, 'uC': 1e-06, 'nC': 1e-09, 'pC': 1e-12, 'fC': 1e-15, 'coulomb': 1, 'coulombs': 1, 'petacoulomb': 1000000000000000.0, 'teracoulomb': 1000000000000.0, 'gigacoulomb': 1000000000.0, 'megacoulomb': 1000000.0, 'kilocoulomb': 1000.0, 'decicoulomb': 0.1, 'centicoulomb': 0.01, 'millicoulomb': 0.001, 'milicoulomb': 0.001, 'microcoulomb': 1e-06, 'nanocoulomb': 1e-09, 'picocoulomb': 1e-12, 'femtocoulomb': 1e-15, 'peta*coulomb': 1000000000000000.0, 'tera*coulomb': 1000000000000.0, 'giga*coulomb': 1000000000.0, 'mega*coulomb': 1000000.0, 'kilo*coulomb': 1000.0, 'deci*coulomb': 0.1, 'centi*coulomb': 0.01, 'milli*coulomb': 0.001, 'mili*coulomb': 0.001, 'micro*coulomb': 1e-06, 'nano*coulomb': 1e-09, 'pico*coulomb': 1e-12, 'femto*coulomb': 1e-15, 'petacoulombs': 1000000000000000.0, 'teracoulombs': 1000000000000.0, 'gigacoulombs': 1000000000.0, 'megacoulombs': 1000000.0, 'kilocoulombs': 1000.0, 'decicoulombs': 0.1, 'centicoulombs': 0.01, 'millicoulombs': 0.001, 'milicoulombs': 0.001, 'microcoulombs': 1e-06, 'nanocoulombs': 1e-09, 'picocoulombs': 1e-12, 'femtocoulombs': 1e-15, 'Coulomb': 1, 'Coulombs': 1, 'petaCoulomb': 1000000000000000.0, 'teraCoulomb': 1000000000000.0, 'gigaCoulomb': 1000000000.0, 'megaCoulomb': 1000000.0, 'kiloCoulomb': 1000.0, 'deciCoulomb': 0.1, 'centiCoulomb': 0.01, 'milliCoulomb': 0.001, 'miliCoulomb': 0.001, 'microCoulomb': 1e-06, 'nanoCoulomb': 1e-09, 'picoCoulomb': 1e-12, 'femtoCoulomb': 1e-15, 'peta*Coulomb': 1000000000000000.0, 'tera*Coulomb': 1000000000000.0, 'giga*Coulomb': 1000000000.0, 'mega*Coulomb': 1000000.0, 'kilo*Coulomb': 1000.0, 'deci*Coulomb': 0.1, 'centi*Coulomb': 0.01, 'milli*Coulomb': 0.001, 'mili*Coulomb': 0.001, 'micro*Coulomb': 1e-06, 'nano*Coulomb': 1e-09, 'pico*Coulomb': 1e-12, 'femto*Coulomb': 1e-15, 'petaCoulombs': 1000000000000000.0, 'teraCoulombs': 1000000000000.0, 'gigaCoulombs': 1000000000.0, 'megaCoulombs': 1000000.0, 'kiloCoulombs': 1000.0, 'deciCoulombs': 0.1, 'centiCoulombs': 0.01, 'milliCoulombs': 0.001, 'miliCoulombs': 0.001, 'microCoulombs': 1e-06, 'nanoCoulombs': 1e-09, 'picoCoulombs': 1e-12, 'femtoCoulombs': 1e-15, 'microAmp*hour': 0.0036}, {'10^-6 Angstrom^-2': 1e-06, 'Angstrom^-2': 1, '10-6 Angstrom-2': 1e-06, 'Angstrom-2': 1}, {'invA': 1, 'invAng': 1, 'invAngstroms': 1, '1/A': 1, '1/Angstrom': 1, '1/angstrom': 1, 'A^{-1}': 1, 'cm^{-1}': 1e-08, '10^-3 Angstrom^-1': 0.001, '1/cm': 1e-08, '1/m': 1e-10, 'nm^{-1}': 1, 'nm^-1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1, 'A{-1}': 1, 'cm{-1}': 1e-08, '10-3 Angstrom-1': 0.001, 'nm{-1}': 1, 'nm-1': 0.1, 'n_m-1': 0.1}], 'unknown': {None: 1, '???': 1, '': 1, 'a.u.': 1, 'Counts': 1, 'counts': 1, 'arbitrary': 1, 'arbitrary units': 1}, '__init__': <function Converter.__init__>, 'scale': <function Converter.scale>, '__call__': <function Converter.__call__>, '__dict__': <attribute '__dict__' of 'Converter' objects>, '__weakref__': <attribute '__weakref__' of 'Converter' objects>, '__annotations__': {}})
__doc__ = '\n    Unit converter for NeXus style units.\n    '
__init__(name)[source]
__module__ = 'sas.sascalc.data_util.nxsunit'
__weakref__

list of weak references to the object (if defined)

dims = [{'m': 1, 'Pm': 1000000000000000.0, 'Tm': 1000000000000.0, 'Gm': 1000000000.0, 'Mm': 1000000.0, 'km': 1000.0, 'dm': 0.1, 'cm': 0.01, 'mm': 0.001, 'um': 1e-06, 'nm': 1e-09, 'pm': 1e-12, 'fm': 1e-15, 'meter': 1, 'meters': 1, 'petameter': 1000000000000000.0, 'terameter': 1000000000000.0, 'gigameter': 1000000000.0, 'megameter': 1000000.0, 'kilometer': 1000.0, 'decimeter': 0.1, 'centimeter': 0.01, 'millimeter': 0.001, 'milimeter': 0.001, 'micrometer': 1e-06, 'nanometer': 1e-09, 'picometer': 1e-12, 'femtometer': 1e-15, 'peta*meter': 1000000000000000.0, 'tera*meter': 1000000000000.0, 'giga*meter': 1000000000.0, 'mega*meter': 1000000.0, 'kilo*meter': 1000.0, 'deci*meter': 0.1, 'centi*meter': 0.01, 'milli*meter': 0.001, 'mili*meter': 0.001, 'micro*meter': 1e-06, 'nano*meter': 1e-09, 'pico*meter': 1e-12, 'femto*meter': 1e-15, 'petameters': 1000000000000000.0, 'terameters': 1000000000000.0, 'gigameters': 1000000000.0, 'megameters': 1000000.0, 'kilometers': 1000.0, 'decimeters': 0.1, 'centimeters': 0.01, 'millimeters': 0.001, 'milimeters': 0.001, 'micrometers': 1e-06, 'nanometers': 1e-09, 'picometers': 1e-12, 'femtometers': 1e-15, 'Meter': 1, 'Meters': 1, 'petaMeter': 1000000000000000.0, 'teraMeter': 1000000000000.0, 'gigaMeter': 1000000000.0, 'megaMeter': 1000000.0, 'kiloMeter': 1000.0, 'deciMeter': 0.1, 'centiMeter': 0.01, 'milliMeter': 0.001, 'miliMeter': 0.001, 'microMeter': 1e-06, 'nanoMeter': 1e-09, 'picoMeter': 1e-12, 'femtoMeter': 1e-15, 'peta*Meter': 1000000000000000.0, 'tera*Meter': 1000000000000.0, 'giga*Meter': 1000000000.0, 'mega*Meter': 1000000.0, 'kilo*Meter': 1000.0, 'deci*Meter': 0.1, 'centi*Meter': 0.01, 'milli*Meter': 0.001, 'mili*Meter': 0.001, 'micro*Meter': 1e-06, 'nano*Meter': 1e-09, 'pico*Meter': 1e-12, 'femto*Meter': 1e-15, 'petaMeters': 1000000000000000.0, 'teraMeters': 1000000000000.0, 'gigaMeters': 1000000000.0, 'megaMeters': 1000000.0, 'kiloMeters': 1000.0, 'deciMeters': 0.1, 'centiMeters': 0.01, 'milliMeters': 0.001, 'miliMeters': 0.001, 'microMeters': 1e-06, 'nanoMeters': 1e-09, 'picoMeters': 1e-12, 'femtoMeters': 1e-15, 'metre': 1, 'metres': 1, 'petametre': 1000000000000000.0, 'terametre': 1000000000000.0, 'gigametre': 1000000000.0, 'megametre': 1000000.0, 'kilometre': 1000.0, 'decimetre': 0.1, 'centimetre': 0.01, 'millimetre': 0.001, 'milimetre': 0.001, 'micrometre': 1e-06, 'nanometre': 1e-09, 'picometre': 1e-12, 'femtometre': 1e-15, 'peta*metre': 1000000000000000.0, 'tera*metre': 1000000000000.0, 'giga*metre': 1000000000.0, 'mega*metre': 1000000.0, 'kilo*metre': 1000.0, 'deci*metre': 0.1, 'centi*metre': 0.01, 'milli*metre': 0.001, 'mili*metre': 0.001, 'micro*metre': 1e-06, 'nano*metre': 1e-09, 'pico*metre': 1e-12, 'femto*metre': 1e-15, 'petametres': 1000000000000000.0, 'terametres': 1000000000000.0, 'gigametres': 1000000000.0, 'megametres': 1000000.0, 'kilometres': 1000.0, 'decimetres': 0.1, 'centimetres': 0.01, 'millimetres': 0.001, 'milimetres': 0.001, 'micrometres': 1e-06, 'nanometres': 1e-09, 'picometres': 1e-12, 'femtometres': 1e-15, 'Metre': 1, 'Metres': 1, 'petaMetre': 1000000000000000.0, 'teraMetre': 1000000000000.0, 'gigaMetre': 1000000000.0, 'megaMetre': 1000000.0, 'kiloMetre': 1000.0, 'deciMetre': 0.1, 'centiMetre': 0.01, 'milliMetre': 0.001, 'miliMetre': 0.001, 'microMetre': 1e-06, 'nanoMetre': 1e-09, 'picoMetre': 1e-12, 'femtoMetre': 1e-15, 'peta*Metre': 1000000000000000.0, 'tera*Metre': 1000000000000.0, 'giga*Metre': 1000000000.0, 'mega*Metre': 1000000.0, 'kilo*Metre': 1000.0, 'deci*Metre': 0.1, 'centi*Metre': 0.01, 'milli*Metre': 0.001, 'mili*Metre': 0.001, 'micro*Metre': 1e-06, 'nano*Metre': 1e-09, 'pico*Metre': 1e-12, 'femto*Metre': 1e-15, 'petaMetres': 1000000000000000.0, 'teraMetres': 1000000000000.0, 'gigaMetres': 1000000000.0, 'megaMetres': 1000000.0, 'kiloMetres': 1000.0, 'deciMetres': 0.1, 'centiMetres': 0.01, 'milliMetres': 0.001, 'miliMetres': 0.001, 'microMetres': 1e-06, 'nanoMetres': 1e-09, 'picoMetres': 1e-12, 'femtoMetres': 1e-15, 'micron': 1e-06, 'Angstrom': 1e-10, 'microns': 1e-06, 'Angstroms': 1e-10, 'A': 1e-10, 'Ang': 1e-10}, {'s': 1, 'Ps': 1000000000000000.0, 'Ts': 1000000000000.0, 'Gs': 1000000000.0, 'Ms': 1000000.0, 'ks': 1000.0, 'ds': 0.1, 'cs': 0.01, 'ms': 0.001, 'us': 1e-06, 'ns': 1e-09, 'ps': 1e-12, 'fs': 1e-15, 'second': 1, 'seconds': 1, 'petasecond': 1000000000000000.0, 'terasecond': 1000000000000.0, 'gigasecond': 1000000000.0, 'megasecond': 1000000.0, 'kilosecond': 1000.0, 'decisecond': 0.1, 'centisecond': 0.01, 'millisecond': 0.001, 'milisecond': 0.001, 'microsecond': 1e-06, 'nanosecond': 1e-09, 'picosecond': 1e-12, 'femtosecond': 1e-15, 'peta*second': 1000000000000000.0, 'tera*second': 1000000000000.0, 'giga*second': 1000000000.0, 'mega*second': 1000000.0, 'kilo*second': 1000.0, 'deci*second': 0.1, 'centi*second': 0.01, 'milli*second': 0.001, 'mili*second': 0.001, 'micro*second': 1e-06, 'nano*second': 1e-09, 'pico*second': 1e-12, 'femto*second': 1e-15, 'petaseconds': 1000000000000000.0, 'teraseconds': 1000000000000.0, 'gigaseconds': 1000000000.0, 'megaseconds': 1000000.0, 'kiloseconds': 1000.0, 'deciseconds': 0.1, 'centiseconds': 0.01, 'milliseconds': 0.001, 'miliseconds': 0.001, 'microseconds': 1e-06, 'nanoseconds': 1e-09, 'picoseconds': 1e-12, 'femtoseconds': 1e-15, 'Second': 1, 'Seconds': 1, 'petaSecond': 1000000000000000.0, 'teraSecond': 1000000000000.0, 'gigaSecond': 1000000000.0, 'megaSecond': 1000000.0, 'kiloSecond': 1000.0, 'deciSecond': 0.1, 'centiSecond': 0.01, 'milliSecond': 0.001, 'miliSecond': 0.001, 'microSecond': 1e-06, 'nanoSecond': 1e-09, 'picoSecond': 1e-12, 'femtoSecond': 1e-15, 'peta*Second': 1000000000000000.0, 'tera*Second': 1000000000000.0, 'giga*Second': 1000000000.0, 'mega*Second': 1000000.0, 'kilo*Second': 1000.0, 'deci*Second': 0.1, 'centi*Second': 0.01, 'milli*Second': 0.001, 'mili*Second': 0.001, 'micro*Second': 1e-06, 'nano*Second': 1e-09, 'pico*Second': 1e-12, 'femto*Second': 1e-15, 'petaSeconds': 1000000000000000.0, 'teraSeconds': 1000000000000.0, 'gigaSeconds': 1000000000.0, 'megaSeconds': 1000000.0, 'kiloSeconds': 1000.0, 'deciSeconds': 0.1, 'centiSeconds': 0.01, 'milliSeconds': 0.001, 'miliSeconds': 0.001, 'microSeconds': 1e-06, 'nanoSeconds': 1e-09, 'picoSeconds': 1e-12, 'femtoSeconds': 1e-15, 'hour': 3600, 'day': 86400, 'week': 604800, 'hours': 3600, 'days': 86400, 'weeks': 604800}, {'degree': 1, 'minute': 0.016666666666666666, 'arcminute': 0.016666666666666666, 'arcsecond': 0.0002777777777777778, 'radian': 57.29577951308232, 'degrees': 1, 'minutes': 0.016666666666666666, 'arcminutes': 0.016666666666666666, 'arcseconds': 0.0002777777777777778, 'radians': 57.29577951308232, 'deg': 1, 'arcmin': 0.016666666666666666, 'arcsec': 0.0002777777777777778, 'rad': 57.29577951308232}, {'Hz': 1, 'PHz': 1000000000000000.0, 'THz': 1000000000000.0, 'GHz': 1000000000.0, 'MHz': 1000000.0, 'kHz': 1000.0, 'dHz': 0.1, 'cHz': 0.01, 'mHz': 0.001, 'uHz': 1e-06, 'nHz': 1e-09, 'pHz': 1e-12, 'fHz': 1e-15, 'hertz': 1, 'hertzs': 1, 'petahertz': 1000000000000000.0, 'terahertz': 1000000000000.0, 'gigahertz': 1000000000.0, 'megahertz': 1000000.0, 'kilohertz': 1000.0, 'decihertz': 0.1, 'centihertz': 0.01, 'millihertz': 0.001, 'milihertz': 0.001, 'microhertz': 1e-06, 'nanohertz': 1e-09, 'picohertz': 1e-12, 'femtohertz': 1e-15, 'peta*hertz': 1000000000000000.0, 'tera*hertz': 1000000000000.0, 'giga*hertz': 1000000000.0, 'mega*hertz': 1000000.0, 'kilo*hertz': 1000.0, 'deci*hertz': 0.1, 'centi*hertz': 0.01, 'milli*hertz': 0.001, 'mili*hertz': 0.001, 'micro*hertz': 1e-06, 'nano*hertz': 1e-09, 'pico*hertz': 1e-12, 'femto*hertz': 1e-15, 'petahertzs': 1000000000000000.0, 'terahertzs': 1000000000000.0, 'gigahertzs': 1000000000.0, 'megahertzs': 1000000.0, 'kilohertzs': 1000.0, 'decihertzs': 0.1, 'centihertzs': 0.01, 'millihertzs': 0.001, 'milihertzs': 0.001, 'microhertzs': 1e-06, 'nanohertzs': 1e-09, 'picohertzs': 1e-12, 'femtohertzs': 1e-15, 'Hertz': 1, 'Hertzs': 1, 'petaHertz': 1000000000000000.0, 'teraHertz': 1000000000000.0, 'gigaHertz': 1000000000.0, 'megaHertz': 1000000.0, 'kiloHertz': 1000.0, 'deciHertz': 0.1, 'centiHertz': 0.01, 'milliHertz': 0.001, 'miliHertz': 0.001, 'microHertz': 1e-06, 'nanoHertz': 1e-09, 'picoHertz': 1e-12, 'femtoHertz': 1e-15, 'peta*Hertz': 1000000000000000.0, 'tera*Hertz': 1000000000000.0, 'giga*Hertz': 1000000000.0, 'mega*Hertz': 1000000.0, 'kilo*Hertz': 1000.0, 'deci*Hertz': 0.1, 'centi*Hertz': 0.01, 'milli*Hertz': 0.001, 'mili*Hertz': 0.001, 'micro*Hertz': 1e-06, 'nano*Hertz': 1e-09, 'pico*Hertz': 1e-12, 'femto*Hertz': 1e-15, 'petaHertzs': 1000000000000000.0, 'teraHertzs': 1000000000000.0, 'gigaHertzs': 1000000000.0, 'megaHertzs': 1000000.0, 'kiloHertzs': 1000.0, 'deciHertzs': 0.1, 'centiHertzs': 0.01, 'milliHertzs': 0.001, 'miliHertzs': 0.001, 'microHertzs': 1e-06, 'nanoHertzs': 1e-09, 'picoHertzs': 1e-12, 'femtoHertzs': 1e-15, 'rpm': 0.016666666666666666, 'rpms': 0.016666666666666666}, {'K': 1, 'PK': 1000000000000000.0, 'TK': 1000000000000.0, 'GK': 1000000000.0, 'MK': 1000000.0, 'kK': 1000.0, 'dK': 0.1, 'cK': 0.01, 'mK': 0.001, 'uK': 1e-06, 'nK': 1e-09, 'pK': 1e-12, 'fK': 1e-15, 'kelvin': 1, 'kelvins': 1, 'petakelvin': 1000000000000000.0, 'terakelvin': 1000000000000.0, 'gigakelvin': 1000000000.0, 'megakelvin': 1000000.0, 'kilokelvin': 1000.0, 'decikelvin': 0.1, 'centikelvin': 0.01, 'millikelvin': 0.001, 'milikelvin': 0.001, 'microkelvin': 1e-06, 'nanokelvin': 1e-09, 'picokelvin': 1e-12, 'femtokelvin': 1e-15, 'peta*kelvin': 1000000000000000.0, 'tera*kelvin': 1000000000000.0, 'giga*kelvin': 1000000000.0, 'mega*kelvin': 1000000.0, 'kilo*kelvin': 1000.0, 'deci*kelvin': 0.1, 'centi*kelvin': 0.01, 'milli*kelvin': 0.001, 'mili*kelvin': 0.001, 'micro*kelvin': 1e-06, 'nano*kelvin': 1e-09, 'pico*kelvin': 1e-12, 'femto*kelvin': 1e-15, 'petakelvins': 1000000000000000.0, 'terakelvins': 1000000000000.0, 'gigakelvins': 1000000000.0, 'megakelvins': 1000000.0, 'kilokelvins': 1000.0, 'decikelvins': 0.1, 'centikelvins': 0.01, 'millikelvins': 0.001, 'milikelvins': 0.001, 'microkelvins': 1e-06, 'nanokelvins': 1e-09, 'picokelvins': 1e-12, 'femtokelvins': 1e-15, 'Kelvin': 1, 'Kelvins': 1, 'petaKelvin': 1000000000000000.0, 'teraKelvin': 1000000000000.0, 'gigaKelvin': 1000000000.0, 'megaKelvin': 1000000.0, 'kiloKelvin': 1000.0, 'deciKelvin': 0.1, 'centiKelvin': 0.01, 'milliKelvin': 0.001, 'miliKelvin': 0.001, 'microKelvin': 1e-06, 'nanoKelvin': 1e-09, 'picoKelvin': 1e-12, 'femtoKelvin': 1e-15, 'peta*Kelvin': 1000000000000000.0, 'tera*Kelvin': 1000000000000.0, 'giga*Kelvin': 1000000000.0, 'mega*Kelvin': 1000000.0, 'kilo*Kelvin': 1000.0, 'deci*Kelvin': 0.1, 'centi*Kelvin': 0.01, 'milli*Kelvin': 0.001, 'mili*Kelvin': 0.001, 'micro*Kelvin': 1e-06, 'nano*Kelvin': 1e-09, 'pico*Kelvin': 1e-12, 'femto*Kelvin': 1e-15, 'petaKelvins': 1000000000000000.0, 'teraKelvins': 1000000000000.0, 'gigaKelvins': 1000000000.0, 'megaKelvins': 1000000.0, 'kiloKelvins': 1000.0, 'deciKelvins': 0.1, 'centiKelvins': 0.01, 'milliKelvins': 0.001, 'miliKelvins': 0.001, 'microKelvins': 1e-06, 'nanoKelvins': 1e-09, 'picoKelvins': 1e-12, 'femtoKelvins': 1e-15, 'C': 1, 'PC': 1000000000000000.0, 'TC': 1000000000000.0, 'GC': 1000000000.0, 'MC': 1000000.0, 'kC': 1000.0, 'dC': 0.1, 'cC': 0.01, 'mC': 0.001, 'uC': 1e-06, 'nC': 1e-09, 'pC': 1e-12, 'fC': 1e-15, 'Celcius': 1, 'Celciuss': 1, 'petaCelcius': 1000000000000000.0, 'teraCelcius': 1000000000000.0, 'gigaCelcius': 1000000000.0, 'megaCelcius': 1000000.0, 'kiloCelcius': 1000.0, 'deciCelcius': 0.1, 'centiCelcius': 0.01, 'milliCelcius': 0.001, 'miliCelcius': 0.001, 'microCelcius': 1e-06, 'nanoCelcius': 1e-09, 'picoCelcius': 1e-12, 'femtoCelcius': 1e-15, 'peta*Celcius': 1000000000000000.0, 'tera*Celcius': 1000000000000.0, 'giga*Celcius': 1000000000.0, 'mega*Celcius': 1000000.0, 'kilo*Celcius': 1000.0, 'deci*Celcius': 0.1, 'centi*Celcius': 0.01, 'milli*Celcius': 0.001, 'mili*Celcius': 0.001, 'micro*Celcius': 1e-06, 'nano*Celcius': 1e-09, 'pico*Celcius': 1e-12, 'femto*Celcius': 1e-15, 'petaCelciuss': 1000000000000000.0, 'teraCelciuss': 1000000000000.0, 'gigaCelciuss': 1000000000.0, 'megaCelciuss': 1000000.0, 'kiloCelciuss': 1000.0, 'deciCelciuss': 0.1, 'centiCelciuss': 0.01, 'milliCelciuss': 0.001, 'miliCelciuss': 0.001, 'microCelciuss': 1e-06, 'nanoCelciuss': 1e-09, 'picoCelciuss': 1e-12, 'femtoCelciuss': 1e-15, 'celcius': 1, 'celciuss': 1, 'petacelcius': 1000000000000000.0, 'teracelcius': 1000000000000.0, 'gigacelcius': 1000000000.0, 'megacelcius': 1000000.0, 'kilocelcius': 1000.0, 'decicelcius': 0.1, 'centicelcius': 0.01, 'millicelcius': 0.001, 'milicelcius': 0.001, 'microcelcius': 1e-06, 'nanocelcius': 1e-09, 'picocelcius': 1e-12, 'femtocelcius': 1e-15, 'peta*celcius': 1000000000000000.0, 'tera*celcius': 1000000000000.0, 'giga*celcius': 1000000000.0, 'mega*celcius': 1000000.0, 'kilo*celcius': 1000.0, 'deci*celcius': 0.1, 'centi*celcius': 0.01, 'milli*celcius': 0.001, 'mili*celcius': 0.001, 'micro*celcius': 1e-06, 'nano*celcius': 1e-09, 'pico*celcius': 1e-12, 'femto*celcius': 1e-15, 'petacelciuss': 1000000000000000.0, 'teracelciuss': 1000000000000.0, 'gigacelciuss': 1000000000.0, 'megacelciuss': 1000000.0, 'kilocelciuss': 1000.0, 'decicelciuss': 0.1, 'centicelciuss': 0.01, 'millicelciuss': 0.001, 'milicelciuss': 0.001, 'microcelciuss': 1e-06, 'nanocelciuss': 1e-09, 'picocelciuss': 1e-12, 'femtocelciuss': 1e-15}, {'C': 1, 'PC': 1000000000000000.0, 'TC': 1000000000000.0, 'GC': 1000000000.0, 'MC': 1000000.0, 'kC': 1000.0, 'dC': 0.1, 'cC': 0.01, 'mC': 0.001, 'uC': 1e-06, 'nC': 1e-09, 'pC': 1e-12, 'fC': 1e-15, 'coulomb': 1, 'coulombs': 1, 'petacoulomb': 1000000000000000.0, 'teracoulomb': 1000000000000.0, 'gigacoulomb': 1000000000.0, 'megacoulomb': 1000000.0, 'kilocoulomb': 1000.0, 'decicoulomb': 0.1, 'centicoulomb': 0.01, 'millicoulomb': 0.001, 'milicoulomb': 0.001, 'microcoulomb': 1e-06, 'nanocoulomb': 1e-09, 'picocoulomb': 1e-12, 'femtocoulomb': 1e-15, 'peta*coulomb': 1000000000000000.0, 'tera*coulomb': 1000000000000.0, 'giga*coulomb': 1000000000.0, 'mega*coulomb': 1000000.0, 'kilo*coulomb': 1000.0, 'deci*coulomb': 0.1, 'centi*coulomb': 0.01, 'milli*coulomb': 0.001, 'mili*coulomb': 0.001, 'micro*coulomb': 1e-06, 'nano*coulomb': 1e-09, 'pico*coulomb': 1e-12, 'femto*coulomb': 1e-15, 'petacoulombs': 1000000000000000.0, 'teracoulombs': 1000000000000.0, 'gigacoulombs': 1000000000.0, 'megacoulombs': 1000000.0, 'kilocoulombs': 1000.0, 'decicoulombs': 0.1, 'centicoulombs': 0.01, 'millicoulombs': 0.001, 'milicoulombs': 0.001, 'microcoulombs': 1e-06, 'nanocoulombs': 1e-09, 'picocoulombs': 1e-12, 'femtocoulombs': 1e-15, 'Coulomb': 1, 'Coulombs': 1, 'petaCoulomb': 1000000000000000.0, 'teraCoulomb': 1000000000000.0, 'gigaCoulomb': 1000000000.0, 'megaCoulomb': 1000000.0, 'kiloCoulomb': 1000.0, 'deciCoulomb': 0.1, 'centiCoulomb': 0.01, 'milliCoulomb': 0.001, 'miliCoulomb': 0.001, 'microCoulomb': 1e-06, 'nanoCoulomb': 1e-09, 'picoCoulomb': 1e-12, 'femtoCoulomb': 1e-15, 'peta*Coulomb': 1000000000000000.0, 'tera*Coulomb': 1000000000000.0, 'giga*Coulomb': 1000000000.0, 'mega*Coulomb': 1000000.0, 'kilo*Coulomb': 1000.0, 'deci*Coulomb': 0.1, 'centi*Coulomb': 0.01, 'milli*Coulomb': 0.001, 'mili*Coulomb': 0.001, 'micro*Coulomb': 1e-06, 'nano*Coulomb': 1e-09, 'pico*Coulomb': 1e-12, 'femto*Coulomb': 1e-15, 'petaCoulombs': 1000000000000000.0, 'teraCoulombs': 1000000000000.0, 'gigaCoulombs': 1000000000.0, 'megaCoulombs': 1000000.0, 'kiloCoulombs': 1000.0, 'deciCoulombs': 0.1, 'centiCoulombs': 0.01, 'milliCoulombs': 0.001, 'miliCoulombs': 0.001, 'microCoulombs': 1e-06, 'nanoCoulombs': 1e-09, 'picoCoulombs': 1e-12, 'femtoCoulombs': 1e-15, 'microAmp*hour': 0.0036}, {'10^-6 Angstrom^-2': 1e-06, 'Angstrom^-2': 1, '10-6 Angstrom-2': 1e-06, 'Angstrom-2': 1}, {'invA': 1, 'invAng': 1, 'invAngstroms': 1, '1/A': 1, '1/Angstrom': 1, '1/angstrom': 1, 'A^{-1}': 1, 'cm^{-1}': 1e-08, '10^-3 Angstrom^-1': 0.001, '1/cm': 1e-08, '1/m': 1e-10, 'nm^{-1}': 1, 'nm^-1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1, 'A{-1}': 1, 'cm{-1}': 1e-08, '10-3 Angstrom-1': 0.001, 'nm{-1}': 1, 'nm-1': 0.1, 'n_m-1': 0.1}]
scale(units='')[source]
scalebase = 1
scalemap = None
unknown = {None: 1, '???': 1, '': 1, 'a.u.': 1, 'Counts': 1, 'counts': 1, 'arbitrary': 1, 'arbitrary units': 1}
sas.sascalc.data_util.nxsunit._build_all_units()[source]
sas.sascalc.data_util.nxsunit._build_metric_units(unit, abbr)[source]

Construct standard SI names for the given unit. Builds e.g.,

s, ns second, nanosecond, nano*second seconds, nanoseconds

Includes prefixes for femto through peta.

Ack! Allows, e.g., Coulomb and coulomb even though Coulomb is not a unit because some NeXus files store it that way!

Returns a dictionary of names and scales.

sas.sascalc.data_util.nxsunit._build_plural_units(**kw)[source]

Construct names for the given units. Builds singular and plural form.

sas.sascalc.data_util.nxsunit._caret_optional(s)[source]

Strip ‘^’ from unit names.

  • WARNING * this will incorrectly transform 10^3 to 103.

sas.sascalc.data_util.nxsunit._check(expect, get)[source]
sas.sascalc.data_util.nxsunit.test()[source]

sas.sascalc.data_util.odict module

A dict that keeps keys in insertion order

class sas.sascalc.data_util.odict.Items(main)[source]

Bases: object

Custom object for accessing the items of an OrderedDict.

Can be called like the normal OrderedDict.items method, but also supports indexing and sequence methods.

__add__(other)[source]
__call__()[source]

Pretend to be the items method.

__cmp__(other)[source]
__contains__(item)[source]
__delitem__(i)[source]

Delete the item at position i.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.odict', '__doc__': '\n    Custom object for accessing the items of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.items`` method, but also\n    supports indexing and sequence methods.\n    ', '__init__': <function Items.__init__>, '__call__': <function Items.__call__>, '__getitem__': <function Items.__getitem__>, '__setitem__': <function Items.__setitem__>, '__delitem__': <function Items.__delitem__>, '__repr__': <function Items.__repr__>, '__lt__': <function Items.__lt__>, '__le__': <function Items.__le__>, '__eq__': <function Items.__eq__>, '__ne__': <function Items.__ne__>, '__gt__': <function Items.__gt__>, '__ge__': <function Items.__ge__>, '__cmp__': <function Items.__cmp__>, '__contains__': <function Items.__contains__>, '__len__': <function Items.__len__>, '__iter__': <function Items.__iter__>, 'count': <function Items.count>, 'index': <function Items.index>, 'reverse': <function Items.reverse>, 'sort': <function Items.sort>, '__mul__': <function Items.__mul__>, '__rmul__': <function Items.__mul__>, '__add__': <function Items.__add__>, '__radd__': <function Items.__radd__>, 'append': <function Items.append>, 'insert': <function Items.insert>, 'pop': <function Items.pop>, 'remove': <function Items.remove>, 'extend': <function Items.extend>, '__iadd__': <function Items.__iadd__>, '__imul__': <function Items.__imul__>, '__dict__': <attribute '__dict__' of 'Items' objects>, '__weakref__': <attribute '__weakref__' of 'Items' objects>, '__hash__': None, '__annotations__': {}})
__doc__ = '\n    Custom object for accessing the items of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.items`` method, but also\n    supports indexing and sequence methods.\n    '
__eq__(other)[source]

Return self==value.

__ge__(other)[source]

Return self>=value.

__getitem__(index)[source]

Fetch the item at position i.

__gt__(other)[source]

Return self>value.

__hash__ = None
__iadd__(other)[source]
__imul__(n)[source]
__init__(main)[source]
__iter__()[source]
__le__(other)[source]

Return self<=value.

__len__()[source]
__lt__(other)[source]

Return self<value.

__module__ = 'sas.sascalc.data_util.odict'
__mul__(n)[source]
__ne__(other)[source]

Return self!=value.

__radd__(other)[source]
__repr__()[source]

Return repr(self).

__rmul__(n)
__setitem__(index, item)[source]

Set item at position i to item.

__weakref__

list of weak references to the object (if defined)

append(item)[source]

Add an item to the end.

count(item)[source]
extend(other)[source]
index(item, *args)[source]
insert(i, item)[source]
pop(i=-1)[source]
remove(item)[source]
reverse()[source]
sort(*args, **kwds)[source]
class sas.sascalc.data_util.odict.Keys(main)[source]

Bases: object

Custom object for accessing the keys of an OrderedDict.

Can be called like the normal OrderedDict.keys method, but also supports indexing and sequence methods.

__add__(other)[source]
__call__()[source]

Pretend to be the keys method.

__cmp__(other)[source]
__contains__(item)[source]
__delitem__(i)[source]
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.odict', '__doc__': '\n    Custom object for accessing the keys of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.keys`` method, but also\n    supports indexing and sequence methods.\n    ', '__init__': <function Keys.__init__>, '__call__': <function Keys.__call__>, '__getitem__': <function Keys.__getitem__>, '__setitem__': <function Keys.__setitem__>, '__repr__': <function Keys.__repr__>, '__lt__': <function Keys.__lt__>, '__le__': <function Keys.__le__>, '__eq__': <function Keys.__eq__>, '__ne__': <function Keys.__ne__>, '__gt__': <function Keys.__gt__>, '__ge__': <function Keys.__ge__>, '__cmp__': <function Keys.__cmp__>, '__contains__': <function Keys.__contains__>, '__len__': <function Keys.__len__>, '__iter__': <function Keys.__iter__>, 'count': <function Keys.count>, 'index': <function Keys.index>, 'reverse': <function Keys.reverse>, 'sort': <function Keys.sort>, '__mul__': <function Keys.__mul__>, '__rmul__': <function Keys.__mul__>, '__add__': <function Keys.__add__>, '__radd__': <function Keys.__radd__>, '__delitem__': <function Keys.__delitem__>, '__iadd__': <function Keys.__iadd__>, '__imul__': <function Keys.__imul__>, 'append': <function Keys.append>, 'insert': <function Keys.insert>, 'pop': <function Keys.pop>, 'remove': <function Keys.remove>, 'extend': <function Keys.extend>, '__dict__': <attribute '__dict__' of 'Keys' objects>, '__weakref__': <attribute '__weakref__' of 'Keys' objects>, '__hash__': None, '__annotations__': {}})
__doc__ = '\n    Custom object for accessing the keys of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.keys`` method, but also\n    supports indexing and sequence methods.\n    '
__eq__(other)[source]

Return self==value.

__ge__(other)[source]

Return self>=value.

__getitem__(index)[source]

Fetch the key at position i.

__gt__(other)[source]

Return self>value.

__hash__ = None
__iadd__(other)[source]
__imul__(n)[source]
__init__(main)[source]
__iter__()[source]
__le__(other)[source]

Return self<=value.

__len__()[source]
__lt__(other)[source]

Return self<value.

__module__ = 'sas.sascalc.data_util.odict'
__mul__(n)[source]
__ne__(other)[source]

Return self!=value.

__radd__(other)[source]
__repr__()[source]

Return repr(self).

__rmul__(n)
__setitem__(index, name)[source]

You cannot assign to keys, but you can do slice assignment to re-order them.

You can only do slice assignment if the new set of keys is a reordering of the original set.

__weakref__

list of weak references to the object (if defined)

append(item)[source]
count(item)[source]
extend(other)[source]
index(item, *args)[source]
insert(i, item)[source]
pop(i=-1)[source]
remove(item)[source]
reverse()[source]
sort(*args, **kwds)[source]
class sas.sascalc.data_util.odict.OrderedDict(init_val=(), strict=False)[source]

Bases: dict

A class of dictionary that keeps the insertion order of keys.

All appropriate methods return keys, items, or values in an ordered way.

All normal dictionary methods are available. Update and comparison is restricted to other OrderedDict objects.

Various sequence methods are available, including the ability to explicitly mutate the key ordering.

__contains__ tests:

>>> d = OrderedDict(((1, 3),))
>>> 1 in d
1
>>> 4 in d
0

__getitem__ tests:

>>> OrderedDict(((1, 3), (3, 2), (2, 1)))[2]
1
>>> OrderedDict(((1, 3), (3, 2), (2, 1)))[4]
Traceback (most recent call last):
KeyError: 4

__len__ tests:

>>> len(OrderedDict())
0
>>> len(OrderedDict(((1, 3), (3, 2), (2, 1))))
3

get tests:

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.get(1)
3
>>> d.get(4) is None
1
>>> d.get(4, 5)
5
>>> d
OrderedDict([(1, 3), (3, 2), (2, 1)])

has_key tests:

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.has_key(1)
1
>>> d.has_key(4)
0
__deepcopy__(memo)[source]

To allow deepcopy to work with OrderedDict.

>>> from copy import deepcopy
>>> a = OrderedDict([(1, 1), (2, 2), (3, 3)])
>>> a['test'] = {}
>>> b = deepcopy(a)
>>> b == a
True
>>> b is a
False
>>> a['test'] is b['test']
False
__delitem__(key)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> del d[3]
>>> d
OrderedDict([(1, 3), (2, 1)])
>>> del d[3]
Traceback (most recent call last):
KeyError: 3
>>> d[3] = 2
>>> d
OrderedDict([(1, 3), (2, 1), (3, 2)])
>>> del d[0:1]
>>> d
OrderedDict([(2, 1), (3, 2)])
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.odict', '__doc__': '\n    A class of dictionary that keeps the insertion order of keys.\n\n    All appropriate methods return keys, items, or values in an ordered way.\n\n    All normal dictionary methods are available. Update and comparison is\n    restricted to other OrderedDict objects.\n\n    Various sequence methods are available, including the ability to explicitly\n    mutate the key ordering.\n\n    __contains__ tests:\n\n    >>> d = OrderedDict(((1, 3),))\n    >>> 1 in d\n    1\n    >>> 4 in d\n    0\n\n    __getitem__ tests:\n\n    >>> OrderedDict(((1, 3), (3, 2), (2, 1)))[2]\n    1\n    >>> OrderedDict(((1, 3), (3, 2), (2, 1)))[4]\n    Traceback (most recent call last):\n    KeyError: 4\n\n    __len__ tests:\n\n    >>> len(OrderedDict())\n    0\n    >>> len(OrderedDict(((1, 3), (3, 2), (2, 1))))\n    3\n\n    get tests:\n\n    >>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))\n    >>> d.get(1)\n    3\n    >>> d.get(4) is None\n    1\n    >>> d.get(4, 5)\n    5\n    >>> d\n    OrderedDict([(1, 3), (3, 2), (2, 1)])\n\n    has_key tests:\n\n    >>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))\n    >>> d.has_key(1)\n    1\n    >>> d.has_key(4)\n    0\n    ', '__init__': <function OrderedDict.__init__>, '__delitem__': <function OrderedDict.__delitem__>, '__eq__': <function OrderedDict.__eq__>, '__lt__': <function OrderedDict.__lt__>, '__le__': <function OrderedDict.__le__>, '__ne__': <function OrderedDict.__ne__>, '__gt__': <function OrderedDict.__gt__>, '__ge__': <function OrderedDict.__ge__>, '__repr__': <function OrderedDict.__repr__>, '__setitem__': <function OrderedDict.__setitem__>, '__getitem__': <function OrderedDict.__getitem__>, '__str__': <function OrderedDict.__repr__>, '__setattr__': <function OrderedDict.__setattr__>, '__getattr__': <function OrderedDict.__getattr__>, '__deepcopy__': <function OrderedDict.__deepcopy__>, 'copy': <function OrderedDict.copy>, 'items': <function OrderedDict.items>, 'keys': <function OrderedDict.keys>, 'values': <function OrderedDict.values>, 'iteritems': <function OrderedDict.iteritems>, 'iterkeys': <function OrderedDict.iterkeys>, '__iter__': <function OrderedDict.iterkeys>, 'itervalues': <function OrderedDict.itervalues>, 'clear': <function OrderedDict.clear>, 'pop': <function OrderedDict.pop>, 'popitem': <function OrderedDict.popitem>, 'setdefault': <function OrderedDict.setdefault>, 'update': <function OrderedDict.update>, 'rename': <function OrderedDict.rename>, 'setitems': <function OrderedDict.setitems>, 'setkeys': <function OrderedDict.setkeys>, 'setvalues': <function OrderedDict.setvalues>, 'index': <function OrderedDict.index>, 'insert': <function OrderedDict.insert>, 'reverse': <function OrderedDict.reverse>, 'sort': <function OrderedDict.sort>, '__dict__': <attribute '__dict__' of 'OrderedDict' objects>, '__weakref__': <attribute '__weakref__' of 'OrderedDict' objects>, '__hash__': None, '__annotations__': {}})
__doc__ = '\n    A class of dictionary that keeps the insertion order of keys.\n\n    All appropriate methods return keys, items, or values in an ordered way.\n\n    All normal dictionary methods are available. Update and comparison is\n    restricted to other OrderedDict objects.\n\n    Various sequence methods are available, including the ability to explicitly\n    mutate the key ordering.\n\n    __contains__ tests:\n\n    >>> d = OrderedDict(((1, 3),))\n    >>> 1 in d\n    1\n    >>> 4 in d\n    0\n\n    __getitem__ tests:\n\n    >>> OrderedDict(((1, 3), (3, 2), (2, 1)))[2]\n    1\n    >>> OrderedDict(((1, 3), (3, 2), (2, 1)))[4]\n    Traceback (most recent call last):\n    KeyError: 4\n\n    __len__ tests:\n\n    >>> len(OrderedDict())\n    0\n    >>> len(OrderedDict(((1, 3), (3, 2), (2, 1))))\n    3\n\n    get tests:\n\n    >>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))\n    >>> d.get(1)\n    3\n    >>> d.get(4) is None\n    1\n    >>> d.get(4, 5)\n    5\n    >>> d\n    OrderedDict([(1, 3), (3, 2), (2, 1)])\n\n    has_key tests:\n\n    >>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))\n    >>> d.has_key(1)\n    1\n    >>> d.has_key(4)\n    0\n    '
__eq__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d == OrderedDict(d)
True
>>> d == OrderedDict(((1, 3), (2, 1), (3, 2)))
False
>>> d == OrderedDict(((1, 0), (3, 2), (2, 1)))
False
>>> d == OrderedDict(((0, 3), (3, 2), (2, 1)))
False
>>> d == dict(d)
False
>>> d == False
False
__ge__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> c = OrderedDict(((0, 3), (3, 2), (2, 1)))
>>> e = OrderedDict(d)
>>> c >= d
False
>>> d >= c
True
>>> d >= dict(c)
Traceback (most recent call last):
TypeError: Can only compare with other OrderedDicts
>>> e >= d
True
__getattr__(name)[source]

Implemented so that access to sequence raises a warning.

>>> d = OrderedDict()
>>> d.sequence
[]
__getitem__(key)[source]

Allows slicing. Returns an OrderedDict if you slice. >>> b = OrderedDict([(7, 0), (6, 1), (5, 2), (4, 3), (3, 4), (2, 5), (1, 6)]) >>> b[::-1] OrderedDict([(1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1), (7, 0)]) >>> b[2:5] OrderedDict([(5, 2), (4, 3), (3, 4)]) >>> type(b[2:4]) <class ‘__main__.OrderedDict’>

__gt__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> c = OrderedDict(((0, 3), (3, 2), (2, 1)))
>>> d > c
True
>>> c > d
False
>>> d > dict(c)
Traceback (most recent call last):
TypeError: Can only compare with other OrderedDicts
__hash__ = None
__init__(init_val=(), strict=False)[source]

Create a new ordered dictionary. Cannot init from a normal dict, nor from kwargs, since items order is undefined in those cases.

If the strict keyword argument is True (False is the default) then when doing slice assignment - the OrderedDict you are assigning from must not contain any keys in the remaining dict.

>>> OrderedDict()
OrderedDict([])
>>> OrderedDict({1: 1})
Traceback (most recent call last):
TypeError: undefined order, cannot get items from dict
>>> OrderedDict({1: 1}.items())
OrderedDict([(1, 1)])
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d
OrderedDict([(1, 3), (3, 2), (2, 1)])
>>> OrderedDict(d)
OrderedDict([(1, 3), (3, 2), (2, 1)])
__iter__()
>>> ii = OrderedDict(((1, 3), (3, 2), (2, 1))).iterkeys()
>>> ii.next()
1
>>> ii.next()
3
>>> ii.next()
2
>>> ii.next()
Traceback (most recent call last):
StopIteration
__le__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> c = OrderedDict(((0, 3), (3, 2), (2, 1)))
>>> e = OrderedDict(d)
>>> c <= d
True
>>> d <= c
False
>>> d <= dict(c)
Traceback (most recent call last):
TypeError: Can only compare with other OrderedDicts
>>> d <= e
True
__lt__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> c = OrderedDict(((0, 3), (3, 2), (2, 1)))
>>> c < d
True
>>> d < c
False
>>> d < dict(c)
Traceback (most recent call last):
TypeError: Can only compare with other OrderedDicts
__module__ = 'sas.sascalc.data_util.odict'
__ne__(other)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d != OrderedDict(d)
False
>>> d != OrderedDict(((1, 3), (2, 1), (3, 2)))
True
>>> d != OrderedDict(((1, 0), (3, 2), (2, 1)))
True
>>> d == OrderedDict(((0, 3), (3, 2), (2, 1)))
False
>>> d != dict(d)
True
>>> d != False
True
__repr__()[source]

Used for __repr__ and __str__

>>> r1 = repr(OrderedDict((('a', 'b'), ('c', 'd'), ('e', 'f'))))
>>> r1
"OrderedDict([('a', 'b'), ('c', 'd'), ('e', 'f')])"
>>> r2 = repr(OrderedDict((('a', 'b'), ('e', 'f'), ('c', 'd'))))
>>> r2
"OrderedDict([('a', 'b'), ('e', 'f'), ('c', 'd')])"
>>> r1 == str(OrderedDict((('a', 'b'), ('c', 'd'), ('e', 'f'))))
True
>>> r2 == str(OrderedDict((('a', 'b'), ('e', 'f'), ('c', 'd'))))
True
__setattr__(name, value)[source]

Implemented so that accesses to sequence raise a warning and are diverted to the new setkeys method.

__setitem__(key, val)[source]

Allows slice assignment, so long as the slice is an OrderedDict >>> d = OrderedDict() >>> d[‘a’] = ‘b’ >>> d[‘b’] = ‘a’ >>> d[3] = 12 >>> d OrderedDict([(‘a’, ‘b’), (‘b’, ‘a’), (3, 12)]) >>> d[:] = OrderedDict(((1, 2), (2, 3), (3, 4))) >>> d OrderedDict([(1, 2), (2, 3), (3, 4)]) >>> d[::2] = OrderedDict(((7, 8), (9, 10))) >>> d OrderedDict([(7, 8), (2, 3), (9, 10)]) >>> d = OrderedDict(((0, 1), (1, 2), (2, 3), (3, 4))) >>> d[1:3] = OrderedDict(((1, 2), (5, 6), (7, 8))) >>> d OrderedDict([(0, 1), (1, 2), (5, 6), (7, 8), (3, 4)]) >>> d = OrderedDict(((0, 1), (1, 2), (2, 3), (3, 4)), strict=True) >>> d[1:3] = OrderedDict(((1, 2), (5, 6), (7, 8))) >>> d OrderedDict([(0, 1), (1, 2), (5, 6), (7, 8), (3, 4)])

>>> a = OrderedDict(((0, 1), (1, 2), (2, 3)), strict=True)
>>> a[3] = 4
>>> a
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a[::1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a[:2] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)])
Traceback (most recent call last):
ValueError: slice assignment must be from unique keys
>>> a = OrderedDict(((0, 1), (1, 2), (2, 3)))
>>> a[3] = 4
>>> a
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a[::1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a[:2] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a[::-1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> a
OrderedDict([(3, 4), (2, 3), (1, 2), (0, 1)])
>>> d = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> d[:1] = 3
Traceback (most recent call last):
TypeError: slice assignment requires an OrderedDict
>>> d = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> d[:1] = OrderedDict([(9, 8)])
>>> d
OrderedDict([(9, 8), (1, 2), (2, 3), (3, 4)])
__str__()

Used for __repr__ and __str__

>>> r1 = repr(OrderedDict((('a', 'b'), ('c', 'd'), ('e', 'f'))))
>>> r1
"OrderedDict([('a', 'b'), ('c', 'd'), ('e', 'f')])"
>>> r2 = repr(OrderedDict((('a', 'b'), ('e', 'f'), ('c', 'd'))))
>>> r2
"OrderedDict([('a', 'b'), ('e', 'f'), ('c', 'd')])"
>>> r1 == str(OrderedDict((('a', 'b'), ('c', 'd'), ('e', 'f'))))
True
>>> r2 == str(OrderedDict((('a', 'b'), ('e', 'f'), ('c', 'd'))))
True
__weakref__

list of weak references to the object (if defined)

clear()[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.clear()
>>> d
OrderedDict([])
copy()[source]
>>> OrderedDict(((1, 3), (3, 2), (2, 1))).copy()
OrderedDict([(1, 3), (3, 2), (2, 1)])
index(key)[source]

Return the position of the specified key in the OrderedDict.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.index(3)
1
>>> d.index(4)
Traceback (most recent call last):
ValueError: list.index(x): x not in list
insert(index, key, value)[source]

Takes index, key, and value as arguments.

Sets key to value, so that key is at position index in the OrderedDict.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.insert(0, 4, 0)
>>> d
OrderedDict([(4, 0), (1, 3), (3, 2), (2, 1)])
>>> d.insert(0, 2, 1)
>>> d
OrderedDict([(2, 1), (4, 0), (1, 3), (3, 2)])
>>> d.insert(8, 8, 1)
>>> d
OrderedDict([(2, 1), (4, 0), (1, 3), (3, 2), (8, 1)])
items()[source]

items returns a list of tuples representing all the (key, value) pairs in the dictionary.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.items()
[(1, 3), (3, 2), (2, 1)]
>>> d.clear()
>>> d.items()
[]
iteritems()[source]
>>> ii = OrderedDict(((1, 3), (3, 2), (2, 1))).iteritems()
>>> ii.next()
(1, 3)
>>> ii.next()
(3, 2)
>>> ii.next()
(2, 1)
>>> ii.next()
Traceback (most recent call last):
StopIteration
iterkeys()[source]
>>> ii = OrderedDict(((1, 3), (3, 2), (2, 1))).iterkeys()
>>> ii.next()
1
>>> ii.next()
3
>>> ii.next()
2
>>> ii.next()
Traceback (most recent call last):
StopIteration
itervalues()[source]
>>> iv = OrderedDict(((1, 3), (3, 2), (2, 1))).itervalues()
>>> iv.next()
3
>>> iv.next()
2
>>> iv.next()
1
>>> iv.next()
Traceback (most recent call last):
StopIteration
keys()[source]

Return a list of keys in the OrderedDict.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.keys()
[1, 3, 2]
pop(key, *args)[source]

No dict.pop in Python 2.2, gotta reimplement it

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.pop(3)
2
>>> d
OrderedDict([(1, 3), (2, 1)])
>>> d.pop(4)
Traceback (most recent call last):
KeyError: 4
>>> d.pop(4, 0)
0
>>> d.pop(4, 0, 1)
Traceback (most recent call last):
TypeError: pop expected at most 2 arguments, got 3
popitem(i=-1)[source]

Delete and return an item specified by index, not a random one as in dict. The index is -1 by default (the last item).

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.popitem()
(2, 1)
>>> d
OrderedDict([(1, 3), (3, 2)])
>>> d.popitem(0)
(1, 3)
>>> OrderedDict().popitem()
Traceback (most recent call last):
KeyError: 'popitem(): dictionary is empty'
>>> d.popitem(2)
Traceback (most recent call last):
IndexError: popitem(): index 2 not valid
rename(old_key, new_key)[source]

Rename the key for a given value, without modifying sequence order.

For the case where new_key already exists this raise an exception, since if new_key exists, it is ambiguous as to what happens to the associated values, and the position of new_key in the sequence.

>>> od = OrderedDict()
>>> od['a'] = 1
>>> od['b'] = 2
>>> od.items()
[('a', 1), ('b', 2)]
>>> od.rename('b', 'c')
>>> od.items()
[('a', 1), ('c', 2)]
>>> od.rename('c', 'a')
Traceback (most recent call last):
ValueError: New key already exists: 'a'
>>> od.rename('d', 'b')
Traceback (most recent call last):
KeyError: 'd'
reverse()[source]

Reverse the order of the OrderedDict.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.reverse()
>>> d
OrderedDict([(2, 1), (3, 2), (1, 3)])
setdefault(key, defval=None)[source]
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.setdefault(1)
3
>>> d.setdefault(4) is None
True
>>> d
OrderedDict([(1, 3), (3, 2), (2, 1), (4, None)])
>>> d.setdefault(5, 0)
0
>>> d
OrderedDict([(1, 3), (3, 2), (2, 1), (4, None), (5, 0)])
setitems(items)[source]

This method allows you to set the items in the dict.

It takes a list of tuples - of the same sort returned by the items method.

>>> d = OrderedDict()
>>> d.setitems(((3, 1), (2, 3), (1, 2)))
>>> d
OrderedDict([(3, 1), (2, 3), (1, 2)])
setkeys(keys)[source]

setkeys all ows you to pass in a new list of keys which will replace the current set. This must contain the same set of keys, but need not be in the same order.

If you pass in new keys that don’t match, a KeyError will be raised.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.keys()
[1, 3, 2]
>>> d.setkeys((1, 2, 3))
>>> d
OrderedDict([(1, 3), (2, 1), (3, 2)])
>>> d.setkeys(['a', 'b', 'c'])
Traceback (most recent call last):
KeyError: 'Keylist is not the same as current keylist.'
setvalues(values)[source]

You can pass in a list of values, which will replace the current list. The value list must be the same len as the OrderedDict.

(Or a ValueError is raised.)

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.setvalues((1, 2, 3))
>>> d
OrderedDict([(1, 1), (3, 2), (2, 3)])
>>> d.setvalues([6])
Traceback (most recent call last):
ValueError: Value list is not the same length as the OrderedDict.
sort(*args, **kwargs)[source]

Sort the key order in the OrderedDict.

This method takes the same arguments as the list.sort method on your version of Python.

>>> d = OrderedDict(((4, 1), (2, 2), (3, 3), (1, 4)))
>>> d.sort()
>>> d
OrderedDict([(1, 4), (2, 2), (3, 3), (4, 1)])
update(from_od)[source]

Update from another OrderedDict or sequence of (key, value) pairs

>>> d = OrderedDict(((1, 0), (0, 1)))
>>> d.update(OrderedDict(((1, 3), (3, 2), (2, 1))))
>>> d
OrderedDict([(1, 3), (0, 1), (3, 2), (2, 1)])
>>> d.update({4: 4})
Traceback (most recent call last):
TypeError: undefined order, cannot get items from dict
>>> d.update((4, 4))
Traceback (most recent call last):
TypeError: cannot convert dictionary update sequence element "4" to a 2-item sequence
values(values=None)[source]

Return a list of all the values in the OrderedDict.

Optionally you can pass in a list of values, which will replace the current list. The value list must be the same len as the OrderedDict.

>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d.values()
[3, 2, 1]
class sas.sascalc.data_util.odict.SequenceOrderedDict(init_val=(), strict=True)[source]

Bases: OrderedDict

Experimental version of OrderedDict that has a custom object for keys, values, and items.

These are callable sequence objects that work as methods, or can be manipulated directly as sequences.

Test for keys, items and values.

>>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))
>>> d
SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])
>>> d.keys
[1, 2, 3]
>>> d.keys()
[1, 2, 3]
>>> d.setkeys((3, 2, 1))
>>> d
SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])
>>> d.setkeys((1, 2, 3))
>>> d.keys[0]
1
>>> d.keys[:]
[1, 2, 3]
>>> d.keys[-1]
3
>>> d.keys[-2]
2
>>> d.keys[0:2] = [2, 1]
>>> d
SequenceOrderedDict([(2, 3), (1, 2), (3, 4)])
>>> d.keys.reverse()
>>> d.keys
[3, 1, 2]
>>> d.keys = [1, 2, 3]
>>> d
SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])
>>> d.keys = [3, 1, 2]
>>> d
SequenceOrderedDict([(3, 4), (1, 2), (2, 3)])
>>> a = SequenceOrderedDict()
>>> b = SequenceOrderedDict()
>>> a.keys == b.keys
1
>>> a['a'] = 3
>>> a.keys == b.keys
0
>>> b['a'] = 3
>>> a.keys == b.keys
1
>>> b['b'] = 3
>>> a.keys == b.keys
0
>>> a.keys > b.keys
0
>>> a.keys < b.keys
1
>>> 'a' in a.keys
1
>>> len(b.keys)
2
>>> 'c' in d.keys
0
>>> 1 in d.keys
1
>>> [v for v in d.keys]
[3, 1, 2]
>>> d.keys.sort()
>>> d.keys
[1, 2, 3]
>>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)), strict=True)
>>> d.keys[::-1] = [1, 2, 3]
>>> d
SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])
>>> d.keys[:2]
[3, 2]
>>> d.keys[:2] = [1, 3]
Traceback (most recent call last):
KeyError: 'Keylist is not the same as current keylist.'
>>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))
>>> d
SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])
>>> d.values
[2, 3, 4]
>>> d.values()
[2, 3, 4]
>>> d.setvalues((4, 3, 2))
>>> d
SequenceOrderedDict([(1, 4), (2, 3), (3, 2)])
>>> d.values[::-1]
[2, 3, 4]
>>> d.values[0]
4
>>> d.values[-2]
3
>>> del d.values[0]
Traceback (most recent call last):
TypeError: Can't delete items from values
>>> d.values[::2] = [2, 4]
>>> d
SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])
>>> 7 in d.values
0
>>> len(d.values)
3
>>> [val for val in d.values]
[2, 3, 4]
>>> d.values[-1] = 2
>>> d.values.count(2)
2
>>> d.values.index(2)
0
>>> d.values[-1] = 7
>>> d.values
[2, 3, 7]
>>> d.values.reverse()
>>> d.values
[7, 3, 2]
>>> d.values.sort()
>>> d.values
[2, 3, 7]
>>> d.values.append('anything')
Traceback (most recent call last):
TypeError: Can't append items to values
>>> d.values = (1, 2, 3)
>>> d
SequenceOrderedDict([(1, 1), (2, 2), (3, 3)])
>>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))
>>> d
SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])
>>> d.items()
[(1, 2), (2, 3), (3, 4)]
>>> d.setitems([(3, 4), (2 ,3), (1, 2)])
>>> d
SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])
>>> d.items[0]
(3, 4)
>>> d.items[:-1]
[(3, 4), (2, 3)]
>>> d.items[1] = (6, 3)
>>> d.items
[(3, 4), (6, 3), (1, 2)]
>>> d.items[1:2] = [(9, 9)]
>>> d
SequenceOrderedDict([(3, 4), (9, 9), (1, 2)])
>>> del d.items[1:2]
>>> d
SequenceOrderedDict([(3, 4), (1, 2)])
>>> (3, 4) in d.items
1
>>> (4, 3) in d.items
0
>>> len(d.items)
2
>>> [v for v in d.items]
[(3, 4), (1, 2)]
>>> d.items.count((3, 4))
1
>>> d.items.index((1, 2))
1
>>> d.items.index((2, 1))
Traceback (most recent call last):
ValueError: list.index(x): x not in list
>>> d.items.reverse()
>>> d.items
[(1, 2), (3, 4)]
>>> d.items.reverse()
>>> d.items.sort()
>>> d.items
[(1, 2), (3, 4)]
>>> d.items.append((5, 6))
>>> d.items
[(1, 2), (3, 4), (5, 6)]
>>> d.items.insert(0, (0, 0))
>>> d.items
[(0, 0), (1, 2), (3, 4), (5, 6)]
>>> d.items.insert(-1, (7, 8))
>>> d.items
[(0, 0), (1, 2), (3, 4), (7, 8), (5, 6)]
>>> d.items.pop()
(5, 6)
>>> d.items
[(0, 0), (1, 2), (3, 4), (7, 8)]
>>> d.items.remove((1, 2))
>>> d.items
[(0, 0), (3, 4), (7, 8)]
>>> d.items.extend([(1, 2), (5, 6)])
>>> d.items
[(0, 0), (3, 4), (7, 8), (1, 2), (5, 6)]
__doc__ = "\n    Experimental version of OrderedDict that has a custom object for ``keys``,\n    ``values``, and ``items``.\n\n    These are callable sequence objects that work as methods, or can be\n    manipulated directly as sequences.\n\n    Test for ``keys``, ``items`` and ``values``.\n\n    >>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))\n    >>> d\n    SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])\n    >>> d.keys\n    [1, 2, 3]\n    >>> d.keys()\n    [1, 2, 3]\n    >>> d.setkeys((3, 2, 1))\n    >>> d\n    SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])\n    >>> d.setkeys((1, 2, 3))\n    >>> d.keys[0]\n    1\n    >>> d.keys[:]\n    [1, 2, 3]\n    >>> d.keys[-1]\n    3\n    >>> d.keys[-2]\n    2\n    >>> d.keys[0:2] = [2, 1]\n    >>> d\n    SequenceOrderedDict([(2, 3), (1, 2), (3, 4)])\n    >>> d.keys.reverse()\n    >>> d.keys\n    [3, 1, 2]\n    >>> d.keys = [1, 2, 3]\n    >>> d\n    SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])\n    >>> d.keys = [3, 1, 2]\n    >>> d\n    SequenceOrderedDict([(3, 4), (1, 2), (2, 3)])\n    >>> a = SequenceOrderedDict()\n    >>> b = SequenceOrderedDict()\n    >>> a.keys == b.keys\n    1\n    >>> a['a'] = 3\n    >>> a.keys == b.keys\n    0\n    >>> b['a'] = 3\n    >>> a.keys == b.keys\n    1\n    >>> b['b'] = 3\n    >>> a.keys == b.keys\n    0\n    >>> a.keys > b.keys\n    0\n    >>> a.keys < b.keys\n    1\n    >>> 'a' in a.keys\n    1\n    >>> len(b.keys)\n    2\n    >>> 'c' in d.keys\n    0\n    >>> 1 in d.keys\n    1\n    >>> [v for v in d.keys]\n    [3, 1, 2]\n    >>> d.keys.sort()\n    >>> d.keys\n    [1, 2, 3]\n    >>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)), strict=True)\n    >>> d.keys[::-1] = [1, 2, 3]\n    >>> d\n    SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])\n    >>> d.keys[:2]\n    [3, 2]\n    >>> d.keys[:2] = [1, 3]\n    Traceback (most recent call last):\n    KeyError: 'Keylist is not the same as current keylist.'\n\n    >>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))\n    >>> d\n    SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])\n    >>> d.values\n    [2, 3, 4]\n    >>> d.values()\n    [2, 3, 4]\n    >>> d.setvalues((4, 3, 2))\n    >>> d\n    SequenceOrderedDict([(1, 4), (2, 3), (3, 2)])\n    >>> d.values[::-1]\n    [2, 3, 4]\n    >>> d.values[0]\n    4\n    >>> d.values[-2]\n    3\n    >>> del d.values[0]\n    Traceback (most recent call last):\n    TypeError: Can't delete items from values\n    >>> d.values[::2] = [2, 4]\n    >>> d\n    SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])\n    >>> 7 in d.values\n    0\n    >>> len(d.values)\n    3\n    >>> [val for val in d.values]\n    [2, 3, 4]\n    >>> d.values[-1] = 2\n    >>> d.values.count(2)\n    2\n    >>> d.values.index(2)\n    0\n    >>> d.values[-1] = 7\n    >>> d.values\n    [2, 3, 7]\n    >>> d.values.reverse()\n    >>> d.values\n    [7, 3, 2]\n    >>> d.values.sort()\n    >>> d.values\n    [2, 3, 7]\n    >>> d.values.append('anything')\n    Traceback (most recent call last):\n    TypeError: Can't append items to values\n    >>> d.values = (1, 2, 3)\n    >>> d\n    SequenceOrderedDict([(1, 1), (2, 2), (3, 3)])\n\n    >>> d = SequenceOrderedDict(((1, 2), (2, 3), (3, 4)))\n    >>> d\n    SequenceOrderedDict([(1, 2), (2, 3), (3, 4)])\n    >>> d.items()\n    [(1, 2), (2, 3), (3, 4)]\n    >>> d.setitems([(3, 4), (2 ,3), (1, 2)])\n    >>> d\n    SequenceOrderedDict([(3, 4), (2, 3), (1, 2)])\n    >>> d.items[0]\n    (3, 4)\n    >>> d.items[:-1]\n    [(3, 4), (2, 3)]\n    >>> d.items[1] = (6, 3)\n    >>> d.items\n    [(3, 4), (6, 3), (1, 2)]\n    >>> d.items[1:2] = [(9, 9)]\n    >>> d\n    SequenceOrderedDict([(3, 4), (9, 9), (1, 2)])\n    >>> del d.items[1:2]\n    >>> d\n    SequenceOrderedDict([(3, 4), (1, 2)])\n    >>> (3, 4) in d.items\n    1\n    >>> (4, 3) in d.items\n    0\n    >>> len(d.items)\n    2\n    >>> [v for v in d.items]\n    [(3, 4), (1, 2)]\n    >>> d.items.count((3, 4))\n    1\n    >>> d.items.index((1, 2))\n    1\n    >>> d.items.index((2, 1))\n    Traceback (most recent call last):\n    ValueError: list.index(x): x not in list\n    >>> d.items.reverse()\n    >>> d.items\n    [(1, 2), (3, 4)]\n    >>> d.items.reverse()\n    >>> d.items.sort()\n    >>> d.items\n    [(1, 2), (3, 4)]\n    >>> d.items.append((5, 6))\n    >>> d.items\n    [(1, 2), (3, 4), (5, 6)]\n    >>> d.items.insert(0, (0, 0))\n    >>> d.items\n    [(0, 0), (1, 2), (3, 4), (5, 6)]\n    >>> d.items.insert(-1, (7, 8))\n    >>> d.items\n    [(0, 0), (1, 2), (3, 4), (7, 8), (5, 6)]\n    >>> d.items.pop()\n    (5, 6)\n    >>> d.items\n    [(0, 0), (1, 2), (3, 4), (7, 8)]\n    >>> d.items.remove((1, 2))\n    >>> d.items\n    [(0, 0), (3, 4), (7, 8)]\n    >>> d.items.extend([(1, 2), (5, 6)])\n    >>> d.items\n    [(0, 0), (3, 4), (7, 8), (1, 2), (5, 6)]\n    "
__init__(init_val=(), strict=True)[source]

Create a new ordered dictionary. Cannot init from a normal dict, nor from kwargs, since items order is undefined in those cases.

If the strict keyword argument is True (False is the default) then when doing slice assignment - the OrderedDict you are assigning from must not contain any keys in the remaining dict.

>>> OrderedDict()
OrderedDict([])
>>> OrderedDict({1: 1})
Traceback (most recent call last):
TypeError: undefined order, cannot get items from dict
>>> OrderedDict({1: 1}.items())
OrderedDict([(1, 1)])
>>> d = OrderedDict(((1, 3), (3, 2), (2, 1)))
>>> d
OrderedDict([(1, 3), (3, 2), (2, 1)])
>>> OrderedDict(d)
OrderedDict([(1, 3), (3, 2), (2, 1)])
__module__ = 'sas.sascalc.data_util.odict'
__setattr__(name, value)[source]

Protect keys, items, and values.

class sas.sascalc.data_util.odict.Values(main)[source]

Bases: object

Custom object for accessing the values of an OrderedDict.

Can be called like the normal OrderedDict.values method, but also supports indexing and sequence methods.

__add__(other)[source]
__call__()[source]

Pretend to be the values method.

__cmp__(other)[source]
__contains__(item)[source]
__delitem__(i)[source]
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.odict', '__doc__': '\n    Custom object for accessing the values of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.values`` method, but also\n    supports indexing and sequence methods.\n    ', '__init__': <function Values.__init__>, '__call__': <function Values.__call__>, '__getitem__': <function Values.__getitem__>, '__setitem__': <function Values.__setitem__>, '__repr__': <function Values.__repr__>, '__lt__': <function Values.__lt__>, '__le__': <function Values.__le__>, '__eq__': <function Values.__eq__>, '__ne__': <function Values.__ne__>, '__gt__': <function Values.__gt__>, '__ge__': <function Values.__ge__>, '__cmp__': <function Values.__cmp__>, '__contains__': <function Values.__contains__>, '__len__': <function Values.__len__>, '__iter__': <function Values.__iter__>, 'count': <function Values.count>, 'index': <function Values.index>, 'reverse': <function Values.reverse>, 'sort': <function Values.sort>, '__mul__': <function Values.__mul__>, '__rmul__': <function Values.__mul__>, '__add__': <function Values.__add__>, '__radd__': <function Values.__radd__>, '__delitem__': <function Values.__delitem__>, '__iadd__': <function Values.__iadd__>, '__imul__': <function Values.__imul__>, 'append': <function Values.append>, 'insert': <function Values.insert>, 'pop': <function Values.pop>, 'remove': <function Values.remove>, 'extend': <function Values.extend>, '__dict__': <attribute '__dict__' of 'Values' objects>, '__weakref__': <attribute '__weakref__' of 'Values' objects>, '__hash__': None, '__annotations__': {}})
__doc__ = '\n    Custom object for accessing the values of an OrderedDict.\n\n    Can be called like the normal ``OrderedDict.values`` method, but also\n    supports indexing and sequence methods.\n    '
__eq__(other)[source]

Return self==value.

__ge__(other)[source]

Return self>=value.

__getitem__(index)[source]

Fetch the value at position i.

__gt__(other)[source]

Return self>value.

__hash__ = None
__iadd__(other)[source]
__imul__(n)[source]
__init__(main)[source]
__iter__()[source]
__le__(other)[source]

Return self<=value.

__len__()[source]
__lt__(other)[source]

Return self<value.

__module__ = 'sas.sascalc.data_util.odict'
__mul__(n)[source]
__ne__(other)[source]

Return self!=value.

__radd__(other)[source]
__repr__()[source]

Return repr(self).

__rmul__(n)
__setitem__(index, value)[source]

Set the value at position i to value.

You can only do slice assignment to values if you supply a sequence of equal length to the slice you are replacing.

__weakref__

list of weak references to the object (if defined)

append(item)[source]
count(item)[source]
extend(other)[source]
index(item, *args)[source]
insert(i, item)[source]
pop(i=-1)[source]
remove(item)[source]
reverse()[source]

Reverse the values

sort(*args, **kwds)[source]

Sort the values.

sas.sascalc.data_util.pathutils module

Utilities for path manipulation. Not to be confused with the pathutils module from the pythonutils package (http://groups.google.com/group/pythonutils).

sas.sascalc.data_util.pathutils.join(path, *paths)[source]
sas.sascalc.data_util.pathutils.relpath(p1, p2)[source]

Compute the relative path of p1 with respect to p2.

sas.sascalc.data_util.pathutils.test()[source]

sas.sascalc.data_util.registry module

File extension registry.

This provides routines for opening files based on extension, and registers the built-in file extensions.

class sas.sascalc.data_util.registry.ExtensionRegistry(**kw)[source]

Bases: object

Associate a file loader with an extension.

Note that there may be multiple loaders for the same extension.

Example:

registry = ExtensionRegistry()

# Add an association by setting an element
registry['.zip'] = unzip

# Multiple extensions for one loader
registry['.tgz'] = untar
registry['.tar.gz'] = untar

# Generic extensions to use after trying more specific extensions;
# these will be checked after the more specific extensions fail.
registry['.gz'] = gunzip

# Multiple loaders for one extension
registry['.cx'] = cx1
registry['.cx'] = cx2
registry['.cx'] = cx3

# Show registered extensions
print registry.extensions()

# Can also register a format name for explicit control from caller
registry['cx3'] = cx3
print registry.formats()

# Retrieve loaders for a file name
registry.lookup('hello.cx') -> [cx3,cx2,cx1]

# Run loader on a filename
registry.load('hello.cx') ->
    try:
        return cx3('hello.cx')
    except:
        try:
            return cx2('hello.cx')
        except:
            return cx1('hello.cx')

# Load in a specific format ignoring extension
registry.load('hello.cx',format='cx3') ->
    return cx3('hello.cx')
__contains__(ext)[source]
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.registry', '__doc__': "\n    Associate a file loader with an extension.\n\n    Note that there may be multiple loaders for the same extension.\n\n    Example: ::\n\n        registry = ExtensionRegistry()\n\n        # Add an association by setting an element\n        registry['.zip'] = unzip\n\n        # Multiple extensions for one loader\n        registry['.tgz'] = untar\n        registry['.tar.gz'] = untar\n\n        # Generic extensions to use after trying more specific extensions;\n        # these will be checked after the more specific extensions fail.\n        registry['.gz'] = gunzip\n\n        # Multiple loaders for one extension\n        registry['.cx'] = cx1\n        registry['.cx'] = cx2\n        registry['.cx'] = cx3\n\n        # Show registered extensions\n        print registry.extensions()\n\n        # Can also register a format name for explicit control from caller\n        registry['cx3'] = cx3\n        print registry.formats()\n\n        # Retrieve loaders for a file name\n        registry.lookup('hello.cx') -> [cx3,cx2,cx1]\n\n        # Run loader on a filename\n        registry.load('hello.cx') ->\n            try:\n                return cx3('hello.cx')\n            except:\n                try:\n                    return cx2('hello.cx')\n                except:\n                    return cx1('hello.cx')\n\n        # Load in a specific format ignoring extension\n        registry.load('hello.cx',format='cx3') ->\n            return cx3('hello.cx')\n    ", '__init__': <function ExtensionRegistry.__init__>, '__setitem__': <function ExtensionRegistry.__setitem__>, '__getitem__': <function ExtensionRegistry.__getitem__>, '__contains__': <function ExtensionRegistry.__contains__>, 'formats': <function ExtensionRegistry.formats>, 'extensions': <function ExtensionRegistry.extensions>, 'lookup': <function ExtensionRegistry.lookup>, 'load': <function ExtensionRegistry.load>, '__dict__': <attribute '__dict__' of 'ExtensionRegistry' objects>, '__weakref__': <attribute '__weakref__' of 'ExtensionRegistry' objects>, '__annotations__': {}})
__doc__ = "\n    Associate a file loader with an extension.\n\n    Note that there may be multiple loaders for the same extension.\n\n    Example: ::\n\n        registry = ExtensionRegistry()\n\n        # Add an association by setting an element\n        registry['.zip'] = unzip\n\n        # Multiple extensions for one loader\n        registry['.tgz'] = untar\n        registry['.tar.gz'] = untar\n\n        # Generic extensions to use after trying more specific extensions;\n        # these will be checked after the more specific extensions fail.\n        registry['.gz'] = gunzip\n\n        # Multiple loaders for one extension\n        registry['.cx'] = cx1\n        registry['.cx'] = cx2\n        registry['.cx'] = cx3\n\n        # Show registered extensions\n        print registry.extensions()\n\n        # Can also register a format name for explicit control from caller\n        registry['cx3'] = cx3\n        print registry.formats()\n\n        # Retrieve loaders for a file name\n        registry.lookup('hello.cx') -> [cx3,cx2,cx1]\n\n        # Run loader on a filename\n        registry.load('hello.cx') ->\n            try:\n                return cx3('hello.cx')\n            except:\n                try:\n                    return cx2('hello.cx')\n                except:\n                    return cx1('hello.cx')\n\n        # Load in a specific format ignoring extension\n        registry.load('hello.cx',format='cx3') ->\n            return cx3('hello.cx')\n    "
__getitem__(ext)[source]
__init__(**kw)[source]
__module__ = 'sas.sascalc.data_util.registry'
__setitem__(ext, loader)[source]
__weakref__

list of weak references to the object (if defined)

extensions()[source]

Return a sorted list of registered extensions.

formats()[source]

Return a sorted list of the registered formats.

load(path, format=None)[source]

Call the loader for the file type of path.

Raises an exception if the loader fails or if no loaders are defined for the given path or format.

lookup(path)[source]

Return the loader associated with the file type of path.

Parameters:

path – Data file path

Returns:

List of available readers for the file extension (maybe empty)

sas.sascalc.data_util.uncertainty module

Uncertainty propagation class for arithmetic, log and exp.

Based on scalars or numpy vectors, this class allows you to store and manipulate values+uncertainties, with propagation of gaussian error for addition, subtraction, multiplication, division, power, exp and log.

Storage properties are determined by the numbers used to set the value and uncertainty. Be sure to use floating point uncertainty vectors for inplace operations since numpy does not do automatic type conversion. Normal operations can use mixed integer and floating point. In place operations such as a *= b create at most one extra copy for each operation. By contrast, c = a*b uses four intermediate vectors, so shouldn’t be used for huge arrays.

class sas.sascalc.data_util.uncertainty.Uncertainty(x, variance=None)[source]

Bases: object

__abs__()[source]
__add__(other)[source]
__and__(other)[source]
__coerce__()[source]
__complex__()[source]
__delitem__(key)[source]
__dict__ = mappingproxy({'__module__': 'sas.sascalc.data_util.uncertainty', '_getdx': <function Uncertainty._getdx>, '_setdx': <function Uncertainty._setdx>, 'dx': <property object>, '__init__': <function Uncertainty.__init__>, '__len__': <function Uncertainty.__len__>, '__getitem__': <function Uncertainty.__getitem__>, '__setitem__': <function Uncertainty.__setitem__>, '__delitem__': <function Uncertainty.__delitem__>, '__add__': <function Uncertainty.__add__>, '__sub__': <function Uncertainty.__sub__>, '__mul__': <function Uncertainty.__mul__>, '__truediv__': <function Uncertainty.__truediv__>, '__pow__': <function Uncertainty.__pow__>, '__radd__': <function Uncertainty.__radd__>, '__rsub__': <function Uncertainty.__rsub__>, '__rmul__': <function Uncertainty.__rmul__>, '__rtruediv__': <function Uncertainty.__rtruediv__>, '__rpow__': <function Uncertainty.__rpow__>, '__iadd__': <function Uncertainty.__iadd__>, '__isub__': <function Uncertainty.__isub__>, '__imul__': <function Uncertainty.__imul__>, '__itruediv__': <function Uncertainty.__itruediv__>, '__ipow__': <function Uncertainty.__ipow__>, '__div__': <function Uncertainty.__div__>, '__rdiv__': <function Uncertainty.__rdiv__>, '__idiv__': <function Uncertainty.__idiv__>, '__neg__': <function Uncertainty.__neg__>, '__pos__': <function Uncertainty.__pos__>, '__abs__': <function Uncertainty.__abs__>, '__str__': <function Uncertainty.__str__>, '__repr__': <function Uncertainty.__repr__>, '__floordiv__': <function Uncertainty.__floordiv__>, '__mod__': <function Uncertainty.__mod__>, '__divmod__': <function Uncertainty.__divmod__>, '__lshift__': <function Uncertainty.__lshift__>, '__rshift__': <function Uncertainty.__rshift__>, '__and__': <function Uncertainty.__and__>, '__xor__': <function Uncertainty.__xor__>, '__or__': <function Uncertainty.__or__>, '__rfloordiv__': <function Uncertainty.__rfloordiv__>, '__rmod__': <function Uncertainty.__rmod__>, '__rdivmod__': <function Uncertainty.__rdivmod__>, '__rlshift__': <function Uncertainty.__rlshift__>, '__rrshift__': <function Uncertainty.__rrshift__>, '__rand__': <function Uncertainty.__rand__>, '__rxor__': <function Uncertainty.__rxor__>, '__ror__': <function Uncertainty.__ror__>, '__ifloordiv__': <function Uncertainty.__ifloordiv__>, '__imod__': <function Uncertainty.__imod__>, '__idivmod__': <function Uncertainty.__idivmod__>, '__ilshift__': <function Uncertainty.__ilshift__>, '__irshift__': <function Uncertainty.__irshift__>, '__iand__': <function Uncertainty.__iand__>, '__ixor__': <function Uncertainty.__ixor__>, '__ior__': <function Uncertainty.__ior__>, '__invert__': <function Uncertainty.__invert__>, '__complex__': <function Uncertainty.__complex__>, '__int__': <function Uncertainty.__int__>, '__long__': <function Uncertainty.__long__>, '__float__': <function Uncertainty.__float__>, '__oct__': <function Uncertainty.__oct__>, '__hex__': <function Uncertainty.__hex__>, '__index__': <function Uncertainty.__index__>, '__coerce__': <function Uncertainty.__coerce__>, 'log': <function Uncertainty.log>, 'exp': <function Uncertainty.exp>, '__dict__': <attribute '__dict__' of 'Uncertainty' objects>, '__weakref__': <attribute '__weakref__' of 'Uncertainty' objects>, '__doc__': None, '__annotations__': {}})
__div__(other)[source]
__divmod__(other)[source]
__doc__ = None
__float__()[source]
__floordiv__(other)[source]
__getitem__(key)[source]
__hex__()[source]
__iadd__(other)[source]
__iand__(other)[source]
__idiv__(other)[source]
__idivmod__(other)[source]
__ifloordiv__(other)[source]
__ilshift__(other)[source]
__imod__(other)[source]
__imul__(other)[source]
__index__()[source]
__init__(x, variance=None)[source]
__int__()[source]
__invert__()[source]
__ior__(other)[source]
__ipow__(other)[source]
__irshift__(other)[source]
__isub__(other)[source]
__itruediv__(other)[source]
__ixor__(other)[source]
__len__()[source]
__long__()[source]
__lshift__(other)[source]
__mod__(other)[source]
__module__ = 'sas.sascalc.data_util.uncertainty'
__mul__(other)[source]
__neg__()[source]
__oct__()[source]
__or__(other)[source]
__pos__()[source]
__pow__(other)[source]
__radd__(other)[source]
__rand__(other)[source]
__rdiv__(other)[source]
__rdivmod__(other)[source]
__repr__()[source]

Return repr(self).

__rfloordiv__(other)[source]
__rlshift__(other)[source]
__rmod__(other)[source]
__rmul__(other)[source]
__ror__(other)[source]
__rpow__(other)[source]
__rrshift__(other)[source]
__rshift__(other)[source]
__rsub__(other)[source]
__rtruediv__(other)[source]
__rxor__(other)[source]
__setitem__(key, value)[source]
__str__()[source]

Return str(self).

__sub__(other)[source]
__truediv__(other)[source]
__weakref__

list of weak references to the object (if defined)

__xor__(other)[source]
_getdx()[source]
_setdx(dx)[source]
property dx

standard deviation

exp()[source]
log()[source]
sas.sascalc.data_util.uncertainty.exp(val)[source]
sas.sascalc.data_util.uncertainty.log(val)[source]
sas.sascalc.data_util.uncertainty.test()[source]

Module contents