Creates a :class:`BumpSequence` object from an XDR Operation
        object.
342973
def from_xdr_object(cls, op_xdr_object):
        
        if not op_xdr_object.sourceAccount:
            source = None
        else:
            source = encode_check(
                'account', op_xdr_object.sourceAccount[0].ed25519).decode()

        bump_to = op_xdr_object.body.bumpSequenceOp.bumpTo
        return cls(source=source, bump_to=bump_to)
96124
def construct_xblock_from_class(self, cls, scope_ids, field_data=None, *args, **kwargs):
        
        return self.mixologist.mix(cls)(
            runtime=self,
            field_data=field_data,
            scope_ids=scope_ids,
            *args, **kwargs
        )
828665
def from_xdr_object(cls, op_xdr_object):
        
        if not op_xdr_object.sourceAccount:
            source = None
        else:
            source = encode_check(
                'account', op_xdr_object.sourceAccount[0].ed25519).decode()

        line = Asset.from_xdr_object(op_xdr_object.body.changeTrustOp.line)
        limit = Operation.from_xdr_amount(
            op_xdr_object.body.changeTrustOp.limit)

        return cls(source=source, asset=line, limit=limit)
486024
def new(self, operation='no operation', **kw):
        
        self_vars = vars(self).copy()
        del self_vars['operation']
        del self_vars['children']
        del self_vars['counts']
        del self_vars['_flush']
        new = self.__class__(operation)
        vars(new).update(self_vars)
        vars(new).update(kw)
        return new
220012
def create_rl_bin_method(op_name, klass, jacobians={}):
    
    # Make left and right versions.
    for prefix in ['r', '']:
        # This function will became the methods.
        op_modules = [operator, builtins]
        op_names = [op_name, op_name + '_']

        op_function_base = find_element(
            op_names,
            op_modules,
            error_on_fail=True)
        # many such functions do not take keyword arguments, so we need to wrap
        # them

        def op_function(a, b):
            return op_function_base(a, b)

        def new_method(self, other, prefix=prefix):
            if not check_special_methods():
                raise NotImplementedError(
                    'Special method %s called on %s, but special methods have been disabled. Set pymc.special_methods_available to True to enable them.' %
                    (op_name, str(self)))
            # This code will create one of two Deterministic objects.
            if prefix == 'r':
                parents = {'a': other, 'b': self}

            else:
                parents = {'a': self, 'b': other}
            jacobian_formats = {'a': 'broadcast_operation',
                                'b': 'broadcast_operation'}
            return pm.Deterministic(op_function,
                                    'A Deterministic returning the value of %s(%s,%s)' % (
                                        prefix + op_name, self.__name__, str(
                                            other)),
                                    '(' + '_'.join(
                                        [self.__name__,
                                         prefix + op_name,
                                         str(other)]) + ')',
                                    parents,
                                    trace=False,
                                    plot=False,
                                    jacobians=jacobians,
                                    jacobian_formats=jacobian_formats)
        # Convert the functions into methods for klass.
        new_method.__name__ = '__' + prefix + op_name + '__'
        setattr(
            klass,
            new_method.__name__,
            UnboundMethodType(
                new_method,
                None,
                klass))
1062229
def to_xdr_object(self):
        
        asset = self.asset.to_xdr_object()
        destination = account_xdr_object(self.destination)

        amount = Operation.to_xdr_amount(self.amount)

        payment_op = Xdr.types.PaymentOp(destination, asset, amount)
        self.body.type = Xdr.const.PAYMENT
        self.body.paymentOp = payment_op
        return super(Payment, self).to_xdr_object()
618141
def _hstack(self, Xs):
        
        types = set(type(X) for X in Xs)

        if self.sparse_output_:
            return sparse.hstack(Xs).tocsr()
        elif dd.Series in types or dd.DataFrame in types:
            with warnings.catch_warnings():
                warnings.filterwarnings("ignore", "Concatenating", UserWarning)
                return dd.concat(Xs, axis="columns")
        elif da.Array in types:
            # To allow compatibility with dask core 1.0.0, this is the `else`
            # part of the definition of the dask.array.hstack inlined.
            # The `then` branch is removed because _validate_output in
            # sklearn.compose.ColumnTransformer ensures ndim == 2, so the
            # check `all(x.ndim == 1 for x in Xs)` should always fail.
            #
            # Once dask.array.hstack supports allow_unknown_chunksizes,
            # changed this to da.hstack(Xs, allow_unknown_chunksizes=True)
            return da.concatenate(Xs, axis=1, allow_unknown_chunksizes=True)
        elif self.preserve_dataframe and (pd.Series in types or pd.DataFrame in types):
            return pd.concat(Xs, axis="columns")
        else:
            return np.hstack(Xs)
630670
def from_cli(cls, opt, strain):
        
        return cls(strain, segment_length=opt.segment_length,
                   segment_start_pad=opt.segment_start_pad,
                   segment_end_pad=opt.segment_end_pad,
                   trigger_start=opt.trig_start_time,
                   trigger_end=opt.trig_end_time,
                   filter_inj_only=opt.filter_inj_only,
                   injection_window=opt.injection_window,
                   allow_zero_padding=opt.allow_zero_padding)
698544
def bump(self, bump_part):
        """"""

        major, minor, patch, stage, n = tuple(self)

        # stage bump
        if bump_part not in {"major", "minor", "patch"}:

            if bump_part not in self.stages:
                raise ValueError(f"Unknown {bump_part} stage")

            # We can not bump from final stage to final again.
            if self.stage == "final" and bump_part == "final":
                raise ValueError(f"{self} is already in final stage.")

            # bump in the same stage (numeric part)
            if bump_part == self.stage:
                n += 1
            else:
                new_stage_number = tuple(self.stages).index(bump_part)

                # We can not bump to a previous stage
                if new_stage_number < self._stage_number:
                    raise ValueError(f"{bump_part} stage is previous to {self}")

                stage = bump_part
                n = 0
        else:
            # major, minor, or patch bump

            # Only version in final stage can do a major, minor or patch
            # bump
            if self.stage != "final":
                raise ValueError(
                    f"{self} is a pre-release version."
                    f" Can't do a {bump_part} version bump"
                )

            if bump_part == "major":
                major += 1
                minor, patch = 0, 0
            elif bump_part == "minor":
                minor += 1
                patch = 0
            else:
                patch += 1

        return Version(major=major, minor=minor, patch=patch, stage=stage, n=n)
1051015
def _simple_new(cls, values, name=None, dtype=None, **kwargs):
        
        if not hasattr(values, 'dtype'):
            if (values is None or not len(values)) and dtype is not None:
                values = np.empty(0, dtype=dtype)
            else:
                values = np.array(values, copy=False)
                if is_object_dtype(values):
                    values = cls(values, name=name, dtype=dtype,
                                 **kwargs)._ndarray_values

        if isinstance(values, (ABCSeries, ABCIndexClass)):
            # Index._data must always be an ndarray.
            # This is no-copy for when _values is an ndarray,
            # which should be always at this point.
            values = np.asarray(values._values)

        result = object.__new__(cls)
        result._data = values
        # _index_data is a (temporary?) fix to ensure that the direct data
        # manipulation we do in `_libs/reduction.pyx` continues to work.
        # We need access to the actual ndarray, since we're messing with
        # data buffers and strides. We don't re-use `_ndarray_values`, since
        # we actually set this value too.
        result._index_data = values
        result.name = name
        for k, v in kwargs.items():
            setattr(result, k, v)
        return result._reset_identity()
1046275
def from_xdr(cls, xdr):
        
        xdr_decoded = base64.b64decode(xdr)
        asset = Xdr.StellarXDRUnpacker(xdr_decoded)
        asset_xdr_object = asset.unpack_Asset()
        asset = Asset.from_xdr_object(asset_xdr_object)
        return asset
1184229
def new_unique_object(self, table_class, sequence_id=None, force_query=False, **kwargs):
        """"""
        from sqlalchemy.exc import IntegrityError
        from sqlalchemy.orm.exc import FlushError

        # If a sequence ID was specified, the caller is certain
        #  that there is no potential for conflicts,
        # so there is no need to commit here.
        if not sequence_id:
            commit = True
            sequence_id = self.next_sequence_id(table_class, force_query=force_query)
        else:
            commit = False

        o = table_class(
            d_vid=self.vid,
            **kwargs
        )

        o.update_id(sequence_id)

        if commit is False:
            return o

        self.commit()

        if self._database.driver == 'sqlite':
            # The Sqlite database can't have concurrency, so there no problem.
            self.session.add(o)
            self.commit()
            return o
        else: # Postgres. Concurrency is a bitch.
            table_name = table_class.__tablename__
            child_sequence_id = table_class.sequence_id.property.columns[0].name

        try:

            self.session.add(o)
            self.commit()
            return o

        except (IntegrityError, FlushError) as e:
            self.rollback()
            self.session.merge(self)
            print 'Failed'
            return None

        return
        # This is horrible, but it's the only thing that has worked for both
        # Sqlite and Postgres in both single processes and multiprocesses.
        d_vid = self.vid
        while True:
            try:
                self.session.add(o)
                self.commit()
                return o

            except (IntegrityError, FlushError) as e:

                self.rollback()

                self.session.expunge_all()
                ds = self._database.dataset(d_vid)
                sequence_id = ds.next_sequence_id(table_class, force_query=True)

                o.update_id(sequence_id)

            except Exception as e:

                print('Completely failed to get a new {} sequence_id; {}'.format(table_class, e))
                self.rollback()
                import traceback

                # This bit is helpful in a multiprocessing run.
                tb = traceback.format_exc()

                print(tb)
                raise
200390
def from_sequence(chain, list_of_residues, sequence_type = None):
        ''''''
        s = Sequence(sequence_type)
        count = 1
        for ResidueAA in list_of_residues:
            s.add(Residue(chain, count, ResidueAA, sequence_type))
            count += 1
        return s
1136912
def from_xdr_object(cls, op_xdr_object):
        
        if not op_xdr_object.sourceAccount:
            source = None
        else:
            source = encode_check(
                'account', op_xdr_object.sourceAccount[0].ed25519).decode()

        selling = Asset.from_xdr_object(
            op_xdr_object.body.createPassiveOfferOp.selling)
        buying = Asset.from_xdr_object(
            op_xdr_object.body.createPassiveOfferOp.buying)
        amount = Operation.from_xdr_amount(
            op_xdr_object.body.createPassiveOfferOp.amount)

        n = op_xdr_object.body.createPassiveOfferOp.price.n
        d = op_xdr_object.body.createPassiveOfferOp.price.d
        price = division(n, d)
        return cls(
            source=source,
            selling=selling,
            buying=buying,
            amount=amount,
            price=price)
210342
def from_record(cls, record, crs):
        """"""
        if 'type' not in record:
            raise TypeError("The data isn't a valid record.")

        return cls(to_shape(record), crs)
999588
def step_preprocess(x, step, hparams):
  
  original_channel_size = common_layers.shape_list(x)[-1]

  if hparams.add_position_timing_signal:
    x = add_position_timing_signal(x, step, hparams)

  if hparams.add_step_timing_signal:
    x = add_step_timing_signal(x, step, hparams)

  if ((hparams.add_position_timing_signal or hparams.add_position_timing_signal)
      and hparams.add_or_concat_timing_signal == "concat"):
    # linear projection to the original dimension of x
    x = common_layers.dense(
        x, original_channel_size, activation=None, use_bias=False)

  if hparams.add_sru:
    x = common_layers.sru(x)

  return x
1357346
def from_xdr_object(cls, op_xdr_object):
        
        if not op_xdr_object.sourceAccount:
            source = None
        else:
            source = encode_check(
                'account', op_xdr_object.sourceAccount[0].ed25519).decode()

        destination = encode_check(
            'account',
            op_xdr_object.body.pathPaymentOp.destination.ed25519).decode()
        send_asset = Asset.from_xdr_object(
            op_xdr_object.body.pathPaymentOp.sendAsset)
        dest_asset = Asset.from_xdr_object(
            op_xdr_object.body.pathPaymentOp.destAsset)
        send_max = Operation.from_xdr_amount(
            op_xdr_object.body.pathPaymentOp.sendMax)
        dest_amount = Operation.from_xdr_amount(
            op_xdr_object.body.pathPaymentOp.destAmount)

        path = []
        if op_xdr_object.body.pathPaymentOp.path:
            for x in op_xdr_object.body.pathPaymentOp.path:
                path.append(Asset.from_xdr_object(x))

        return cls(
            source=source,
            destination=destination,
            send_asset=send_asset,
            send_max=send_max,
            dest_asset=dest_asset,
            dest_amount=dest_amount,
            path=path)