Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor overlays to be classes instead of dicts #1141

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions hexrd/ui/calibration/auto/powder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from hexrd.ui.async_runner import AsyncRunner
from hexrd.ui.create_hedm_instrument import create_hedm_instrument
from hexrd.ui.constants import OverlayType
from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.utils import instr_to_internal_dict

Expand Down Expand Up @@ -228,12 +227,12 @@ def overlays(self):

@property
def visible_overlays(self):
return [x for x in self.overlays if x['visible']]
return [x for x in self.overlays if x.visible]

@property
def visible_powder_overlays(self):
overlays = self.visible_overlays
return [x for x in overlays if x['type'] == OverlayType.powder]
return [x for x in overlays if x.is_powder]

@property
def active_overlay(self):
Expand All @@ -243,11 +242,7 @@ def active_overlay(self):
@property
def material(self):
overlay = self.active_overlay
return HexrdConfig().material(overlay['material']) if overlay else None

@property
def active_overlay_refinements(self):
return [x[1] for x in self.active_overlay['refinements']]
return overlay.material if overlay else None

@property
def refinement_flags_without_overlays(self):
Expand All @@ -256,4 +251,4 @@ def refinement_flags_without_overlays(self):
@property
def refinement_flags(self):
return np.hstack([self.refinement_flags_without_overlays,
self.active_overlay_refinements])
self.active_overlay.refinements])
Loading