function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self, main): self.main = main
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def advanceQueue(self, n): # Send first block of available messages while n.chatq and (type(n.chatq[0]) is not float): msg = n.chatq.pop(0) n.chatq_base = (n.chatq_base + 1) % 0x100000000 self.sendMessage(n, msg) dcall_discard(n, 'chatq_dcall') # If...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def clearQueue(self, n): # Reset everything to normal del n.chatq[:] dcall_discard(n, 'chatq_dcall') n.chatq_base = None
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def __init__(self, main): self.main = main self.rebuild_bans_dcall = None self.ban_matcher = SubnetMatcher() self.isBanned = self.ban_matcher.containsIP
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def cb(): self.rebuild_bans_dcall = None osm = self.main.osm self.ban_matcher.clear() # Get all bans from bridges. if osm.bcm: for bridge in osm.bcm.bridges: for b in bridge.bans.itervalues(): if b.e...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def enforceAllBans(self): osm = self.main.osm # Check all the online nodes. for n in list(osm.nodes): int_ip = Ad().setRawIPPort(n.ipp).getIntIP() if self.isBanned(int_ip): osm.nodeExited(n, "Node Banned") # Check my ping neighbors. for p...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def __init__(self, main): self.main = main self.topic = "" self.topic_whoset = "" self.topic_node = None self.waiting = True
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def receivedSyncTopic(self, n, topic): # Topic arrived from a YR packet if self.waiting: self.updateTopic(n, n.nick, topic, changed=False)
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def broadcastNewTopic(self, topic): osm = self.main.osm if len(topic) > 255: topic = topic[:255] # Update topic locally if not self.updateTopic(osm.me, osm.me.nick, topic, changed=True): # Topic is controlled by a bridge node self.topic_node.bridge_...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def checkLeavingNode(self, n): # If the node who set the topic leaves, wipe out the topic if self.topic_node is n: self.updateTopic(None, "", "", changed=False)
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def __init__(self): self.myip_reports = [] self.reconnect_dcall = None self.reconnect_interval = RECONNECT_RANGE[0] # Initial Connection Manager self.icm = None # Neighbor Connection Manager self.osm = None self.accept_IQ_trigger = False # P...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def reconnectDesired(self): raise NotImplementedError("Override me!")
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def startInitialContact(self): # If all the conditions are right, start connection procedure CHECK(not (self.icm or self.osm)) dcall_discard(self, 'reconnect_dcall') def cb(result): self.icm = None result, node_ipps = result if result == 'good': ...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def startNodeSync(self, node_ipps): # Determine my IP address and enable the osm CHECK(not (self.icm or self.osm)) # Reset the reconnect interval self.reconnect_interval = RECONNECT_RANGE[0] dcall_discard(self, 'reconnect_dcall') # Get my address and port try: ...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def queryLocation(self, my_ipp): raise NotImplementedError("Override me!")
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def showLoginStatus(self, text, counter=None): raise NotImplementedError("Override me!")
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def cb(): self.reconnect_dcall = None self.startConnecting()
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def afterShutdownHandlers(self): raise NotImplementedError("Override me!")
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def getStateObserver(self): raise NotImplementedError("Override me!")
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def stateChange_ObserverUp(self): # Called after a DC client / IRC server / etc. has become available. osm = self.osm if osm and osm.syncd: self.osm.updateMyInfo() # Make sure the observer's still online, because a nick collison # in updateMyInfo could have killed it...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def stateChange_DtellaUp(self): # Called after Dtella has finished syncing. osm = self.osm CHECK(osm and osm.syncd) osm.updateMyInfo(send=True) so = self.getStateObserver() if so: so.event_DtellaUp()
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def addMyIPReport(self, from_ad, my_ad): # from_ad = the IP who sent us this guess # my_ad = the IP that seems to belong to us CHECK(from_ad.auth('sx', self)) fromip = from_ad.getRawIP() myip = my_ad.getRawIP() # If we already have a report from this fromip in the list...
pmarks-net/dtella
[ 5, 2, 5, 11, 1426380623 ]
def can_handle_url(cls, url): return cls._url_re.match(url)
repotvsupertuga/tvsupertuga.repository
[ 1, 8, 1, 4, 1493763534 ]
def GFX_MenuDialog(filename,*items): file=open(filename,'w') file.writelines(map(lambda x:x+"\n", items)) file.close() os.system("python X11_MenuDialog.py "+filename);
kmatheussen/radium
[ 768, 35, 768, 253, 1319467491 ]
def __init__( self, *args ): apply( qt.QWidget.__init__, (self,) + args ) self.topLayout = qt.QVBoxLayout( self, 10 ) self.grid = qt.QGridLayout( 0, 0 ) self.topLayout.addLayout( self.grid, 10 ) # Create a list box self.lb = qt.QListBox( self, "listBox" ) file=open(sys.argv[...
kmatheussen/radium
[ 768, 35, 768, 253, 1319467491 ]
def listBoxItemSelected( self, index ): txt = qt.QString() txt = "List box item %d selected" % index print txt file=open(sys.argv[1],'w') file.write(self.dasitems[index]) file.close(); a.quit()
kmatheussen/radium
[ 768, 35, 768, 253, 1319467491 ]
def randname(): length = random.randint(1, 4) return "".join(random.sample("abcdef", 1)[0] for i in range(length))
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def genpaths(): """generate random paths""" path = "" while True: nextpath = randpath(path) yield nextpath path = nextpath
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testempty(self): tree = treestate.treestate(os.path.join(testtmp, "empty"), 0) self.assertEqual(len(tree), 0) self.assertEqual(tree.getmetadata(), b"") self.assertEqual(tree.walk(0, 0), []) self.assertTrue(tree.hasdir("/")) for path in ["", "a", "/", "b/c", "d/"]: ...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testremove(self): tree = treestate.treestate(os.path.join(testtmp, "remove"), 0) count = 5000 files = list(itertools.islice(genfiles(), count)) expected = {} for path, bits, mode, size, mtime, copied in files: tree.insert(path, bits, mode, size, mtime, copied) ...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def walk(setbits, unsetbits): return sorted( k for k, v in pycompat.iteritems(expected) if ((v[0] & unsetbits) == 0 and (v[0] & setbits) == setbits) )
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testdirfilter(self): treepath = os.path.join(testtmp, "walk") tree = treestate.treestate(treepath, 0) files = ["a/b", "a/b/c", "b/c", "c/d"] for path in files: tree.insert(path, 1, 2, 3, 4, None) self.assertEqual(tree.walk(1, 0, None), files) self.assertEq...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testsaveas(self): treepath = os.path.join(testtmp, "saveas") tree = treestate.treestate(treepath, 0) tree.insert("a", 1, 2, 3, 4, None) tree.setmetadata(b"1") tree.flush() tree.insert("b", 1, 2, 3, 4, None) tree.remove("a") treepath = "%s-savedas" % t...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testpathcomplete(self): treepath = os.path.join(testtmp, "pathcomplete") tree = treestate.treestate(treepath, 0) paths = ["a/b/c", "a/b/d", "a/c", "de"] for path in paths: tree.insert(path, 1, 2, 3, 4, None) def complete(prefix, fullpath=False): compl...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def testsubdirquery(self): treepath = os.path.join(testtmp, "subdir") tree = treestate.treestate(treepath, 0) paths = ["a/b/c", "a/b/d", "a/c", "de"] for path in paths: tree.insert(path, 1, 2, 3, 4, None) self.assertEqual(tree.tracked(""), paths) self.assertEq...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def test_path_add_01( ): '''A Path and an int cannot be added.''' assert raises(TypeError, 'Path([(1, 2), (3, 4)]) + 3')
drepetto/chiplotle
[ 27, 16, 27, 7, 1432836867 ]
def test_path_radd_02( ): '''A float and a Path cannot be added.''' assert raises(TypeError, '3.2 + Path([(1, 2), (3, 4)])')
drepetto/chiplotle
[ 27, 16, 27, 7, 1432836867 ]
def test_path_radd_03( ): '''A Coordinate and a Path can be added.''' a = Path([(1, 2), (3, 4)]) t = Coordinate(1, 2) + a assert t is not a assert isinstance(t, Path) assert t == Path([(2, 4), (4, 6)])
drepetto/chiplotle
[ 27, 16, 27, 7, 1432836867 ]
def test_path_radd_04( ): '''A duple and a Path cannot be added.''' a = Path([(1, 2), (3, 4)]) assert raises(TypeError, '(1, 2) + a')
drepetto/chiplotle
[ 27, 16, 27, 7, 1432836867 ]
def test_path_add_06( ): '''A Path and a Path cannot be added.''' a = Path([(1, 2), (3, 4)]) b = Path([(2, 3)]) assert raises(TypeError, 'a + b')
drepetto/chiplotle
[ 27, 16, 27, 7, 1432836867 ]
def _logo_data(event): return { 'url': event.logo_url, 'filename': event.logo_metadata['filename'], 'size': event.logo_metadata['size'], 'content_type': event.logo_metadata['content_type'] }
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) self.event = self._conf.as_event
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _checkProtection(self): RHLayoutBase._checkProtection(self) if self._conf.getType() != 'conference': raise NotFound('Only conferences have layout settings')
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): f = request.files['file'] try: img = Image.open(f) except IOError: flash(_('You cannot upload this file as a logo.'), 'error') return jsonify_data(content=None) if img.format.lower() not in {'jpeg', 'png', 'gif'}: flash(...
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): self.event.logo = None self.event.logo_metadata = None flash(_('Logo deleted'), 'success') logger.info("Logo of %s deleted by %s", self.event, session.user) return jsonify_data(content=None)
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): f = request.files['file'] self.event.stylesheet = to_unicode(f.read()).strip() self.event.stylesheet_metadata = { 'hash': crc32(self.event.stylesheet), 'size': len(self.event.stylesheet), 'filename': secure_filename(f.filename, 'stylesheet....
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): self.event.stylesheet = None self.event.stylesheet_metadata = None layout_settings.set(self.event, 'use_custom_css', False) flash(_('CSS file deleted'), 'success') logger.info("CSS file for %s deleted by %s", self.event, session.user) return jsonify_da...
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): form = CSSSelectionForm(event=self.event, formdata=request.args, csrf_enabled=False) css_url = None if form.validate(): css_url = get_css_url(self.event, force_theme=form.theme.data, for_preview=True) return WPConfModifPreviewCSS(self, self._conf, form=for...
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): form = CSSSelectionForm(event=self.event) if form.validate_on_submit(): layout_settings.set(self.event, 'use_custom_css', form.theme.data == '_custom') if form.theme.data != '_custom': layout_settings.set(self._conf, 'theme', form.theme.data) ...
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _process(self): event = self._conf.as_event if not event.has_logo: raise NotFound metadata = event.logo_metadata return send_file(metadata['filename'], BytesIO(event.logo), mimetype=metadata['content_type'], conditional=True)
belokop/indico_bare
[ 1, 1, 1, 5, 1465204236 ]
def _get_formatted_message(label, context): """ Return a message that is a rendered template with the given context using the default language of the system. """ current_language = get_language() # Setting the environment to the default language activate(settings.LANGUAGE_CODE) c = Con...
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def _distinct_action_time(query, limit=None): """ Distinct rows by the 'action_time' field, keeping in the query only the entry with the highest 'id' for the related set of entries with equal 'action_time'. If 'limit' is set, the function will return the 'limit'-most-recent actionlogs. Ex...
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def by_object(self, obj, limit=None): """Return LogEntries for a related object.""" ctype = ContentType.objects.get_for_model(obj) q = self.filter(content_type__pk=ctype.pk, object_id=obj.pk) return _distinct_action_time(q, limit)
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def by_object_last_week(self, obj): """Return LogEntries of the related object for the last week.""" last_week_date = datetime.datetime.today() - datetime.timedelta(days=7) ctype = ContentType.objects.get_for_model(obj) return self.filter(content_type__pk=ctype.pk, object_id=obj.pk, ...
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def for_projects_by_user(self, user): """Return project LogEntries for a related user.""" ctype = ContentType.objects.get(model='project') return self.filter(user__pk__exact=user.pk, content_type__pk=ctype.pk)
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def top_submitters_by_team_content_type(self, number=10): """ Return a list of dicts with the ordered top submitters for the entries of the 'team' content type. """ return self.top_submitters_by_content_type('teams.team', number)
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def __unicode__(self): return u'%s.%s.%s' % (self.action_type, self.object_name, self.user)
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def save(self, *args, **kwargs): """Save the object in the database.""" if self.action_time is None: self.action_time = datetime.datetime.now() super(LogEntry, self).save(*args, **kwargs)
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def action_type_short(self): """ Return a shortened, generalized version of an action type. Useful for presenting an image signifying an action type. Example:: >>> from notification.models import NoticeType >>> nt = NoticeType(label='project_added') >>> zlog = LogEntry(...
tymofij/adofex
[ 9, 1, 9, 36, 1314472327 ]
def detect(iToken, lObjects): ''' primary_unit_declaration ::= identifier; ''' return classify(iToken, lObjects)
jeremiah-c-leary/vhdl-style-guide
[ 129, 31, 129, 57, 1499106283 ]
def testing_user(): user, _ = User.objects.get_or_create(username="tester") user.set_password("password") user.save() yield user
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def testing_profile(testing_user): yield UserProfile.objects.create(user=testing_user)
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def import_user(): user, _ = User.objects.get_or_create(username="importer") user.set_password("password") user.save() yield user
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def importer_profile(import_user): yield UserProfile.objects.create(user=import_user)
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def sample_category(): category, _ = Category.objects.get_or_create(name="test category") yield category
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def sample_tag(sample_category, testing_user): tag, _ = Tag.objects.get_or_create(name="test tag", defaults={ "category": sample_category, "create_user": testing_user, "update_user": testing_user, }) yield tag
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def role_category(): category, _ = Category.objects.get_or_create(name="audience") yield category
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def role_tag(role_category, testing_user): tag, _ = Tag.objects.get_or_create(name="cadre", defaults={ "category": role_category, "create_user": testing_user, "update_user": testing_user, }) assert Tag.tags.roles() yield tag
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def test_resource(testing_user): yield resource_factory( user=testing_user, title=u"Básica salud del recién nacido", description=u"Básica salud del recién nacido", )
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def test_peer(): peer = Peer.peers.create(name="Distant ORB", host="http://www.orb.org/") yield peer
mPowering/django-orb
[ 2, 10, 2, 81, 1420822795 ]
def owoify(message): for key in substitutions.keys(): message = message.replace(key,substitutions[key]) return message + choice(faces)
sentriz/steely
[ 21, 14, 21, 6, 1498783471 ]
def setUpClass(cls): super(TestStockQuantityChangeReason, cls).setUpClass() # MODELS cls.stock_move = cls.env["stock.move"] cls.product_product_model = cls.env["product.product"] cls.product_category_model = cls.env["product.category"] cls.wizard_model = cls.env["stock.c...
OCA/stock-logistics-warehouse
[ 248, 611, 248, 91, 1402934883 ]
def _product_change_qty(self, product, new_qty): values = { "product_tmpl_id": product.product_tmpl_id.id, "product_id": product.id, "new_quantity": new_qty, } wizard = self.wizard_model.create(values) wizard.change_product_qty()
OCA/stock-logistics-warehouse
[ 248, 611, 248, 91, 1402934883 ]
def __init__(self): BaseModelsResource.__init__(self, SearchFilter)
cgwire/zou
[ 145, 88, 145, 11, 1490485144 ]
def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} default['product_customer_code_ids'] = False res = super(product_product, self).copy( cr, uid, id, default=default, context=context) return res
cgstudiomap/cgstudiomap
[ 3, 2, 3, 45, 1427859918 ]
def __init__(self, label, channel, nodes_per_block, init_blocks, min_blocks, max_blocks, parallelism, walltime, launcher, cmd_timeout=10): se...
Parsl/parsl
[ 369, 114, 369, 333, 1476980871 ]
def _write_submit_script(self, template, script_filename, job_name, configs): """Generate submit script and write it to a file. Args: - template (string) : The template string to be used for the writing submit script - script_filename (string) : Name of the submit script ...
Parsl/parsl
[ 369, 114, 369, 333, 1476980871 ]
def _status(self): pass
Parsl/parsl
[ 369, 114, 369, 333, 1476980871 ]
def __init__(self, qubits: Iterable['cirq.Qid'], letter: str): self.qubits = tuple(qubits) self.letter = letter
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return InputCell(qubits=Cell._replace_qubits(self.qubits, qubits), letter=self.letter)
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def __init__(self, letter: str, value: int): self.letter = letter self.value = value
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return self
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def generate_all_input_cell_makers() -> Iterator[CellMaker]: # Quantum inputs. yield from _input_family("inputA", "a") yield from _input_family("inputB", "b") yield from _input_family("inputR", "r") yield from _input_family("revinputA", "a", rev=True) yield from _input_family("revinputB", "b", r...
quantumlib/Cirq
[ 3678, 836, 3678, 314, 1513294909 ]
def get_exploration_action( self, action_distribution: ActionDistribution, timestep: Union[int, TensorType], explore: bool = True,
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def ipython(): config = tools.default_config() config.TerminalInteractiveShell.simple_prompt = True shell = interactiveshell.TerminalInteractiveShell.instance(config=config) return shell
googleapis/python-bigquery
[ 575, 233, 575, 100, 1575936544 ]
def eight_schools_params(): """Share setup for eight schools.""" return { "J": 8, "y": np.array([28.0, 8.0, -3.0, 7.0, -1.0, 1.0, 18.0, 12.0]), "sigma": np.array([15.0, 10.0, 16.0, 11.0, 9.0, 11.0, 10.0, 18.0]), }
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def draws(): """Share default draw count.""" return 500
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def chains(): """Share default chain count.""" return 2
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def create_model(seed=10): """Create model with fake data.""" np.random.seed(seed) nchains = 4 ndraws = 500 data = { "J": 8, "y": np.array([28.0, 8.0, -3.0, 7.0, -1.0, 1.0, 18.0, 12.0]), "sigma": np.array([15.0, 10.0, 16.0, 11.0, 9.0, 11.0, 10.0, 18.0]), } p...
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def create_multidimensional_model(seed=10): """Create model with fake data.""" np.random.seed(seed) nchains = 4 ndraws = 500 ndim1 = 5 ndim2 = 7 data = { "y": np.random.normal(size=(ndim1, ndim2)), "sigma": np.random.normal(size=(ndim1, ndim2)), } posterior...
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def create_data_random(groups=None, seed=10): """Create InferenceData object using random data.""" if groups is None: groups = ["posterior", "sample_stats", "observed_data", "posterior_predictive"] rng = np.random.default_rng(seed) data = rng.normal(size=(4, 500, 8)) idata_dict = dict(...
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def data_random(): """Fixture containing InferenceData object using random data.""" idata = create_data_random() return idata
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def models(): """Fixture containing 2 mock inference data instances for testing.""" # blank line to keep black and pydocstyle happy
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def multidim_models(): """Fixture containing 2 mock inference data instances with multidimensional data for testing.""" # blank line to keep black and pydocstyle happy
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def check_multiple_attrs( test_dict: Dict[str, List[str]], parent: InferenceData
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def emcee_version(): """Check emcee version.
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def needs_emcee3_func(): """Check if emcee3 is required.""" # pylint: disable=invalid-name needs_emcee3 = pytest.mark.skipif(emcee_version() < 3, reason="emcee3 required") return needs_emcee3
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def _emcee_lnprior(theta): """Proper function to allow pickling.""" mu, tau, eta = theta[0], theta[1], theta[2:] # Half-cauchy prior, hwhm=25 if tau < 0: return -np.inf prior_tau = -np.log(tau ** 2 + 25 ** 2) prior_mu = -((mu / 10) ** 2) # normal prior, loc=0, scale=10 prior...
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def _emcee_lnprob(theta, y, sigma): """Proper function to allow pickling.""" mu, tau, eta = theta[0], theta[1], theta[2:] prior = _emcee_lnprior(theta) like_vect = -(((mu + tau * eta - y) / sigma) ** 2) like = np.sum(like_vect) return like + prior, (like_vect, np.random.normal((mu + tau * ...
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]
def emcee_schools_model(data, draws, chains): """Schools model in emcee.""" import emcee
arviz-devs/arviz
[ 1351, 324, 1351, 165, 1438170670 ]