示例#1
0
文件: core.py 项目: Zaharid/smpdf
    def __enter__(self):
        """Load observable file in memory, using `with obs`.

        Note: Except random bugs due to APPLGrid poor implementation
        when loading several observables in the same process. In particular,pdf
        convolutions of grids made with AMCFast will not work."""
        global _selected_grid
        if _selected_grid == self.filename:
            return
        if _selected_grid is not None:
            raise RuntimeError("Contrdicting observable scope. "
                               "Was %s and trying to enter %s" %
                               (_selected_grid, self.filename))

        with contextlib.ExitStack() as stack:
            if not logging.getLogger().isEnabledFor(logging.DEBUG):
                stack.enter_context(supress_stdout())
            applwrap.initobs(self.filename)
        _selected_grid = self.filename
示例#2
0
 def test_bad_values(self):
     with self.assertRaises(ValueError):
         applwrap.initobs("patata")
     with self.assertRaises(ValueError):
         applwrap.initpdf("patata")