pynbody.util.SettingControl

pynbody.util.SettingControl#

class pynbody.util.SettingControl(dictionary, key, value)[source]#

Bases: object

Class to control a setting using a with statement.

This is used by pynbody.analysis.luminosity and pynbody.analysis.ionfrac to control the table used by calculations.

Given a dictionary, the key to modify, and the value to set the key to, this class will set the key to the value on creation or when entering the with block, and reset it to the original value when exiting the block.

__init__(dictionary, key, value)[source]#

Create a new setting control object

Parameters:
  • dictionary (dict) – The dictionary to control; this is modified in place.

  • key (str) – The key to modify

  • value (object) – The value to set the key to when creating or entering the with block.