Skip to content

Commit

Permalink
Merge pull request #377 from European-XFEL/fix/tableInitialLoading
Browse files Browse the repository at this point in the history
fix: interpret complex numbers from the DB when the gui loads the table
  • Loading branch information
tmichela authored Jan 27, 2025
2 parents 76352ec + 9783a33 commit a0b022f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions damnit/gui/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from PyQt5.QtWidgets import QMessageBox
from superqt.utils import qthrottled

from ..backend.db import BlobTypes, DamnitDB, ReducedData
from ..backend.db import BlobTypes, DamnitDB, ReducedData, blob2complex
from ..backend.extraction_control import ExtractionJobTracker
from ..backend.user_variables import value_types_by_name
from ..util import StatusbarStylesheet, delete_variable, timestamp2str
Expand Down Expand Up @@ -518,14 +518,16 @@ def _load_from_db(self):
self.setItem(row_ix, 3, self.text_item(ts, timestamp2str(ts)))

for (prop, run), grp in groupby(self.db.conn.execute("""
SELECT proposal, run, name, value, max_diff, attributes FROM run_variables
SELECT proposal, run, name, value, max_diff, summary_type, attributes FROM run_variables
ORDER BY proposal, run
""").fetchall(), key=lambda r: r[:2]): # Group by proposal & run
row_ix = self.run_index[(prop, run)]
for *_, name, value, max_diff, attr_json in grp:
for *_, name, value, max_diff, summary_type, attr_json in grp:
col_ix = self.column_index[name]
if name in self.user_variables:
value = self.user_variables[name].get_type_class().from_db_value(value)
if summary_type == "complex":
value = blob2complex(value)
attrs = json.loads(attr_json) if attr_json else {}
self.setItem(row_ix, col_ix, self.new_item(value, name, max_diff, attrs))

Expand Down
7 changes: 6 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

Added:

- Watch context file for changes saved outside the editor (!304).
- GUI: Watch context file for changes saved outside the editor (!304).
- GUI: show when runs are being processed (!322)
- Reads techniques annotation from MyMDC (!338).
- Add a `tags` attribute allowing cathegorizing `Variable`s (!354).
- Add support for `complex` numbers (!374)
- GUI: Add a Dark theme (!376)

Changed:

Expand All @@ -19,10 +22,12 @@ Fixed:

- Fixed loading data with WebViewer (!310).
- Added back grid lines for plots of `DataArray`'s (!334).
- Failed to setup new database from the GUI (!337)
- Fixed adding new variable without explicit title as column in GUI (!347).
- Fixed thumbnails of 2D `DataArray`'s to match what is displayed when the
variable is plotted (!355).
- Fixed crashes when the context file environment is missing dependencies (!356).
- handle failure generating summary while writing results to file (!370)

## [0.1.4]

Expand Down

0 comments on commit a0b022f

Please sign in to comment.