lale/lib/lale/concat_features.py
def transform_schema(self, s_X):
        """Used internally by Lale for type-checking downstream operators."""
        min_cols, max_cols, elem_schema = 0, 0, None

        def add_ranges(min_a, max_a, min_b, max_b):
            min_ab = min_a + min_b
            if max_a == "unbounded" or max_b == "unbounded":
                max_ab = "unbounded"
            else:
                max_ab = max_a + max_b
            return min_ab, max_ab

        elem_schema: Optional[JSON_TYPE] = None
        for s_dataset in s_X["items"]:
            if s_dataset.get("laleType", None) == "Any":
                return {"laleType": "Any"}
            arr_1d_num = {"type": "array", "items": {"type": "number"}}
            arr_2d_num = {"type": "array", "items": arr_1d_num}
            s_decision_func = {"anyOf": [arr_1d_num, arr_2d_num]}
            if lale.type_checking.is_subschema(s_decision_func, s_dataset):
                s_dataset = arr_2d_num
            assert "items" in s_dataset, lale.pretty_print.to_string(s_dataset)
            s_rows = s_dataset["items"]
            if "type" in s_rows and "array" == s_rows["type"]:
                s_cols = s_rows["items"]
                if isinstance(s_cols, dict):
                    min_c = s_rows["minItems"] if "minItems" in s_rows else 1
                    max_c = s_rows["maxItems"] if "maxItems" in s_rows else "unbounded"
                    if elem_schema is None:
                        elem_schema = s_cols
                    else:
                        elem_schema = lale.type_checking.join_schemas(
                            elem_schema, s_cols
                        )
                else:
                    min_c, max_c = len(s_cols), len(s_cols)
                    for s_col in s_cols:
                        if elem_schema is None:
                            elem_schema = s_col
                        else:
                            elem_schema = lale.type_checking.join_schemas(
                                elem_schema, s_col
                            )
                min_cols, max_cols = add_ranges(min_cols, max_cols, min_c, max_c)
            else:
                if elem_schema is None:
                    elem_schema = s_rows
                else:
                    elem_schema = lale.type_checking.join_schemas(elem_schema, s_rows)
                min_cols, max_cols = add_ranges(min_cols, max_cols, 1, 1)
        s_result = {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "array",
            "items": {"type": "array", "minItems": min_cols, "items": elem_schema},
        }
        if max_cols != "unbounded":
            s_result["items"]["maxItems"] = max_cols
        lale.type_checking.validate_is_schema(s_result)
        return s_result
Used internally by Lale for type-checking downstream operators.
Used internally by Lale for type-checking downstream operators.
Used internally by Lale for type - checking downstream operators .
def transform_schema(self, s_X):
        min_cols, max_cols, elem_schema = 0, 0, None
        def add_ranges(min_a, max_a, min_b, max_b):
            min_ab = min_a + min_b
            if max_a == "unbounded" or max_b == "unbounded":
                max_ab = "unbounded"
            else:
                max_ab = max_a + max_b
            return min_ab, max_ab
        elem_schema: Optional[JSON_TYPE] = None
        for s_dataset in s_X["items"]:
            if s_dataset.get("laleType", None) == "Any":
                return {"laleType": "Any"}
            arr_1d_num = {"type": "array", "items": {"type": "number"}}
            arr_2d_num = {"type": "array", "items": arr_1d_num}
            s_decision_func = {"anyOf": [arr_1d_num, arr_2d_num]}
            if lale.type_checking.is_subschema(s_decision_func, s_dataset):
                s_dataset = arr_2d_num
            assert "items" in s_dataset, lale.pretty_print.to_string(s_dataset)
            s_rows = s_dataset["items"]
            if "type" in s_rows and "array" == s_rows["type"]:
                s_cols = s_rows["items"]
                if isinstance(s_cols, dict):
                    min_c = s_rows["minItems"] if "minItems" in s_rows else 1
                    max_c = s_rows["maxItems"] if "maxItems" in s_rows else "unbounded"
                    if elem_schema is None:
                        elem_schema = s_cols
                    else:
                        elem_schema = lale.type_checking.join_schemas(
                            elem_schema, s_cols
                        )
                else:
                    min_c, max_c = len(s_cols), len(s_cols)
                    for s_col in s_cols:
                        if elem_schema is None:
                            elem_schema = s_col
                        else:
                            elem_schema = lale.type_checking.join_schemas(
                                elem_schema, s_col
                            )
                min_cols, max_cols = add_ranges(min_cols, max_cols, min_c, max_c)
            else:
                if elem_schema is None:
                    elem_schema = s_rows
                else:
                    elem_schema = lale.type_checking.join_schemas(elem_schema, s_rows)
                min_cols, max_cols = add_ranges(min_cols, max_cols, 1, 1)
        s_result = {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "array",
            "items": {"type": "array", "minItems": min_cols, "items": elem_schema},
        }
        if max_cols != "unbounded":
            s_result["items"]["maxItems"] = max_cols
        lale.type_checking.validate_is_schema(s_result)
        return s_result
def transform_schema ( self , s_X ) : min_cols , max_cols , elem_schema = 0 , 0 , None def add_ranges ( min_a , max_a , min_b , max_b ) : min_ab = min_a + min_b if max_a == "unbounded" or max_b == "unbounded" : max_ab = "unbounded" else : max_ab = max_a + max_b return min_ab , max_ab elem_schema : Optional [ JSON_TYPE ] = None for s_dataset in s_X [ "items" ] : if s_dataset . get ( "laleType" , None ) == "Any" : return { "laleType" : "Any" } arr_1d_num = { "type" : "array" , "items" : { "type" : "number" } } arr_2d_num = { "type" : "array" , "items" : arr_1d_num } s_decision_func = { "anyOf" : [ arr_1d_num , arr_2d_num ] } if lale . type_checking . is_subschema ( s_decision_func , s_dataset ) : s_dataset = arr_2d_num assert "items" in s_dataset , lale . pretty_print . to_string ( s_dataset ) s_rows = s_dataset [ "items" ] if "type" in s_rows and "array" == s_rows [ "type" ] : s_cols = s_rows [ "items" ] if isinstance ( s_cols , dict ) : min_c = s_rows [ "minItems" ] if "minItems" in s_rows else 1 max_c = s_rows [ "maxItems" ] if "maxItems" in s_rows else "unbounded" if elem_schema is None : elem_schema = s_cols else : elem_schema = lale . type_checking . join_schemas ( elem_schema , s_cols ) else : min_c , max_c = len ( s_cols ) , len ( s_cols ) for s_col in s_cols : if elem_schema is None : elem_schema = s_col else : elem_schema = lale . type_checking . join_schemas ( elem_schema , s_col ) min_cols , max_cols = add_ranges ( min_cols , max_cols , min_c , max_c ) else : if elem_schema is None : elem_schema = s_rows else : elem_schema = lale . type_checking . join_schemas ( elem_schema , s_rows ) min_cols , max_cols = add_ranges ( min_cols , max_cols , 1 , 1 ) s_result = { "$schema" : "http://json-schema.org/draft-04/schema#" , "type" : "array" , "items" : { "type" : "array" , "minItems" : min_cols , "items" : elem_schema } , } if max_cols != "unbounded" : s_result [ "items" ] [ "maxItems" ] = max_cols lale . type_checking . validate_is_schema ( s_result ) return s_result
Used internally by Lale for type-checking downstream operators.
Used internally by Lale for type - checking downstream operators .
"""Used internally by Lale for type-checking downstream operators."""
self
s_X