
Hi, I have a quick question: Is there a way to get a list of all available Numpy integer dtypes programatically? thanks, V-

On Fri, Aug 9, 2013 at 11:06 PM, Valentin Haenel <valentin@haenel.co> 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] -- Robert Kern

Hi, On Fri, Aug 9, 2013 at 3:17 PM, Robert Kern <robert.kern@gmail.com> wrote:
On Fri, Aug 9, 2013 at 11:06 PM, Valentin Haenel <valentin@haenel.co> 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

Hi, * Matthew Brett <matthew.brett@gmail.com> [2013-08-10]:
On Fri, Aug 9, 2013 at 3:17 PM, Robert Kern <robert.kern@gmail.com> wrote:
On Fri, Aug 9, 2013 at 11:06 PM, Valentin Haenel <valentin@haenel.co> wrote:
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):
[snip
or (at least for the standard int dtypes):
np.sctypes['int'] + np.sctypes['uint']
Thanks Matthew and Robert. That was very helpful. V-
participants (3)
-
Matthew Brett
-
Robert Kern
-
Valentin Haenel