How to use the clu.typespace.namespace.Namespace function in clu

To help you get started, we’ve selected a few clu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fish2000 / instakit / instakit / utils / misc.py View on Github external
import six
except ImportError:
    class FakeSix(object):
        @property
        def string_types(self):
            return tuple()
    six = FakeSix()

export(wrap_value,              name='wrap_value')
export(none_function,           name='none_function')
export(tuplize,                 name='tuplize')
export(uniquify,                name='uniquify')
export(listify,                 name='listify')

export(SimpleNamespace)
export(Namespace)

export(stringify,               name='stringify')
export(string_types)
export(byte_types)

export(suffix_searcher)
export(u8encode)
export(u8bytes)
export(u8str)

# Assign the modules’ `__all__` and `__dir__` using the exporter:
__all__, __dir__ = exporter.all_and_dir()
github fish2000 / instakit / instakit / utils / mode.py View on Github external
import contextlib
import numpy
import os

from PIL import Image, ImageMode
from enum import auto, unique

from clu.constants.consts import DEBUG, ENCODING
from clu.enums import alias, AliasingEnum
from clu.naming import split_abbreviations
from clu.predicates import attr, getpyattr, isclasstype, or_none
from clu.typespace.namespace import Namespace
from clu.typology import string_types

junkdrawer = Namespace()
junkdrawer.imode = lambda image: ImageMode.getmode(image.mode)

ImageMode.getmode('RGB') # one call must be made to getmode()
                         # to properly initialize ImageMode._modes:

junkdrawer.modes = ImageMode._modes
junkdrawer.types = Image._MODE_CONV
junkdrawer.ismap = Image._MAPMODES

mode_strings = tuple(junkdrawer.modes.keys())
dtypes_for_modes = { k : v[0] for k, v in junkdrawer.types.items() }

junkdrawer.idxmode = lambda idx: ImageMode.getmode(mode_strings[idx])
junkdrawer.is_mapped = lambda mode: mode in junkdrawer.ismap

class ModeAncestor(AliasingEnum):