Ignore:
Timestamp:
Apr 4, 2017 8:03:52 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
2d866370
Parents:
388bd51
Message:

Add docstrings to sesans_reader utility functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r388bd51 r09a0be5  
    117117 
    118118    def _unit_conversion(self, value, value_unit, default_unit): 
     119        """ 
     120        Performs unit conversion on a measurement. 
     121 
     122        :param value: The magnitude of the measurement 
     123        :type value: Number 
     124        :param value_unit: a string containing the final desired unit 
     125        :type value_unit: String 
     126        :param default_unit: a string containing the units of the original measurement 
     127        :type default_unit: String 
     128        :return: The magnitude of the measurement in the new units 
     129        """ 
    119130        if has_converter and value_unit != default_unit: 
    120131            data_conv_q = Converter(value_unit) 
     
    126137 
    127138    def _header_fetch(self, headers, key): 
     139        """ 
     140        Pull the value of a unit defined header from a dict. Example:: 
     141 
     142         d = {"Length [m]": 17} 
     143         self._header_fetch(d, "Length") == 17 
     144 
     145        :param header: A dictionary of values 
     146        :type header: Dictionary 
     147        :param key: A string which is a prefix for one of the keys in the dict 
     148        :type key: String 
     149        :return: The value of the dictionary for the specified key 
     150        """ 
    128151        index = [k for k in headers.keys() 
    129152                 if k.startswith(key)][0] 
     
    131154 
    132155    def _fetch_unit(self, params, key): 
     156        """ 
     157        Pull the unit off of a dictionary header. Example:: 
     158 
     159         d = {"Length [m]": 17} 
     160         self._fetch_unit(d, "Length") == "m" 
     161 
     162        :param header: A dictionary of values, where the keys are strings 
     163        with the units for the values appended onto the string within square 
     164        brackets (See the example above) 
     165        :type header: Dictionary 
     166        :param key: A string with the prefix of the dictionary key whose unit 
     167        is being fetched 
     168        :type key: String 
     169        :return: A string containing the unit specifed in the header 
     170        """ 
    133171        index = [k for k in params.keys() 
    134172                 if k.startswith(key)][0] 
Note: See TracChangeset for help on using the changeset viewer.