class Superell(Primitive): def __init__(self,name, center=(0, 0, 0), a=(1, 0, 0), b=(0, 1, 0), c=(0, 0, 1), n=0, e=0, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy) self.a = Vector(a, copy) self.b = Vector(b, copy) self.c = Vector(c, copy) self.n = n self.e = e def __repr__(self): result = "{}({}, v={}, a={}, b={}, c={}, n={}, e={} )" return result.format( self.__class__.__name__, self.name, repr(self.center), repr(self.a), repr(self.b), repr(self.c), self.n, self.e ) def update_params(self, params): params.update({ "center": self.center, "a": self.a, "b": self.b, "c": self.c, "n": self.n, "e": self.e }) def copy(self): return Superell(self.name, self.center, self.a, self.b, self.c, self.n, self.e, copy=True) def has_same_data(self, other): return self.e == other.e and \ self.n == other.n and \ self.center.is_same(other.center) and \ self.a.is_same(other.a) and \ self.b.is_same(other.b) and \ self.c.is_same(other.c) @staticmethod def from_wdb(name, data): return Superell( name=name, center=data.v, a=data.a, b=data.b, c=data.c, n=data.n, e=data.e, )
def check_tgc(self, name, expected_points): shape = self.lookup_shape(name) expected = Vector(expected_points) actual = cta.flatten_numbers( [shape.base, shape.height, shape.a, shape.b, shape.c, shape.d]) if not expected.is_same(actual): self.fail("{0} != {1}".format(expected, actual))
class Grip(Primitive): def __init__(self, name, center=(0, 0, 0), normal=(1, 0, 0), magnitude=1, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.normal = Vector(normal, copy=copy) self.magnitude = magnitude def __repr__(self): result = "{}({}, center={}, normal={}, magnitude={})" return result.format(self.__class__.__name__, self.name, self.center, self.normal, self.magnitude) def update_params(self, params): params.update({ "center": self.center, "normal": self.normal, "magnitude": self.magnitude }) def copy(self): return Grip(self.name, self.center, self.normal, self.magnitude, copy=True) def has_same_data(self, other): return self.center.is_same(other.center) and \ self.normal.is_same(other.normal) and \ self.magnitude == other.magnitude @staticmethod def from_wdb(name, data): return Grip(name=name, center=data.center, normal=data.normal, magnitude=data.mag)
class Grip(Primitive): def __init__(self, name, center=(0, 0, 0), normal=(1, 0, 0), magnitude=1, copy=False): Primitive.__init__(self, name=name) self.center = Vector(center, copy=copy) self.normal = Vector(normal, copy=copy) self.magnitude = magnitude def __repr__(self): result = "{}({}, center={}, normal={}, magnitude={})" return result.format( self.__class__.__name__, self.name, self.center, self.normal, self.magnitude ) def update_params(self, params): params.update({ "center": self.center, "normal": self.normal, "magnitude": self.magnitude }) def copy(self): return Grip(self.name, self.center, self.normal, self.magnitude, copy=True) def has_same_data(self, other): return self.center.is_same(other.center) and \ self.normal.is_same(other.normal) and \ self.magnitude == other.magnitude @staticmethod def from_wdb(name, data): return Grip( name=name, center=data.center, normal=data.normal, magnitude=data.mag )
class VOL(Primitive): def __init__( self, name, file_name, x_dim=1, y_dim=1, z_dim=1, low_thresh=0, high_thresh=128, cell_size=(1, 1, 1), mat=Transform.unit(), copy=False, ): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.x_dim = x_dim self.y_dim = y_dim self.z_dim = z_dim self.low_thresh = low_thresh self.high_thresh = high_thresh self.cell_size = Vector(cell_size, copy=copy) self.mat = Transform(mat, copy=copy, force=True) def __repr__(self): result = ( "{}({}, file_name={}, x_dim={}, y_dim={}, z_dim={}, " "low_thresh={}, high_thresh={} cell_size={}, mat={})" ) return result.format( self.__class__.__name__, self.file_name, self.name, self.x_dim, self.y_dim, self.z_dim, self.low_thresh, self.high_thresh, repr(self.cell_size), repr(self.mat), ) def update_params(self, params): params.update( { "file_name": self.file_name, "x_dim": self.x_dim, "y_dim": self.y_dim, "z_dim": self.z_dim, "low_thresh": self.low_thresh, "high_thresh": self.high_thresh, "cell_size": self.cell_size, "mat": self.mat, } ) def copy(self): return VOL( self.name, file_name=self.file_name, x_dim=self.x_dim, y_dim=self.y_dim, z_dim=self.z_dim, low_thresh=self.low_thresh, high_thresh=self.high_thresh, cell_size=self.cell_size, mat=self.mat, copy=True, ) def has_same_data(self, other): if not ( self.file_name == other.file_name, self.x_dim == other.x_dim and self.y_dim == other.y_dim and self.z_dim == other.z_dim and self.low_thresh == other.low_thresh and self.high_thresh == other.high_thresh, ): return False return self.cell_size.is_same(other.cell_size) and np.allclose(self.mat, other.mat) @staticmethod def from_wdb(name, data): return VOL( name=name, file_name=data.file, x_dim=data.xdim, y_dim=data.ydim, z_dim=data.zdim, low_thresh=data.lo, high_thresh=data.hi, cell_size=data.cellsize, mat=cta.transform_from_pointer(data.mat), )
class VOL(Primitive): def __init__(self, name, file_name, x_dim=1, y_dim=1, z_dim=1, low_thresh=0, high_thresh=128, cell_size=(1, 1, 1), mat=Transform.unit(), copy=False): Primitive.__init__(self, name=name) if not os.path.isfile(file_name): raise ValueError("File {} does not exist !".format(file_name)) self.file_name = file_name self.x_dim = x_dim self.y_dim = y_dim self.z_dim = z_dim self.low_thresh = low_thresh self.high_thresh = high_thresh self.cell_size = Vector(cell_size, copy=copy) self.mat = Transform(mat, copy=copy, force=True) def __repr__(self): result = "{}({}, file_name={}, x_dim={}, y_dim={}, z_dim={}, " \ "low_thresh={}, high_thresh={} cell_size={}, mat={})" return result.format(self.__class__.__name__, self.file_name, self.name, self.x_dim, self.y_dim, self.z_dim, self.low_thresh, self.high_thresh, repr(self.cell_size), repr(self.mat)) def update_params(self, params): params.update({ "file_name": self.file_name, "x_dim": self.x_dim, "y_dim": self.y_dim, "z_dim": self.z_dim, "low_thresh": self.low_thresh, "high_thresh": self.high_thresh, "cell_size": self.cell_size, "mat": self.mat }) def copy(self): return VOL(self.name, file_name=self.file_name, x_dim=self.x_dim, y_dim=self.y_dim, z_dim=self.z_dim, low_thresh=self.low_thresh, high_thresh=self.high_thresh, cell_size=self.cell_size, mat=self.mat, copy=True) def has_same_data(self, other): if not (self.file_name == other.file_name, self.x_dim == other.x_dim and self.y_dim == other.y_dim and self.z_dim == other.z_dim and self.low_thresh == other.low_thresh and self.high_thresh == other.high_thresh): return False return self.cell_size.is_same(other.cell_size) and np.allclose( self.mat, other.mat) @staticmethod def from_wdb(name, data): return VOL(name=name, file_name=data.file, x_dim=data.xdim, y_dim=data.ydim, z_dim=data.zdim, low_thresh=data.lo, high_thresh=data.hi, cell_size=data.cellsize, mat=cta.transform_from_pointer(data.mat))
def check_tgc(self, name, expected_points): shape = self.lookup_shape(name) expected = Vector(expected_points) actual = cta.flatten_numbers([shape.base, shape.height, shape.a, shape.b, shape.c, shape.d]) if not expected.is_same(actual): self.fail("{0} != {1}".format(expected, actual))
def check_arb(self, name, expected_points): shape = self.lookup_shape(name) expected = Vector(expected_points) if not expected.is_same(shape.points): self.fail("{0} != {1}".format(expected, shape.points))
def test_arbn_defaults(self): shape = self.lookup_shape("arbn.s") expected = Vector((1, 0, 0, 1, -1, 0, 0, 1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 0, 1, 1, 0, 0, -1, 1)) self.assertTrue(expected.is_same(cta.flatten_numbers(shape.planes)))