Skip to content

Commit

Permalink
Merge 6a7b89a into 95bebcb
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthchirp committed Oct 15, 2018
2 parents 95bebcb + 6a7b89a commit 789df20
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ispyb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ConfigParser as configparser
import logging

__version__ = '4.12.0'
__version__ = '4.13.0'

_log = logging.getLogger('ispyb')

Expand Down
31 changes: 20 additions & 11 deletions ispyb/model/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,24 @@ def data_collection(self):
@property
def unit_cell(self):
'''Returns the unit cell model'''
return ispyb.model.integration.UnitCell(self._data['cell_a'], self._data['cell_b'],self._data['cell_c'],
self._data['cell_alpha'], self._data['cell_beta'], self._data['cell_gamma'])
return ispyb.model.integration.UnitCell(
self._data['cell_a'], self._data['cell_b'],self._data['cell_c'],
self._data['cell_alpha'], self._data['cell_beta'], self._data['cell_gamma']
)

@property
def APIID(self):
'''Returns the AutoProcIntegrationID.'''
return self._apiid

@property
def program(self):
'''Returns the AutoProcProgram model object for the processing program
responsible for this integration result.'''
if self._cache_app is None:
self._cache_app = ispyb.model.processingprogram.ProcessingProgram(self.APPID, self._db)
return self._cache_app

def __repr__(self):
'''Returns an object representation, including the AutoProcIntegrationID,
the database connection interface object, and the cache status.'''
Expand Down Expand Up @@ -92,20 +102,21 @@ def __str__(self):
('timestamp', 'recordTimeStamp'),
))

class UnitCell():
'''An object representing the parameters of the unit cell I.e unit cell edges and angles
class UnitCell(object):
'''A read-only object representing the parameters of the unit cell,
ie. edges and angles.
'''

def __init__(self, a, b, c, alpha, beta, gamma):
'''Unit cell object
:param a: Edge a
:param b: Edge b
:param c: Edge c
:param a: Edge a in Angstrom
:param b: Edge b in Angstrom
:param c: Edge c in Angstrom
:param alpha: Angle alpha
:param beta: Angle beta
:param gamma: Angle gamma
:return: A unitcell object
:return: A UnitCell object
'''
self._a = a
self._b = b
Expand All @@ -114,7 +125,6 @@ def __init__(self, a, b, c, alpha, beta, gamma):
self._beta = beta
self._gamma = gamma


@property
def a(self):
'''Returns dimension a of unit cell in Angstroms'''
Expand Down Expand Up @@ -144,7 +154,7 @@ def beta(self):
def gamma(self):
'''Returns angle gamma of unit cell'''
return self._gamma

def __str__(self):
'''Returns a pretty-printed object representation.'''
return ('\n'.join((
Expand All @@ -155,4 +165,3 @@ def __str__(self):
' beta : {uc.beta}',
' gamma : {uc.gamma}',
))).format(uc=self)

12 changes: 0 additions & 12 deletions ispyb/model/test_unitcell.py

This file was deleted.

28 changes: 28 additions & 0 deletions tests/model/test_unitcell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from __future__ import absolute_import, division, print_function

import ispyb.model.integration
import pytest

def test_unitcell_input_values_equals_output_values():
uc = ispyb.model.integration.UnitCell(10,20,30,40,50,60)
assert uc.a == 10
assert uc.b == 20
assert uc.c == 30
assert uc.alpha == 40
assert uc.beta == 50
assert uc.gamma == 60

def test_unitcell_values_are_immutable():
uc = ispyb.model.integration.UnitCell(10,20,30,40,50,60)
with pytest.raises(AttributeError):
uc.a = 1
with pytest.raises(AttributeError):
uc.b = 1
with pytest.raises(AttributeError):
uc.c = 1
with pytest.raises(AttributeError):
uc.alpha = 1
with pytest.raises(AttributeError):
uc.beta = 1
with pytest.raises(AttributeError):
uc.gamma = 1

0 comments on commit 789df20

Please sign in to comment.