cfdm.configuration¶
-
cfdm.configuration(atol=None, rtol=None, log_level=None)[source]¶ View or set any number of constants in the project-wide configuration.
The full list of global constants that are provided in a dictionary to view, and can be set in any combination, are:
These are all constants that apply throughout
cfdm, except for in specific functions only if overriden by the corresponding keyword argument to that function.The value of
None, either taken by default or supplied as a value, will result in the constant in question not being changed from the current value. That is, it will have no effect.Note that setting a constant using this function is equivalent to setting it by means of a specific function of the same name, e.g. via
cfdm.atol, but in this case multiple constants can be set at once.New in version 1.8.6.
- Parameters
- atol:
float, optional The new value of absolute tolerance. The default is to not change the current value.
- rtol:
float, optional The new value of relative tolerance. The default is to not change the current value.
- log_level:
strorint, optional The new value of the minimal log severity level. This can be specified either as a string equal (ignoring case) to the named set of log levels or identifier ‘DISABLE’, or an integer code corresponding to each of these, namely:
'DISABLE'(0);'WARNING'(1);'INFO'(2);'DETAIL'(3);'DEBUG'(-1).
- atol:
- Returns
dictThe names and values of the project-wide constants prior to the change, or the current names and values if no new values are specified.
Examples:
>>> cfdm.configuration() # view full global configuration of constants {'atol': 2.220446049250313e-16, 'rtol': 2.220446049250313e-16, 'log_level': 'WARNING'} >>> cfdm.log_level('DEBUG') # make a change to one constant... 'WARNING' >>> cfdm.configuration() # ...and it is reflected in the configuration {'atol': 2.220446049250313e-16, 'rtol': 2.220446049250313e-16, 'log_level': 'DEBUG'}
>>> cfdm.configuration()['atol'] # access specific values by key querying 2.220446049250313e-16 >>> cfdm.configuration()['atol'] == cfdm.atol() # note the equivalency True
>>> cfdm.configuration(atol=5e-14, log_level='INFO') # set multiple items {'atol': 2.220446049250313e-16, 'rtol': 2.220446049250313e-16, 'log_level': 'DEBUG'} >>> cfdm.configuration() {'atol': 5e-14, 'rtol': 2.220446049250313e-16, 'log_level': 'INFO'}
>>> cfdm.configuration(rtol=1e-17) # equivalent to setting cfdm.rtol(1e-17) {'atol': 5e-14, 'rtol': 2.220446049250313e-16, 'log_level': 'INFO'} >>> cfdm.configuration() {'atol': 5e-14, 'rtol': 1e-17, 'log_level': 'INFO'}