Skip to content

Commit

Permalink
re-wrote Frame as subclass of MVArray
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenovic committed Oct 19, 2016
1 parent 70a4aab commit 85e527a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,10 +1640,13 @@ def meet(self, other, subspace=None):

return (self * subspace.inv()) | other

class Frame(np.ndarray):

class MVArray(np.ndarray):
'''
MultiVector Array
'''

def __new__(cls, input_array):
#obj = np.asarray(input_array).view(cls)
obj = np.empty(len(input_array), dtype=object)
obj[:] = input_array
obj = obj.view(cls)
Expand All @@ -1652,6 +1655,21 @@ def __new__(cls, input_array):
def __array_finalize__(self, obj):
if obj is None: return


class Frame(MVArray):
'''
A frame of vectors
'''
def __new__(cls, input_array):
if not np.all([k.grades()==[1] for k in input_array]):
raise TypeError('Frames must be made from vectors')

obj = MVArray.__new__(cls, input_array)
return obj

def __array_finalize__(self, obj):
if obj is None: return

@property
def En(self):
'''
Expand Down

0 comments on commit 85e527a

Please sign in to comment.