Hi, On Fri, Aug 9, 2013 at 3:17 PM, Robert Kern <[email protected]> wrote: > On Fri, Aug 9, 2013 at 11:06 PM, Valentin Haenel <[email protected]> wrote: >> >> Hi, >> >> I have a quick question: Is there a way to get a list of all available >> Numpy integer dtypes programatically? > > [~] > |8> def all_dtypes(cls): > ..> for sub in cls.__subclasses__(): > ..> try: > ..> sub(0) > ..> except TypeError: > ..> pass > ..> else: > ..> yield sub > ..> for subsub in all_dtypes(sub): > ..> yield subsub > ..> > > [~] > |10> list(all_dtypes(np.integer)) > [numpy.int8, > numpy.int16, > numpy.int32, > numpy.int64, > numpy.int64, > numpy.timedelta64, > numpy.uint8, > numpy.uint16, > numpy.uint32, > numpy.uint64, > numpy.uint64]
or (at least for the standard int dtypes): np.sctypes['int'] + np.sctypes['uint'] Cheers, Matthew _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
