Adapts the given AST into the shape that this gem expects
552562
def adapt(parsed_ast)
      parsed_data = {}

      # No data exists stored above feature level
      parsed_data['cuke_modeler_parsing_data'] = nil

      # Comments are stored on the feature in gherkin 3.x
      parsed_data['comments'] = []
      parsed_ast[:comments].each do |comment|
        adapt_comment!(comment)
      end
      parsed_data['comments'].concat(parsed_ast.delete(:comments))

      # An AST is just one feature
      adapt_feature!(parsed_ast)

      parsed_data['feature'] = parsed_ast

      [parsed_data]
    end
97750
def migrate_into_triple(belstr: str) -> str:
    """"""

    bo.ast = bel.lang.partialparse.get_ast_obj(belstr, "2.0.0")

    return migrate_ast(bo.ast).to_triple()
4684
def reshape_to_2d(arr):
  '''
  

  '''
  return arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
1280588
def eval_to_ast(self, e, n, extra_constraints=(), exact=None):
        
        return [ ast.bv.BVV(v, e.size()) for v in self.eval(e, n, extra_constraints=extra_constraints, exact=exact) ]
1151567
def translate(patterns, *, flags=0):
    """"""

    flags = _flag_transform(flags)
    return _wcparse.translate(_wcparse.split(patterns, flags), flags)
404887
function() {
            var args = slice.call(arguments);
            args.unshift(this);
            return _.extend.apply(this, args);
        }
912511
def reshape(self, shape: tf.TensorShape) -> 'TensorFluent':
        '''
        '''
        t = tf.reshape(self.tensor, shape)
        scope = self.scope.as_list()
        batch = self.batch
        return TensorFluent(t, scope, batch=batch)
469133
def adapt_example!(parsed_example, gathered_comments)
      # Saving off the original data
      parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))

      # Removing parsed data for child elements in order to avoid duplicating data
      parsed_example['cuke_modeler_parsing_data']['tags'] = nil
      parsed_example['cuke_modeler_parsing_data']['rows'] = nil

      if parsed_example['comments']
        parsed_example['cuke_modeler_parsing_data']['comments'] = nil
        gathered_comments.concat(parsed_example['comments'])
      end

      parsed_example['rows'].each do |row|
        adapt_table_row!(row, gathered_comments)
      end

      if parsed_example['tags']
        parsed_example['tags'].each do |tag|
          adapt_tag!(tag)
        end
      end
    end
252782
def transform(self, attrs):
        """"""
        self.collect(attrs)
        self.add_missing_implementations()
        self.fill_attrs(attrs)
337834
def extend(dset, array, **attrs):
    
    length = len(dset)
    if len(array) == 0:
        return length
    newlength = length + len(array)
    if array.dtype.name == 'object':  # vlen array
        shape = (newlength,) + preshape(array[0])
    else:
        shape = (newlength,) + array.shape[1:]
    dset.resize(shape)
    dset[length:newlength] = array
    for key, val in attrs.items():
        dset.attrs[key] = val
    return newlength
1185377
def reshape_z(z, dim_z, ndim):
    

    z = np.atleast_2d(z)
    if z.shape[1] == dim_z:
        z = z.T

    if z.shape != (dim_z, 1):
        raise ValueError('z must be convertible to shape ({}, 1)'.format(dim_z))

    if ndim == 1:
        z = z[:, 0]

    if ndim == 0:
        z = z[0, 0]

    return z
894399
def process_alias(line, to, from)
      AST::Alias.new line, to, from
    end
711124
def typeCompileAst(ast):
    
    children = list(ast.children)
    if ast.astType == 'op':
        retsig = ast.typecode()
        basesig = ''.join(x.typecode() for x in list(ast.children))
        # Find some operation that will work on an acceptable casting of args.
        for sig in sigPerms(basesig):
            value = (ast.value + '_' + retsig + sig).encode('ascii')
            if value in interpreter.opcodes:
                break
        else:
            for sig in sigPerms(basesig):
                funcname = (ast.value + '_' + retsig + sig).encode('ascii')
                if funcname in interpreter.funccodes:
                    value = ('func_%sn' % (retsig + sig)).encode('ascii')
                    children += [ASTNode('raw', 'none',
                                         interpreter.funccodes[funcname])]
                    break
            else:
                raise NotImplementedError(
                    "couldn't find matching opcode for '%s'"
                    % (ast.value + '_' + retsig + basesig))
        # First just cast constants, then cast variables if necessary:
        for i, (have, want) in enumerate(zip(basesig, sig)):
            if have != want:
                kind = typecode_to_kind[want]
                if children[i].astType == 'constant':
                    children[i] = ASTNode('constant', kind, children[i].value)
                else:
                    opname = "cast"
                    children[i] = ASTNode('op', kind, opname, [children[i]])
    else:
        value = ast.value
        children = ast.children
    return ASTNode(ast.astType, ast.astKind, value,
                   [typeCompileAst(c) for c in children])
782459
def flatten(self, shallow=None):
        
        return self._wrap(self._flatten(self.obj, shallow))
502159
def _fix_gemm(op_name, inputs, old_attr, proto_obj):
    """"""
    op_sym = getattr(symbol, op_name, None)
    alpha = float(old_attr.get('alpha', 1.0))
    beta = float(old_attr.get('beta', 1.0))
    trans_a = int(old_attr.get('transA', 0))
    trans_b = int(old_attr.get('transB', 0))
    if trans_a:
        inputs[0] = symbol.transpose(inputs[0], axes=(1, 0))
    if not trans_b:
        inputs[1] = symbol.transpose(inputs[1], axes=(1, 0))
    new_inputs = [alpha*inputs[0], inputs[1], beta*inputs[2]]
    new_attr = {'num_hidden' : proto_obj._params[inputs[2].name].shape[0]}
    return op_sym, new_attr, new_inputs
1108499
def _convert_to_ast(self, data_e, size_e=None):
        
        if type(data_e) is bytes:
            # Convert the string into a BVV, *regardless of endness*
            bits = len(data_e) * self.state.arch.byte_width
            data_e = self.state.solver.BVV(data_e, bits)
        elif type(data_e) is int:
            data_e = self.state.solver.BVV(data_e, size_e*self.state.arch.byte_width if size_e is not None
                                       else self.state.arch.bits)
        else:
            data_e = data_e.raw_to_bv()

        return data_e
494706
def applyStyleOnShape(self, shape, node, only_explicit=False):
        

        # RLG-specific: all RLG shapes
        "Apply style attributes of a sequence of nodes to an RL shape."

        # tuple format: (svgAttr, rlgAttr, converter, default)
        mappingN = (
            ("fill", "fillColor", "convertColor", "black"),
            ("fill-opacity", "fillOpacity", "convertOpacity", 1),
            ("fill-rule", "_fillRule", "convertFillRule", "nonzero"),
            ("stroke", "strokeColor", "convertColor", "none"),
            ("stroke-width", "strokeWidth", "convertLength", "1"),
            ("stroke-opacity", "strokeOpacity", "convertOpacity", 1),
            ("stroke-linejoin", "strokeLineJoin", "convertLineJoin", "0"),
            ("stroke-linecap", "strokeLineCap", "convertLineCap", "0"),
            ("stroke-dasharray", "strokeDashArray", "convertDashArray", "none"),
        )
        mappingF = (
            ("font-family", "fontName", "convertFontFamily", DEFAULT_FONT_NAME),
            ("font-size", "fontSize", "convertLength", "12"),
            ("text-anchor", "textAnchor", "id", "start"),
        )

        if shape.__class__ == Group:
            # Recursively apply style on Group subelements
            for subshape in shape.contents:
                self.applyStyleOnShape(subshape, node, only_explicit=only_explicit)
            return

        ac = self.attrConverter
        for mapping in (mappingN, mappingF):
            if shape.__class__ != String and mapping == mappingF:
                continue
            for (svgAttrName, rlgAttr, func, default) in mapping:
                svgAttrValue = ac.findAttr(node, svgAttrName)
                if svgAttrValue == '':
                    if only_explicit:
                        continue
                    else:
                        svgAttrValue = default
                if svgAttrValue == "currentColor":
                    svgAttrValue = ac.findAttr(node.getparent(), "color") or default
                try:
                    meth = getattr(ac, func)
                    setattr(shape, rlgAttr, meth(svgAttrValue))
                except (AttributeError, KeyError, ValueError):
                    pass
        if getattr(shape, 'fillOpacity', None) is not None and shape.fillColor:
            shape.fillColor.alpha = shape.fillOpacity