function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def one_drop(self, one_drop): assert_is_type(one_drop, None, bool) self._parms["one_drop"] = one_drop
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def skip_drop(self): """ For booster=dart only: skip_drop (0..1) Type: ``float`` (default: ``0``). """ return self._parms.get("skip_drop")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def skip_drop(self, skip_drop): assert_is_type(skip_drop, None, float) self._parms["skip_drop"] = skip_drop
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def tree_method(self): """ Tree method One of: ``"auto"``, ``"exact"``, ``"approx"``, ``"hist"`` (default: ``"auto"``). """ return self._parms.get("tree_method")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def tree_method(self, tree_method): assert_is_type(tree_method, None, Enum("auto", "exact", "approx", "hist")) self._parms["tree_method"] = tree_method
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def grow_policy(self): """ Grow policy - depthwise is standard GBM, lossguide is LightGBM One of: ``"depthwise"``, ``"lossguide"`` (default: ``"depthwise"``). """ return self._parms.get("grow_policy")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def grow_policy(self, grow_policy): assert_is_type(grow_policy, None, Enum("depthwise", "lossguide")) self._parms["grow_policy"] = grow_policy
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def booster(self): """ Booster type One of: ``"gbtree"``, ``"gblinear"``, ``"dart"`` (default: ``"gbtree"``). """ return self._parms.get("booster")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def booster(self, booster): assert_is_type(booster, None, Enum("gbtree", "gblinear", "dart")) self._parms["booster"] = booster
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def reg_lambda(self): """ L2 regularization Type: ``float`` (default: ``1``). """ return self._parms.get("reg_lambda")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def reg_lambda(self, reg_lambda): assert_is_type(reg_lambda, None, float) self._parms["reg_lambda"] = reg_lambda
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def reg_alpha(self): """ L1 regularization Type: ``float`` (default: ``0``). """ return self._parms.get("reg_alpha")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def reg_alpha(self, reg_alpha): assert_is_type(reg_alpha, None, float) self._parms["reg_alpha"] = reg_alpha
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def dmatrix_type(self): """ Type of DMatrix. For sparse, NAs and 0 are treated equally. One of: ``"auto"``, ``"dense"``, ``"sparse"`` (default: ``"auto"``). """ return self._parms.get("dmatrix_type")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def dmatrix_type(self, dmatrix_type): assert_is_type(dmatrix_type, None, Enum("auto", "dense", "sparse")) self._parms["dmatrix_type"] = dmatrix_type
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def backend(self): """ Backend. By default (auto), a GPU is used if available. One of: ``"auto"``, ``"gpu"``, ``"cpu"`` (default: ``"auto"``). """ return self._parms.get("backend")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def backend(self, backend): assert_is_type(backend, None, Enum("auto", "gpu", "cpu")) self._parms["backend"] = backend
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def gpu_id(self): """ Which GPU to use. Type: ``int`` (default: ``0``). """ return self._parms.get("gpu_id")
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def gpu_id(self, gpu_id): assert_is_type(gpu_id, None, int) self._parms["gpu_id"] = gpu_id
h2oai/h2o-dev
[ 6169, 1943, 6169, 208, 1393862887 ]
def __init__( self, type: OperationType, create_account_op: CreateAccountOp = None, payment_op: PaymentOp = None, path_payment_strict_receive_op: PathPaymentStrictReceiveOp = None, manage_sell_offer_op: ManageSellOfferOp = None, create_passive_sell_offer_op: Creat...
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def pack(self, packer: Packer) -> None: self.type.pack(packer) if self.type == OperationType.CREATE_ACCOUNT: if self.create_account_op is None: raise ValueError("create_account_op should not be None.") self.create_account_op.pack(packer) return ...
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def unpack(cls, unpacker: Unpacker) -> "OperationBody": type = OperationType.unpack(unpacker) if type == OperationType.CREATE_ACCOUNT: create_account_op = CreateAccountOp.unpack(unpacker) return cls(type=type, create_account_op=create_account_op) if type == OperationType....
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def from_xdr_bytes(cls, xdr: bytes) -> "OperationBody": unpacker = Unpacker(xdr) return cls.unpack(unpacker)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def from_xdr(cls, xdr: str) -> "OperationBody": xdr_bytes = base64.b64decode(xdr.encode()) return cls.from_xdr_bytes(xdr_bytes)
StellarCN/py-stellar-base
[ 328, 158, 328, 6, 1443187561 ]
def expression(symbolAction, nextState): #expression ::= | pathitem pathtail #pathitem ::= | "(" pathlist ")" # | "[" propertylist "]" # | "{" formulacontent "}" # | boolean # | literal # | numericliteral # ...
gniezen/n3pygments
[ 22, 6, 22, 3, 1327326868 ]
def series_rolling_median(): series = pd.Series([4, 3, 5, 2, 6]) # Series of 4, 3, 5, 2, 6 out_series = series.rolling(3).median() return out_series # Expect series of NaN, NaN, 4.0, 3.0, 5.0
IntelLabs/hpat
[ 645, 65, 645, 54, 1496336381 ]
def Xval_on_single_patient(predictor_cls, feature_extractor, patient_name="Dog_1",preprocess=True): """ Single patient cross validation Returns 2 lists of cross validation performances :param predictor_cls: :param feature_extractor :param patient_name: :return: """ # predictor_cls is...
vincentadam87/gatsby-hackathon-seizure
[ 3, 1, 3, 5, 1403950691 ]
def main(): # code run at script launch #patient_name = sys.argv[1] # There are Dog_[1-4] and Patient_[1-8] patients_list = ["Dog_%d" % i for i in range(1, 5)] + ["Patient_%d" % i for i in range(1, 9)] patients_list = ["Dog_%d" % i for i in [1]] #["Patient_%d" % i for i in range(1, 9)]#++
vincentadam87/gatsby-hackathon-seizure
[ 3, 1, 3, 5, 1403950691 ]
def generate(env): """Add Builders and construction variables for ar to an Environment.""" SCons.Tool.createStaticLibBuilder(env)
kerwinxu/barcodeManager
[ 4, 1, 4, 3, 1447294107 ]
def exists(env): return env.Detect('CC') or env.Detect('ar')
kerwinxu/barcodeManager
[ 4, 1, 4, 3, 1447294107 ]
def test_install_packages(): d = dun.CreateDummy() d() package.install_package('./dummy/dummytest_1.0.0.tar.gz', verbose=True) d._clean()
biokit/biokit
[ 47, 22, 47, 13, 1410258271 ]
def test_get_r_version(): package.get_R_version()
biokit/biokit
[ 47, 22, 47, 13, 1410258271 ]
def forwards(self, orm): # Changing field 'Student.student_id' db.alter_column('publications_student', 'student_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=12))
evildmp/arkestra-publications
[ 2, 3, 2, 6, 1320326961 ]
def forwards(self, orm): # Adding field 'Face.district_id' db.add_column(u'faces_face', 'district_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['faces.District'], null=True), keep_default=False)
RuralIndia/pari
[ 22, 9, 22, 39, 1360646573 ]
def __init__(self, input=None, n_visible=784, n_hidden=500, \ W=None, hbias=None, vbias=None, numpy_rng=None, theano_rng=None): """ RBM constructor. Defines the parameters of the model along with basic operations for inferring hidden from visible (and vice-versa), as well...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def propup(self, vis): '''This function propagates the visible units activation upwards to the hidden units Note that we return also the pre-sigmoid activation of the layer. As it will turn out later, due to how Theano deals with optimizations, this symbolic variable will be nee...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def propdown(self, hid): '''This function propagates the hidden units activation downwards to the visible units Note that we return also the pre_sigmoid_activation of the layer. As it will turn out later, due to how Theano deals with optimizations, this symbolic variable will be...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def gibbs_hvh(self, h0_sample): ''' This function implements one step of Gibbs sampling, starting from the hidden state''' pre_sigmoid_v1, v1_mean, v1_sample = self.sample_v_given_h(h0_sample) pre_sigmoid_h1, h1_mean, h1_sample = self.sample_h_given_v(v1_sample) return [pre_s...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def get_cost_updates(self, lr=0.1, persistent=None, k=1): """This functions implements one step of CD-k or PCD-k :param lr: learning rate used to train the RBM :param persistent: None for CD. For PCD, shared variable containing old state of Gibbs chain. This must be a shared ...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def get_reconstruction_cost(self, updates, pre_sigmoid_nv): """Approximation to the reconstruction error Note that this function requires the pre-sigmoid activation as input. To understand why this is so you need to understand a bit about how Theano works. Whenever you compile a Theano...
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def test_model(model_trained,test_set_x_org=None): """ Get the reduced data using the model learned.
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def sample_model(rng,model_trained,test_set_x_org=None,n_chains=20,n_samples=10,sample_gap=1000): """ Sample from the trained RBM given some actual examples to initialize the algorithm.
yifeng-li/DECRES
[ 33, 13, 33, 5, 1434585720 ]
def is_valid(self, raise_exception=True): result = super().is_valid(raise_exception=raise_exception) if result: if not self.phone_number or PHONE_NUMBER_REGEXP and not re.match(PHONE_NUMBER_REGEXP, self.phone_number): if not raise_exception: return False ...
thorgate/django-esteid
[ 19, 2, 19, 3, 1445964219 ]
def format(self, value): self._format = value return self
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def input(self, text): self._input = self._params["input"] = text return self
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def categories(self, tree_key=None, additionals=None): params = dict(additionals or []) if tree_key is not None: params.update(dict(tree_key=tree_key))
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def keywords(self): self._functions["keywords"] = True return self
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def entities(self): self._functions["entities"] = True return self
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def language(self): self._functions["language"] = True return self
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def meaningfy(self): fs = [] for k,v in self._functions.items(): kk = k if isinstance(v, dict): if v.has_key("additionals"): for a in v["additionals"]: kk = "%s+%s" % (kk, a) ...
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def _reset(self): self._functions = {} self._params = {}
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def get_builder(self): if self.__builder__ is None: self.__builder__ = NeocortexRestClient.Builder(self.BASE_URL, self.api_key).format(ResponseFormats.JSON)
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def categories(self, input, tree_key=None, additionals=None): builder = self.get_builder() return builder.format(ResponseFormats.JSON).input(input).categories(tree_key, additionals).meaningfy().payload["categories"]
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def entities(self, input): builder = self.get_builder() return builder.format(ResponseFormats.JSON).input(input).entities().meaningfy().payload["entities"]
popego/neocortex-api-python
[ 8, 2, 8, 1, 1262800862 ]
def setUp(self): super(BcryptTests, self).setUp() User.objects.create_user('john', 'johndoe@example.com', password='123456') User.objects.create_user('jane', 'janedoe@example.com', password='abc') User.objects.create_user(...
fwenzel/django-sha2
[ 109, 18, 109, 3, 1293582874 ]
def test_bcrypt_auth(self): """Try authenticating.""" assert authenticate(username='john', password='123456') assert authenticate(username='jane', password='abc') assert not authenticate(username='jane', password='123456') assert authenticate(username='jude', password=u'abcéäêëôø...
fwenzel/django-sha2
[ 109, 18, 109, 3, 1293582874 ]
def test_nokey(self): """With no HMAC key, no dice.""" assert not authenticate(username='john', password='123456') assert not authenticate(username='jane', password='abc') assert not authenticate(username='jane', password='123456') assert not authenticate(username='jude', passwor...
fwenzel/django-sha2
[ 109, 18, 109, 3, 1293582874 ]
def test_hmac_autoupdate(self): """Auto-update HMAC key if hash in DB is outdated.""" # Get HMAC key IDs to compare old_key_id = max(settings.HMAC_KEYS.keys()) new_key_id = '2020-01-01' # Add a new HMAC key new_keys = settings.HMAC_KEYS.copy() new_keys[new_key_id...
fwenzel/django-sha2
[ 109, 18, 109, 3, 1293582874 ]
def extractNotoriousOnlineBlogspotCom(item): ''' Parser for 'notorious-online.blogspot.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('PRC', 'PRC', 'translated'),...
fake-name/ReadableWebProxy
[ 191, 16, 191, 3, 1437712243 ]
def __init__(self, config, name): """ :type name: str """ self.config = config self.name = name
ThomasGerstenberg/serial_monitor
[ 9, 5, 9, 4, 1440644224 ]
def open(self): raise NotImplementedError
ThomasGerstenberg/serial_monitor
[ 9, 5, 9, 4, 1440644224 ]
def close(self): raise NotImplementedError
ThomasGerstenberg/serial_monitor
[ 9, 5, 9, 4, 1440644224 ]
def read(self, num_bytes=1): raise NotImplementedError
ThomasGerstenberg/serial_monitor
[ 9, 5, 9, 4, 1440644224 ]
def write(self, data): raise NotImplementedError
ThomasGerstenberg/serial_monitor
[ 9, 5, 9, 4, 1440644224 ]
def command_oraakkeli(bot, user, channel, args): """Asks a question from the oracle (http://www.lintukoto.net/viihde/oraakkeli/)""" if not args: return args = urllib.quote_plus(args) answer = getUrl("http://www.lintukoto.net/viihde/oraakkeli/index.php?kysymys=%s&html=0" % args).getContent() answe...
nigeljonez/newpyfibot
[ 8, 3, 8, 1, 1285336020 ]
def __unicode__(self): return unicode(self.user)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def get_absolute_url(self): return reverse('desktop.user', args=[self.user.username])
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def generic_sharing_url(self): url = urlparams(django_reverse('desktop.user', args=[self.user.username])) return absolute_url(url)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def _social_sharing_url(self, service): # django_reverse used instead of reverse because we don't want a locale preprended to sharing links. url = urlparams(django_reverse('desktop.user', args=[self.user.username]), f=service) retu...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def twitter_sharing_url(self): return self._social_sharing_url('t')
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def facebook_sharing_url(self): return self._social_sharing_url('fb')
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def poster_sharing_url(self): return self._social_sharing_url('p')
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def badges(self): """Returns a list of dicts used for badge list rendering. They represent all badges earned by the user in the Spark game. """ badges = [] completed_challenges = CompletedChallenge.objects.filter(profile=self, ...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def has_badge(self, badge_id): """Returns whether this user has earned the given badge.""" if badge_id: return CompletedChallenge.objects.filter(profile=self, challenge__pk=badge_id, date_badge_earned__isnull=False).count() == 1 else: ...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def total_badges_earned(self): """Returns the total number of badges earned by the user. Doesn't include hidden unlocked badges from an upper level. """ return CompletedChallenge.objects.filter(profile=self, date_badge_earned__isnull=False).count()
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def spark_started_with(self): if self.parent_username is not None: return self.parent_username return ''
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def most_recent_share(self): """Most recent share stat displayed on desktop dashboard/user pages.""" from stats.models import SharingHistory
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def shares_over_time(self): """Aggregate data of Spark shares since the start of the campaign. Used by the 'shares over time' diagram in the user dashboard. """ from stats.models import SharingHistory return SharingHistory.get_shares_over_time(self)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def sparked_countries(self): """List of countries this user has shared their Spark with.""" from .utils import user_node countries = set() node = user_node(self.user) for child in node.get_children(): cc = child.user.profile.country_code if cc: ...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def total_shares(self): """Total shares stat displayed on desktop dashboard/user pages.""" from stats.models import SharingHistory
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def challenge_info(self): """Returns a list of dicts containing level/challenge completion information. Used to render both desktop and mobile collapsing challenge lists. """ return utils.get_profile_levels(self)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def new_challenge_count(self): """Returns the number of newly available challenges in the user's current level.""" if self.new_challenges: challenge_count = utils.CHALLENGE_COUNT_PER_LVL[self.level-1] completed_challenge_count = len(CompletedChallenge.objects.filter(profile=self,...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def new_badge_count(self): """Returns the number of recently earned badges.""" return len([b for b in self.badges if b['new']])
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def qr_code_download(self): """Returns the URL of a QR code which, when scanned, points to: https://[domain]/download?f=qr&user=[username] """ url = absolute_url(urlparams(django_reverse('sharing.download'), user=self.user.username)) return sharing_utils.url2qr(url)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def continent_code(self): from geo.continents import countries_continents code = '' if self.country_code: code = countries_continents[self.country_code]
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def total_countries_sparked(self): """Returns the total number of countries where the user's children are located.""" return len(self.sparked_countries)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def total_continents_sparked(self): """Returns the total number of continents where the user's children are located.""" from geo.continents import countries_continents from .utils import user_node
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def children_profiles(self): """Returns a list of profiles of the user's children in the user tree.""" from .utils import user_node
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def clear_new_badges(self): """Clears notifications of recently earned badges.""" CompletedChallenge.objects.filter(profile=self, new_badge=True).update(new_badge=False)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def clear_new_challenges(self): """Clears notifications of new available challenges.""" self.new_challenges = False self.save()
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def trigger_multisparker_badge(self): from challenges.tasks import update_completed_challenges
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def update_ancestors_longest_chain(self): """Updates 'longest chain' stat of all ancestors of this user when relevant. Used after Boost step 2 confirmation so that all users involved have their longest chain stat updated. """ from .utils import user_node ancestors = user_node...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def add_city_shares_for_children(self): """Creates city shares in the CitySharingHistory for the global visualization. This is useful when a user already has children when he completes boost 1 (geolocation). As soon as it's completed, city shares are created for all geolocated children. ...
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def __unicode__(self): return "%s <-> %s" % (self.profile, self.challenge)
mozilla/spark
[ 5, 6, 5, 4, 1297724745 ]
def binarize_vector(u): return u > 0
mikekestemont/PyStyl
[ 55, 13, 55, 6, 1409592784 ]
def cosine_distance_binary(u, v): u = binarize_vector(u) v = binarize_vector(v) return (1.0 * (u * v).sum()) / numpy.sqrt((u.sum() * v.sum()))
mikekestemont/PyStyl
[ 55, 13, 55, 6, 1409592784 ]
def cityblock_distance(u, v): """Return the Manhattan/City Block distance between two vectors.""" return abs(u-v).sum()
mikekestemont/PyStyl
[ 55, 13, 55, 6, 1409592784 ]
def correlation(u, v): """Return the correlation distance between two vectors.""" u_var = u - u.mean() v_var = v - v.mean() return 1.0 - dot(u_var, v_var) / (sqrt(dot(u_var, u_var)) * sqrt(dot(v_var, v_var)))
mikekestemont/PyStyl
[ 55, 13, 55, 6, 1409592784 ]
def jaccard_distance(u, v): """return jaccard distance""" u = numpy.asarray(u) v = numpy.asarray(v) return (numpy.double(numpy.bitwise_and((u != v), numpy.bitwise_or(u != 0, v != 0)).sum()) / numpy.double(numpy.bitwise_or(u != 0, v != 0).sum()))
mikekestemont/PyStyl
[ 55, 13, 55, 6, 1409592784 ]
def setUp(self): mock_client = mock.MagicMock() mock_client.user.return_value = 'mocked user' self.request = Request('http://a.b/path') self.request.grant_type = 'password' self.request.username = 'john' self.request.password = 'doe' self.request.client = mock_cli...
idan/oauthlib
[ 2555, 477, 2555, 82, 1321744131 ]