diff --git a/csst_common/__init__.py b/csst_common/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..03b4017a109f9111732253bc1623d4cba939e777 100644 --- a/csst_common/__init__.py +++ b/csst_common/__init__.py @@ -0,0 +1,5 @@ +import os + +__version__ = "0.0.1" + +PACKAGE_PATH = os.path.dirname(__file__) diff --git a/csst_common/params.py b/csst_common/params.py index 5bce9ac5f54323a37d4b294e809579935d63cca9..86fbd9ce0985989d1f7fb31e91c4bd4bc146aa00 100644 --- a/csst_common/params.py +++ b/csst_common/params.py @@ -3,9 +3,10 @@ class BasicParams: """ the basic parameter class """ def __repr__(self): _class_name = self.__class__.__name__ - _str = "<{}>\n{}\n".format(_class_name, "-" * (len(_class_name) + 2)) + _str = "<{} length={}>".format(_class_name, len(self.__dict__)) + _str += "\n{}\n".format("-" * len(_str)) for k, v in self.__dict__.items(): - _str += "{}:{} \n".format(k, v) + _str += "{} : {} \n".format(k, v) return _str # def to_dict(self): @@ -20,13 +21,26 @@ class BasicParams: class CsstParams(BasicParams): """ CSST parameters -- a collection of """ def __init__(self): + """ + This class defines the CSST parameters. + + Example + ------- + >>> from csst_common.params import CsstParams + >>> cps = CsstParams() + + See also + -------- + CsstMbiParams, CsstSlsParams, CsstSimParams + """ self.mbi = CsstMbiParams() self.sls = CsstSlsParams() self.sim = CsstSimParams() def __repr__(self): _class_name = self.__class__.__name__ - _str = "<{}>\n{}\n".format(_class_name, "-"*(len(_class_name)+2)) + _str = "<{} length={}>".format(_class_name, len(self.__dict__)) + _str += "\n{}\n".format("-" * len(_str)) for k, v in self.__dict__.items(): _str += "{}: \n".format(k) for kk in self.__getattribute__(k).__dict__.keys(): @@ -79,6 +93,8 @@ class CsstSimParams(BasicParams): self.VER_SIMS = ["C3", "C5.1", "C5.2"] +cp = CsstParams() + if __name__ == "__main__": cp = CsstParams() print(cp)