Shape¶
-
class
sisl.shape.
Shape
(center)¶ Bases:
object
Baseclass for all shapes. Logical operations are implemented on this class.
This class must be sub classed.
Also all the required methods are predefined although they issue an error if they are not implemented in the sub-classed class.
There are a few routines that are necessary when implementing an inherited class:
center
return the geometric center of the shape.
within
Returns a boolean array which defines whether a coordinate is within or outside the shape.
within_index
Equivalent to
within
, however only the indices of those within are returned.copy
Create a new identical shape.
The minimal requirement a shape can have are the above attributes.
Subclassed shapes may have additional methods by which they are defined.
Any
Shape
may be used to construct other shapes by applying set operations. Currently implemented binary operators are:__or__
/__add__
: set union, either | or + operator (not or)__and__
: set intersection, & operator (not and)__sub__
: set complement, - operator__xor__
: set disjunctive union, ^ operator- Parameters
center ((3,)) – the center of the shape
Attributes
__doc__
__module__
__slots__
_center
The geometric center of the shape
Methods
__add__
(other)__and__
(other)__contains__
(other)Checks whether all of other is within the shape
__delattr__
Implement delattr(self, name).
__dir__
Default dir() implementation.
__eq__
Return self==value.
__format__
Default object formatter.
__ge__
Return self>=value.
__getattribute__
Return getattr(self, name).
__gt__
Return self>value.
__hash__
Return hash(self).
__init__
(center)Initialize self.
__init_subclass__
This method is called when a class is subclassed.
__le__
Return self<=value.
__lt__
Return self<value.
__ne__
Return self!=value.
__new__
Create and return a new object.
__or__
(other)__reduce__
Helper for pickle.
__reduce_ex__
Helper for pickle.
__repr__
Return repr(self).
__setattr__
Implement setattr(self, name, value).
__sizeof__
Size of object in memory, in bytes.
__str__
()Return str(self).
__sub__
(other)__subclasshook__
Abstract classes can override this to customize issubclass().
__xor__
(other)scale
(scale)Return a new Shape with a scaled size
toCuboid
()Create a cuboid which is surely encompassing the full shape
Create an ellipsoid which is surely encompassing the full shape
toSphere
()Create a sphere which is surely encompassing the full shape
within
(other, *args, **kwargs)Return
True
if other is fully within selfwithin_index
(other, *args, **kwargs)Return indices of the elements of other that are within the shape
-
property
center
¶ The geometric center of the shape
-
within
(other, *args, **kwargs)[source]¶ Return
True
if other is fully within selfIf other is an array, an array will be returned for each of these.
- Parameters
other (array_like) – the array/object that is checked for containment
*args – passed directly to
within_index
**kwargs – passed directly to
within_index