Skip to content

Instantly share code, notes, and snippets.

@shelling
Created January 27, 2010 10:24
Show Gist options
  • Select an option

  • Save shelling/287716 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/287716 to your computer and use it in GitHub Desktop.
using numpy.ndarray to construct Plane class
#!/usr/bin/env python
#-*- mode: python -*-
import numpy
class Plane(numpy.ndarray):
"""
"""
def __new__(cls, abuffer):
abuffer = numpy.array(abuffer, dtype="float128")
if len(abuffer.shape) == 2:
return numpy.ndarray.__new__(cls, abuffer.shape, "float128", abuffer)
else:
pass
def __array_finalize__(self, obj):
pass
@property
def name(self, name):
self.name = name
return self
p = Plane([[1,2,],[3,4]])
print p
print p.shape
print p.dtype
print p.__class__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment