In relax a mixture of both camel case (e.g. CamelCase) and lower case with underscores is used. Despite the variability there are fixed rules which should be adhered to. These naming conventions should be observed at all times.
For both variables and functions lower case with underscores between words is always used. This is for readability as the convention is much more fluent than camel case. A few rare exceptions exist, an example is the Brownian diffusion tensor parameter of anisotropy which is referenced as cdp.diff_tensor.Da. As a rule though all new variable or function names should be kept as lower case. An example of this convention for both the variable name and function name is:
def assemble_param_vector(self, spin=None, spin_id=None, sim_index=None, model_type=None): """Assemble the model-free parameter vector (as numpy array). If the spin argument is supplied, then the spin_id argument will be ignored. @keyword spin: The spin data container. @type spin: SpinContainer instance @keyword spin_id: The spin identification string. @type spin_id: str @keyword sim_index: The optional MC simulation index. @type sim_index: int @keyword model_type: The optional parameter set, one of 'all', 'diff', 'mf', or 'local_tm'. @type model_type: str or None @return: An array of the parameter values of the model-free model. @rtype: numpy array """ # Initialise. param_vector =  # Determine the model type. if not model_type: model_type = self.determine_param_set_type() # Diffusion tensor parameters. if model_type == 'diff' or model_type == 'all': # Normal parameters. if sim_index == None: # Spherical diffusion. if cdp.diff_tensor.type == 'sphere': param_vector.append(cdp.diff_tensor.tm)
For classes relax uses a mix of camel case (for example all the RelaxError objects) and underscores (for example Model_free). The first letter in all cases is always capitalised. Generally the camel case is reserved for very low level classes which are involved in the program's infrastructure. Examples include the RelaxError code, the threading code, and the relax data store code. All the data analysis specific code, data pipe control code, interface code, etc. uses underscores between the words with only the first letter capitalised. One exception is the space mapping class OpenDX, the reason being that the program is called OpenDX. An example is:
class Model_free_main: """Class containing functions specific to model-free analysis.""" def are_mf_params_set(self, spin): """Test if the model-free parameter values are set. @param spin: The spin container object. @type spin: SpinContainer instance @return: The name of the first parameter in the parameter list in which the corresponding parameter value is None. If all parameters are set, then None is returned. @rtype: str or None """ # Deselected residue. if spin.select == 0: return
If you have a look at a few relax source files, you will notice that the variable, function, and class names can be quite long. For example the model-free function disassemble_param_vector() and the RelaxError class RelaxNoSequenceError. While this is not normal for coding, it is an important component of relax as it facilitates the reading of the source code by a non-coder or someone not familiar with the codebase. Iteration counters can be single letter variables such as i, j, k, etc., however for all other variables, functions, and classes please attempt to use descriptive names which are instantly identifiable. Please minimise the amount of abbreviations used and only use those which are obvious. For example naming the parameter vector self.param_vector, the relaxation data relax_data, the model selection class class Model_selection, the type of spheroidal diffusion spheroid_type, etc.
The relax user manual (PDF), created 2019-03-08.