• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mantidproject / mslice / 13084206280

28 Jan 2025 09:32AM UTC coverage: 87.668%. Remained the same
13084206280

push

github

web-flow
Merge pull request #1048 from mantidproject/ruff-format

Ruff format mslice

440 of 499 new or added lines in 39 files covered. (88.18%)

6 existing lines in 5 files now uncovered.

3064 of 3495 relevant lines covered (87.67%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/mslice/workspace/workspace.py
1
from .base import WorkspaceBase
1✔
2
from .workspace_mixin import WorkspaceOperatorMixin, WorkspaceMixin
1✔
3
from .helperfunctions import (
1✔
4
    attribute_from_log,
5
    attribute_to_log,
6
    delete_workspace,
7
    rename_workspace,
8
)
9
from .common_workspace_properties import CommonWorkspaceProperties
1✔
10

11
from mantid.api import MatrixWorkspace
1✔
12

13
import re
1✔
14

15

16
class Workspace(
1✔
17
    WorkspaceOperatorMixin, WorkspaceMixin, WorkspaceBase, CommonWorkspaceProperties
18
):
19
    """workspace wrapper for MatrixWorkspace"""
20

21
    def __init__(self, mantid_ws, name):
1✔
22
        if isinstance(mantid_ws, MatrixWorkspace):
1✔
23
            self._raw_ws = mantid_ws
1✔
24
        else:
25
            raise TypeError(
1✔
26
                "Workspace expected matrixWorkspace, got %s"
27
                % mantid_ws.__class__.__name__
28
            )
29
        CommonWorkspaceProperties.__init__(self)
1✔
30
        self._name = name
1✔
31
        self._cut_params = {}
1✔
32
        self.ef_defined = None
1✔
33
        self.limits = {}
1✔
34
        self.is_PSD = None
1✔
35
        self.e_mode = None
1✔
36
        self.e_fixed = None
1✔
37
        self.axes = []
1✔
38
        attribute_from_log(self, mantid_ws)
1✔
39

40
    @WorkspaceMixin.name.setter
1✔
41
    def name(self, new_name: str):
1✔
42
        raw_name = str(self.raw_ws)
1✔
43
        rename_workspace(
1✔
44
            raw_name, re.sub(rf"{re.escape(self.name)}\w*", new_name, raw_name)
45
        )
46

47
        self._name = new_name
1✔
48

49
    def rewrap(self, mantid_ws):
1✔
50
        new_ws = Workspace(mantid_ws, self.name)
1✔
51
        new_ws.is_PSD = self.is_PSD
1✔
52
        new_ws.e_mode = self.e_mode
1✔
53
        new_ws.e_fixed = self.e_fixed
1✔
54
        new_ws.ef_defined = self.ef_defined
1✔
55
        new_ws.limits = self.limits
1✔
56
        new_ws.axes = self.axes
1✔
57
        new_ws.is_slice = self.is_slice
1✔
58
        attribute_from_log(new_ws, mantid_ws)
1✔
59
        return new_ws
1✔
60

61
    def save_attributes(self):
1✔
62
        attrdict = {}
×
NEW
63
        for k, v in [["axes", self.axes]]:
×
64
            if k:
×
65
                attrdict[k] = v
×
66
        attribute_to_log(attrdict, self.raw_ws)
×
67

68
    def remove_saved_attributes(self):
1✔
69
        attribute_from_log(None, self.raw_ws)
×
70

71
    def __del__(self):
1✔
72
        if hasattr(self, "_raw_ws"):
1✔
73
            delete_workspace(self, self._raw_ws)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc