Esempio n. 1
0
 def refresh_display(self, info):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     try:
         comments = info.pop(input_database._comment, None)
         comments_text = "\n# " + "\n# ".join(comments)
     except (
             TypeError,  # No comments
             AttributeError
     ):  # Failed to generate info (returned str instead)
         comments_text = ""
     self.display["python"].setText("info = " + pformat(info) +
                                    comments_text)
     self.display["yaml"].setText(
         yaml_dump(sort_cosmetic(info)) + comments_text)
     self.display["bibliography"].setText(
         prettyprint_bib(*get_bib_info(info)))
     # Display covmat
     packages_path = resolve_packages_path()
     if not packages_path:
         self.covmat_text.setText(
             "\nIn order to find a covariance matrix, you need to define an external "
             "packages installation path, e.g. via the env variable %r.\n" %
             _packages_path_env)
     elif any(not os.path.isdir(d.format(**{_packages_path: packages_path}))
              for d in covmat_folders):
         self.covmat_text.setText(
             "\nThe external cosmological packages appear not to be installed where "
             "expected: %r\n" % packages_path)
     else:
         covmat_data = get_best_covmat(info, packages_path=packages_path)
         self.current_params_in_covmat = covmat_data["params"]
         self.current_covmat = covmat_data["covmat"]
         _, corrmat = cov_to_std_and_corr(self.current_covmat)
         self.covmat_text.setText(
             "\nCovariance file: %r\n\n"
             "NB: you do *not* need to save or copy this covariance matrix: "
             "it will be selected automatically.\n" % covmat_data["name"])
         self.covmat_table.setRowCount(len(self.current_params_in_covmat))
         self.covmat_table.setColumnCount(len(
             self.current_params_in_covmat))
         self.covmat_table.setHorizontalHeaderLabels(
             list(self.current_params_in_covmat))
         self.covmat_table.setVerticalHeaderLabels(
             list(self.current_params_in_covmat))
         for i, pi in enumerate(self.current_params_in_covmat):
             for j, pj in enumerate(self.current_params_in_covmat):
                 self.covmat_table.setItem(
                     i, j,
                     QTableWidgetItem("%g" % self.current_covmat[i, j]))
                 if i != j:
                     color = [
                         256 * c
                         for c in cmap_corr(corrmat[i, j] / 2 + 0.5)[:3]
                     ]
                 else:
                     color = [255.99] * 3
                 self.covmat_table.item(i, j).setBackground(QColor(*color))
                 self.covmat_table.item(i, j).setForeground(QColor(0, 0, 0))
     QApplication.restoreOverrideCursor()
Esempio n. 2
0
 def refresh_display(self, info):
     try:
         comments = info.pop(input_database._comment, None)
         comments_text = "\n# " + "\n# ".join(comments)
     except (TypeError,  # No comments
             AttributeError):  # Failed to generate info (returned str instead)
         comments_text = ""
     self.display["python"].setText(
         "from collections import OrderedDict\n\ninfo = " +
         pformat(info) + comments_text)
     self.display["yaml"].setText(yaml_dump(info) + comments_text)
     self.display["bibliography"].setText(prettyprint_bib(get_bib_info(info)))