How to use the larray.core.array function in larray

To help you get started, we’ve selected a few larray 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 liam2 / liam2 / liam2 / expr.py View on Github external
filter_value = expr_eval(filter_expr, sub_context)
            assert isinstance(filter_value, (bool, np.bool_)) or \
                np.issubdtype(filter_value.dtype, np.bool_)

            if isinstance(expr_value, la.LArray):
                # ca craint, ce qui faut, c'est faire un guess axis sur la
                # première valeur valide puis utiliser le label de cet axe
                # là (ou faire un PGroup sur cet axe là), otherwise, we can
                # introduce duplicate keys
                # OR, I could replicate the first non-filtered key
                # it might be a bad key, but if so, it would break anyway
                always_good_key = expr_value.axes[0].labels[0]
                missing_value = get_default_value(expr_value)
                # print("good key", always_good_key)
                # print("type missing", missing_value, type(missing_value))
            elif isinstance(expr_value, la.core.array.LArrayPointsIndexer):
                always_good_key = expr_value.array.axes[0].labels[0]
                missing_value = get_default_value(expr_value.array)
                # print("type missing", missing_value, type(missing_value))
            elif isinstance(expr_value, np.ndarray):
                always_good_key = -1
                missing_value = get_default_value(expr_value)
            else:
                assert isinstance(expr_value, (tuple, list))
                always_good_key = -1
                missing_value = None

            def fixkey(orig_key, filter_value):
                if non_scalar_array(orig_key):
                    # print("orig_key", orig_key)
                    non_filtered_idx = filter_value.nonzero()[0]
                    if len(non_filtered_idx):