Skip to content

Commit

Permalink
TST #98 modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jan 8, 2021
1 parent a606ad2 commit bef290f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 100 deletions.
28 changes: 5 additions & 23 deletions hkl/tests/test_diffract.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
import pytest
import gi
import numpy.testing

from ophyd import Component as Cpt
from ophyd import PseudoSingle, SoftPositioner

import pint

import gi
import pytest

gi.require_version("Hkl", "5.0")
# NOTE: MUST call gi.require_version() BEFORE import hkl
from hkl.calc import A_KEV
from hkl.geometries import E4CV


class Fourc(E4CV):
h = Cpt(PseudoSingle, "")
k = Cpt(PseudoSingle, "")
l = Cpt(PseudoSingle, "")

omega = Cpt(SoftPositioner)
chi = Cpt(SoftPositioner)
phi = Cpt(SoftPositioner)
tth = Cpt(SoftPositioner)
from hkl.geometries import SimulatedE4CV

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for p in self.real_positioners:
p._set_position(0) # give each a starting position
class Fourc(SimulatedE4CV):
...


@pytest.fixture(scope="function")
Expand Down
46 changes: 9 additions & 37 deletions hkl/tests/test_extra_motor.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
from ophyd import PseudoSingle, SoftPositioner
from ophyd import Component as Cpt

import gi
from ophyd import Component as Cpt
from ophyd import PseudoSingle

gi.require_version("Hkl", "5.0")
from hkl.geometries import E4CV


class Fourc(E4CV):
h = Cpt(PseudoSingle, "")
k = Cpt(PseudoSingle, "")
l = Cpt(PseudoSingle, "")
from hkl.geometries import SimulatedE4CV

omega = Cpt(SoftPositioner)
chi = Cpt(SoftPositioner)
phi = Cpt(SoftPositioner)
tth = Cpt(SoftPositioner)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for p in self.real_positioners:
p._set_position(0) # give each a starting position
class Fourc(SimulatedE4CV):
...


FOURC_SETUP_CODE = """
from ophyd import PseudoSingle, SoftPositioner
from ophyd import Component as Cpt
from ophyd import SoftPositioner
import gi
gi.require_version('Hkl', '5.0')
from hkl.geometries import E4CV
class Fourc(E4CV):
h = Cpt(PseudoSingle, '')
k = Cpt(PseudoSingle, '')
l = Cpt(PseudoSingle, '')
omega = Cpt(SoftPositioner)
chi = Cpt(SoftPositioner)
phi = Cpt(SoftPositioner)
tth = Cpt(SoftPositioner)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
from hkl.geometries import SimulatedE4CV
for p in self.real_positioners:
p._set_position(0) # give each a starting position
class Fourc(SimulatedE4CV):
...
"""


Expand Down
23 changes: 4 additions & 19 deletions hkl/tests/test_fourc.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
from bluesky import plans as bp
from bluesky.simulators import check_limits
from ophyd import PseudoSingle, SoftPositioner
from ophyd import Component as Cpt
from ophyd.positioner import LimitError
import gi
import numpy as np
import numpy.testing
import pytest

import gi

gi.require_version("Hkl", "5.0")
# NOTE: MUST call gi.require_version() BEFORE import hkl
from hkl.geometries import E4CV


class Fourc(E4CV):
h = Cpt(PseudoSingle, "")
k = Cpt(PseudoSingle, "")
l = Cpt(PseudoSingle, "")

omega = Cpt(SoftPositioner, limits=(-180, 180))
chi = Cpt(SoftPositioner, limits=(-180, 180))
phi = Cpt(SoftPositioner, limits=(-180, 180))
tth = Cpt(SoftPositioner, limits=(-180, 180))
from hkl.geometries import SimulatedE4CV

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for p in self.real_positioners:
p._set_position(0) # give each a starting position
class Fourc(SimulatedE4CV):
...


@pytest.fixture(scope="function")
Expand Down
25 changes: 4 additions & 21 deletions hkl/tests/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
from ophyd import Component as Cpt
from ophyd import PseudoSingle
from ophyd import SoftPositioner
import gi
import numpy as np
import pytest

import gi

gi.require_version("Hkl", "5.0")
# NOTE: MUST call gi.require_version() BEFORE import hkl
from hkl.geometries import E4CV


class Fourc(E4CV):
h = Cpt(PseudoSingle, "")
k = Cpt(PseudoSingle, "")
l = Cpt(PseudoSingle, "")

omega = Cpt(SoftPositioner, limits=(-180, 180))
chi = Cpt(SoftPositioner, limits=(-180, 180))
phi = Cpt(SoftPositioner, limits=(-180, 180))
tth = Cpt(SoftPositioner, limits=(-180, 180))
from hkl.geometries import SimulatedE4CV

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for p in self.real_positioners:
p._set_position(0) # give each a starting position
class Fourc(SimulatedE4CV):
...


@pytest.fixture(scope="function")
Expand Down

0 comments on commit bef290f

Please sign in to comment.