Example #1
0
def test_profile_modelling():
    grs = pytest.importorskip("dials.algorithms.profile_model.gaussian_rs")

    profile1 = grs.Model(None, 3, 0.1, 0.2, deg=True)
    dictionary = profile1.to_dict()
    profile2 = ProfileModelFactory.from_dict(dictionary)
    assert profile1.sigma_b() == pytest.approx(profile2.sigma_b(), abs=1e-7)
    assert profile1.sigma_m() == pytest.approx(profile2.sigma_m(), abs=1e-7)
Example #2
0
def test_profile_modelling():
    grs = pytest.importorskip("dials.algorithms.profile_model.gaussian_rs")
    if not hasattr(grs, "__file__"):
        pytest.skip("test requires DIALS")
        # this may pretend to be present in Python 3 without dials actually being there

    profile1 = grs.Model(None, 3, 0.1, 0.2, deg=True)
    dictionary = profile1.to_dict()
    profile2 = ProfileModelFactory.from_dict(dictionary)
    assert profile1.sigma_b() == pytest.approx(profile2.sigma_b(), abs=1e-7)
    assert profile1.sigma_m() == pytest.approx(profile2.sigma_m(), abs=1e-7)
 def _profile_from_dict(obj):
     ''' Get the profile from a dictionary. '''
     from dxtbx.model import ProfileModelFactory
     return ProfileModelFactory.from_dict(obj)
 def run(self):
   profile1 = NullProfile(10)
   dictionary = profile1.to_dict()
   profile2 = ProfileModelFactory.from_dict(dictionary)
   assert(profile1.parameter == profile2.parameter)
   print 'OK'
  name = 'null'

  def __init__(self, parameter):
    self.parameter = parameter

  def to_dict(self):
    return {
      '__id__' : self.name,
      'parameter' : self.parameter
    }

  @classmethod
  def from_dict(Class, obj):
    return Class(obj['parameter'])

ProfileModelFactory.append(NullProfile.name, NullProfile)


class Test(object):

  def __init__(self):
    pass

  def run(self):
    profile1 = NullProfile(10)
    dictionary = profile1.to_dict()
    profile2 = ProfileModelFactory.from_dict(dictionary)
    assert(profile1.parameter == profile2.parameter)
    print 'OK'

if __name__ == '__main__':
Example #6
0
 def _profile_from_dict(obj):
   ''' Get the profile from a dictionary. '''
   from dxtbx.model import ProfileModelFactory
   return ProfileModelFactory.from_dict(obj)
Example #7
0
 def run(self):
     profile1 = NullProfile(10)
     dictionary = profile1.to_dict()
     profile2 = ProfileModelFactory.from_dict(dictionary)
     assert (profile1.parameter == profile2.parameter)
     print 'OK'
Example #8
0
class NullProfile(ProfileModelBaseIface):

    name = 'null'

    def __init__(self, parameter):
        self.parameter = parameter

    def to_dict(self):
        return {'__id__': self.name, 'parameter': self.parameter}

    @classmethod
    def from_dict(cls, obj):
        return cls(obj['parameter'])


ProfileModelFactory.append(NullProfile.name, NullProfile)


class Test(object):
    def __init__(self):
        pass

    def run(self):
        profile1 = NullProfile(10)
        dictionary = profile1.to_dict()
        profile2 = ProfileModelFactory.from_dict(dictionary)
        assert (profile1.parameter == profile2.parameter)
        print 'OK'


if __name__ == '__main__':
Example #9
0
 def _profile_from_dict(obj):
     """ Get the profile from a dictionary. """
     return ProfileModelFactory.from_dict(obj)