function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def update_document_on_search_service(sender, **kwargs): if not kwargs.get('raw', False): instance = kwargs['instance'] search_index_update('metric', instance.id)
policycompass/policycompass-services
[ 2, 11, 2, 2, 1404486772 ]
def delete_document_on_search_service(sender, **kwargs): instance = kwargs['instance'] search_index_delete('metric', instance.id)
policycompass/policycompass-services
[ 2, 11, 2, 2, 1404486772 ]
def shrink_host(url): u = urlparse.urlparse(url)[1].split('.') u = u[-2] + '.' + u[-1] return u.encode('utf-8')
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def request(url, close=True, redirect=True, error=False, proxy=None, post=None, headers=None, mobile=False, limit=None, referer=None, cookie=None, compression=True, output='', timeout='30', XHR=False): try: #control.log('@@@@@@@@@@@@@@ - URL:%s POST:%s' % (url, post)) handlers = [] if not ...
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def parseDOM(html, name=u"", attrs={}, ret=False): # Copyright (C) 2010-2011 Tobias Ussing And Henrik Mosgaard Jensen if attrs is None: attrs = {} if isinstance(html, str): try: html = [html.decode("utf-8")] # Replace with chardet thingy except: try: ...
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def cleanHTMLCodes(txt): txt = txt.replace("'", "") txt = re.sub("(&#[0-9]+)([^;^0-9]+)", "\\1;\\2", txt) txt = HTMLParser.HTMLParser().unescape(txt) txt = txt.replace(""", "\"") txt = txt.replace("&", "&") return txt
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def randomagent(): BR_VERS = [ ['%s.0' % i for i in xrange(18, 50)], ['37.0.2062.103', '37.0.2062.120', '37.0.2062.124', '38.0.2125.101', '38.0.2125.104', '38.0.2125.111', '39.0.2171.71', '39.0.2171.95', '39.0.2171.99', '40.0.2214.93', '40.0.2214.111', '40.0.2214.115', '42.0.2311.9...
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def file_quality_openload(url): try: if '1080' in url: return {'quality': '1080p'} elif '720' in url: return {'quality': 'HD'} else: return {'quality': 'SD'} except: return {'quality': 'SD', 'url': url}
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def __init__(self): self.cookie = None
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def get_cookie(self, netloc, ua, timeout): try: headers = {'User-Agent': ua} request = urllib2.Request(netloc, headers=headers) try: response = urllib2.urlopen(request, timeout=int(timeout)) except urllib2.HTTPError as response: r...
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def __init__(self): self.COOKIE_NAME = 'BLAZINGFAST-WEB-PROTECT'
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def getCookieString(self, content, rcksid): vars = re.findall('toNumbers\("([^"]+)"', content) value = self._decrypt(vars[2], vars[0], vars[1]) cookie = "%s=%s;%s" % (self.COOKIE_NAME, value, rcksid) return cookie
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def __init__(self): self.cookie = None
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def parseJSString(s): try: offset=1 if s[0]=='+' else 0 val = int(eval(s.replace('!+[]','1').replace('!![]','1').replace('[]','0').replace('(','str(')[offset:])) return val except: pass
mrknow/filmkodi
[ 68, 68, 68, 206, 1444160337 ]
def windows_build(args): logging.info("Using vcvars environment:\n{}".format(args.vcvars)) path = args.output os.makedirs(path, exist_ok=True) mxnet_root = get_mxnet_root() logging.info("Found MXNet root: {}".format(mxnet_root)) with remember_cwd(): os.chdir(path) cmd = "\"{}\...
dmlc/mxnet
[ 20293, 6870, 20293, 1995, 1430410875 ]
def nix_build(args): path = args.output os.makedirs(path, exist_ok=True) with remember_cwd(): os.chdir(path) logging.info("Generating project with CMake") check_call("cmake \ -DUSE_CUDA=OFF \ -DUSE_OPENCV=OFF \ -DUSE_OPENMP=OFF \ -DCMAK...
dmlc/mxnet
[ 20293, 6870, 20293, 1995, 1430410875 ]
def prepare_default_pager( clear_screen: bool = False, quit_if_one_screen: bool = True, ansi_escapes: bool = True, chop_long_lines: bool = True, no_init: bool = True, no_tilde: bool = False,
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def make_pager(cmd=None): def _pager(text): return pydoc.tempfilepager(pydoc.plain(text), cmd) return _pager if cmd else pydoc.plainpager
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def pager(text: str) -> None: _pager = find_pager() logger.trace(f"Using pager: '{_pager}'") # type: ignore[attr-defined] make_pager(_pager)(text)
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def __init__(self, ts_start, config, test_id=None): self.ts_start = ts_start self.ts_end = None self.test_id = test_id self.config = config self.description = '' self.input_directory = None self.output_directory = None self.resource_path = 'resources' self.status = CONSTANTS.OK s...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def __init__(self): self._default_test_id = -1 self._analyses = {} self._resource_path = 'resources' self._input_directory = None self._output_directory = None self.return_exit_code = False self.skip_plots = False self.available_graphing_modules = graphing_modules logger.info('Availa...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def signal_start(self, config, test_id=None, **kwargs): """ Initialize an analysis object and set ts_start for the analysis represented by test_id :param test_id: integer that represents the analysis :param config: config can be a ConfigParser.ConfigParser object or a string specifying local or http(s) ...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def get_failed_analyses(self): """ Returns a list of test_id for which naarad analysis failed :return: list of test_ids """ failed_analyses = [] for test_id in self._analyses.keys(): if self._analyses[test_id].status != CONSTANTS.OK: failed_analyses.append(test_id) return faile...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def _set_sla_data(self, test_id, metrics): """ Get sla data from each metric and set it in the _Analysis object specified by test_id to make it available for retrieval :return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status """ for metric in metrics: ...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def _set_stats_data(self, test_id, metrics): """ Get summary stats data from each metric and set it in the _Analysis object specified by test_id to make it available for retrieval :return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status """ for metric ...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def _run_pre(self, analysis, run_steps): """ If Naarad is run in CLI mode, execute any pre run steps specified in the config. ts_start/ts_end are set based on workload run steps if any. :param: analysis: The analysis object being processed :param: run_steps: list of post run steps """ worklo...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def _process_args(self, analysis, args): """ When Naarad is run in CLI mode, get the CL arguments and update the analysis :param: analysis: The analysis being processed :param: args: Command Line Arguments received by naarad """ if args.exit_code: self.return_exit_code = args.exit_code ...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def run(self, analysis, is_api_call, **kwargs): """ :param analysis: Run naarad analysis for the specified analysis object :param **kwargs: Additional keyword args can be passed in here for future enhancements :return: """ threads = [] crossplots = [] report_args = {} metrics = defau...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def diff_reports_by_location(self, report1_location, report2_location, output_directory, config=None, **kwargs): """ Create a diff report using report1 as a baseline :param: report1_location: report to be used as baseline :param: report2_location: report to compare against baseline :param: config fi...
linkedin/naarad
[ 240, 67, 240, 66, 1383348894 ]
def AddError(err): errors.append(err)
DLR-SC/tigl
[ 186, 54, 186, 96, 1419243179 ]
def MockError(token, category, message): AddError((token, category, message)) print token, category, message
DLR-SC/tigl
[ 186, 54, 186, 96, 1419243179 ]
def setUp(self): nsiqcppstyle_rulemanager.ruleManager.ResetRules() nsiqcppstyle_rulemanager.ruleManager.ResetRegisteredRules() nsiqcppstyle_state._nsiqcppstyle_state.verbose = True nsiqcppstyle_reporter.Error = MockError self.setUpRule() global errors errors = []
DLR-SC/tigl
[ 186, 54, 186, 96, 1419243179 ]
def gen_zip(url): """Returns swarming_bot.zip content.""" with open(os.path.join(BOT_DIR, 'config', 'bot_config.py'), 'rb') as f: bot_config_content = f.read() return bot_archive.get_swarming_bot_zip( BOT_DIR, url, '1', {'config/bot_config.py': bot_config_content}, None)
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def do_GET(self): if self.path == '/swarming/api/v1/bot/server_ping': self.send_response(200) self.end_headers() return None if self.path == '/auth/api/v1/server/oauth_config': return self.send_json({ 'client_id': 'id', 'client_not_so_secret': 'hunter2', 'pr...
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def do_PUT(self): raise NotImplementedError(self.path)
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def __init__(self): super(Server, self).__init__() self._lock = threading.Lock() # Accumulated bot events. self._bot_events = [] # Running tasks. self._tasks = {} # Bot reported task errors. self._task_errors = {} self.has_polled = threading.Event() self.has_updated_task = thread...
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def get_tasks(self): """Returns the tasks run by the bots.""" with self._lock: return copy.deepcopy(self._tasks)
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def _add_bot_event(self, data): # Used by the handler. with self._lock: self._bot_events.append(data)
luci/luci-py
[ 70, 40, 70, 82, 1427740754 ]
def GetStates(S): global states states = S #=====================# # Get Trajectory # #=====================#
riscmaster/risc_maap
[ 1, 1, 1, 1, 1431718259 ]
def GetBatt(S): global nominal_thrust B = S.battery_remaining # coefficients for fourth order fit # determined 11 May 2015 by Spencer Maughan and Ishmaal Erekson c0 = 0.491674747062374 c1 = -0.024809293286468 c2 = 0.000662710609466 c3 = -0.000008160593348 c4 = 0.000000033699651 ...
riscmaster/risc_maap
[ 1, 1, 1, 1, 1431718259 ]
def Basic_Controller(): global states, euler_max, max_yaw_rate, pub_ctrl,K,traj Ctrl = Controls() Ctrl.Obj = [Control()]*1 Ctrl.header.stamp = states.header.stamp g = 9.80665 # average value of earth's gravitational constant m/s^2 m = 1.282 # IRIS mass in kg #===============...
riscmaster/risc_maap
[ 1, 1, 1, 1, 1431718259 ]
def setUp(self): super(PodcastTestCase, self).setUp() self.client = Client() # show show = Show.objects.create( title='All About Everything', slug='everything', description='All About Everything is a show about everything. Each week we dive into any s...
richardcornish/django-itunespodcast
[ 11, 9, 11, 3, 1474854128 ]
def setUpTestData(cls): UsernameSnippet.objects.create(available=True)
jeremyphilemon/uniqna
[ 11, 9, 11, 33, 1483453818 ]
def __init__(self, inst, obj): self.client = None self.load_into(inst, obj)
b1naryth1ef/rowboat
[ 117, 91, 117, 7, 1475878220 ]
def parse(cls, obj, *args, **kwargs): inst = PluginConfigObj() cls(inst, obj) return inst
b1naryth1ef/rowboat
[ 117, 91, 117, 7, 1475878220 ]
def force_load_plugin_configs(cls): """ This function can be called to ensure that this class will have all its attributes properly loaded, as they are dynamically set when plugin configs are defined. """ plugins = os.path.join(os.path.dirname(os.path.realpath(__file__)),...
b1naryth1ef/rowboat
[ 117, 91, 117, 7, 1475878220 ]
def get_command_override(self, command): return rule_matcher(command, self.overrides or [])
b1naryth1ef/rowboat
[ 117, 91, 117, 7, 1475878220 ]
def get_printable_field_value(instance, fieldname): """ Get the display value of a model field, showing a comma-delimited list for M2M fields. """ field = instance._meta.get_field(fieldname) field_value = getattr(instance, fieldname) if isinstance(field, models.ManyToManyField): fie...
SohoTechLabs/django-ajax-changelist
[ 2, 5, 2, 1, 1365111694 ]
def __init__(self, model, valid_fields, **kwargs): self.model = model self.valid_fields = valid_fields
SohoTechLabs/django-ajax-changelist
[ 2, 5, 2, 1, 1365111694 ]
def __init__(self, *args, **kwargs): HANDLER_NAME_TPL = "_%s_ajax_handler" if not hasattr(self, 'ajax_list_display'): self.ajax_list_display = [] self.list_display = list(self.list_display) self.list_display = self.list_display + map(lambda name: HANDLER_NAME_TPL % name, ...
SohoTechLabs/django-ajax-changelist
[ 2, 5, 2, 1, 1365111694 ]
def _get_field_handler(self, fieldname): """ Handle rendering of AJAX-editable fields for the changelist, by dynamically building a callable for each field. """ def handler_function(obj, *args, **kwargs): ItemForm = modelform_factory(self.model, fields=(fieldname,)) ...
SohoTechLabs/django-ajax-changelist
[ 2, 5, 2, 1, 1365111694 ]
def getStep(self, stepid=None, buildid=None, number=None, name=None): tbl = self.db.model.steps if stepid is not None: wc = (tbl.c.id == stepid) else: if buildid is None: raise RuntimeError('must supply either stepid or buildid') if number is n...
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def getSteps(self, buildid): def thd(conn): tbl = self.db.model.steps q = tbl.select() q = q.where(tbl.c.buildid == buildid) q = q.order_by(tbl.c.number) res = conn.execute(q) return [self._stepdictFromRow(row) for row in res.fetchall()] ...
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def addStep(self, buildid, name, state_string): def thd(conn): tbl = self.db.model.steps # get the highest current number r = conn.execute(sa.select([sa.func.max(tbl.c.number)], whereclause=(tbl.c.buildid == buildid))) number...
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def startStep(self, stepid): started_at = int(self.master.reactor.seconds()) def thd(conn): tbl = self.db.model.steps q = tbl.update(whereclause=(tbl.c.id == stepid)) conn.execute(q, started_at=started_at) yield self.db.pool.do(thd)
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def setStepStateString(self, stepid, state_string): def thd(conn): tbl = self.db.model.steps q = tbl.update(whereclause=(tbl.c.id == stepid)) conn.execute(q, state_string=state_string) return self.db.pool.do(thd)
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def thd(conn): tbl = self.db.model.steps wc = (tbl.c.id == stepid) q = sa.select([tbl.c.urls_json], whereclause=wc) res = conn.execute(q) row = res.fetchone() if _racehook is not None: _racehook() ...
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def finishStep(self, stepid, results, hidden): def thd(conn): tbl = self.db.model.steps q = tbl.update(whereclause=(tbl.c.id == stepid)) conn.execute(q, complete_at=int(self.master.reactor.seconds()), results=results, ...
tardyp/buildbot
[ 6, 2, 6, 1, 1285148030 ]
def setUp(self): filename = "testdata/nasa_gv_mc3e_2dvd_test.txt" self.dsd = NASA_2DVD_reader.read_2dvd_dsd_nasa_gv(filename)
josephhardinee/PyDisdrometer
[ 35, 29, 35, 14, 1396333080 ]
def test_dsd_nd_exists(self): self.assertIsNotNone(self.dsd.fields["Nd"], "DSD Object has no Nd field")
josephhardinee/PyDisdrometer
[ 35, 29, 35, 14, 1396333080 ]
def test_RR_works(self): self.dsd.calculate_RR() self.assertIsNotNone( self.dsd.fields["rain_rate"], "Rain Rate is not in fields after calculate_RR()", ) self.assertEqual( len(self.dsd.fields["rain_rate"]["data"]), 5, "Wrong num...
josephhardinee/PyDisdrometer
[ 35, 29, 35, 14, 1396333080 ]
def is_continuous(self): """ Whether or not the domain has an uncountable number of values. :type: `bool` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_finite(self): """ Whether or not the domain contains a finite number of points. :type: `bool` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def dtype(self): """ The numpy dtype of a single element of the domain. :type: `np.dtype` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def n_members(self): """ Returns the number of members in the domain if it `is_finite`, otherwise, returns `np.inf`. :type: ``int`` or ``np.inf`` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def example_point(self): """ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1 ``np.array`` of type `dtype`. :type: ``np.ndarray`` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def values(self): """ Returns an `np.array` of type `dtype` containing some values from the domain. For domains where `is_finite` is ``True``, all elements of the domain will be yielded exactly once. :rtype: `np.ndarray` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_discrete(self): """ Whether or not the domain has a countable number of values. :type: `bool` """ return not self.is_continuous
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def in_domain(self, points): """ Returns ``True`` if all of the given points are in the domain, ``False`` otherwise. :param np.ndarray points: An `np.ndarray` of type `self.dtype`. :rtype: `bool` """ pass
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def __init__(self, *domains):
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_continuous(self): """ Whether or not the domain has an uncountable number of values. :type: `bool` """ return any([domain.is_continuous for domain in self._domains])
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_finite(self): """ Whether or not the domain contains a finite number of points. :type: `bool` """ return all([domain.is_finite for domain in self._domains])
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def dtype(self): """ The numpy dtype of a single element of the domain. :type: `np.dtype` """ return self._dtype
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def n_members(self): """ Returns the number of members in the domain if it `is_finite`, otherwise, returns `np.inf`. :type: ``int`` or ``np.inf`` """ if self.is_finite: return reduce(mul, [domain.n_members for domain in self._domains], 1) else: ...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def example_point(self): """ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1 ``np.array`` of type `dtype`. :type: ``np.ndarray`` """ return self._example_point
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def values(self): """ Returns an `np.array` of type `dtype` containing some values from the domain. For domains where `is_finite` is ``True``, all elements of the domain will be yielded exactly once. :rtype: `np.ndarray` """ separate_values = [domain.valu...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def _mytype(self, array): # astype does weird stuff with struct names, and possibly # depends on numpy version; hopefully # the following is a bit more predictable since it passes through # uint8 return separate_struct_array(array, self.dtype)[0]
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def to_regular_arrays(self, array): """ Expands from an array of type `self.dtype` into a list of arrays with dtypes corresponding to the factor domains. :param np.ndarray array: An `np.array` of type `self.dtype`. :rtype: ``list`` """ return separate_struct_arr...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def in_domain(self, points): """ Returns ``True`` if all of the given points are in the domain, ``False`` otherwise. :param np.ndarray points: An `np.ndarray` of type `self.dtype`. :rtype: `bool` """ return all([ domain.in_domain(array) f...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def __init__(self, min=-np.inf, max=np.inf): self._min = min self._max = max
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def min(self): """ Returns the minimum value of the domain. :rtype: `float` """ return self._min
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def max(self): """ Returns the maximum value of the domain. :rtype: `float` """ return self._max
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_continuous(self): """ Whether or not the domain has an uncountable number of values. :type: `bool` """ return True
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_finite(self): """ Whether or not the domain contains a finite number of points. :type: `bool` """ return False
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def dtype(self): """ The numpy dtype of a single element of the domain. :type: `np.dtype` """ return np.float
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def n_members(self): """ Returns the number of members in the domain if it `is_finite`, otherwise, returns `None`. :type: ``np.inf`` """ return np.inf
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def example_point(self): """ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1 ``np.array`` of type ``dtype``. :type: ``np.ndarray`` """ if not np.isinf(self.min): ...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def values(self): """ Returns an `np.array` of type `self.dtype` containing some values from the domain. For domains where ``is_finite`` is ``True``, all elements of the domain will be yielded exactly once. :rtype: `np.ndarray` """ return self.example_poi...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def in_domain(self, points): """ Returns ``True`` if all of the given points are in the domain, ``False`` otherwise. :param np.ndarray points: An `np.ndarray` of type `self.dtype`. :rtype: `bool` """ if np.all(np.isreal(points)): are_greater = np.all...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def __init__(self, min=0, max=np.inf): self._min = int(min) if not np.isinf(min) else min self._max = int(max) if not np.isinf(max) else max
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def min(self): """ Returns the minimum value of the domain. :rtype: `float` or `np.inf` """ return int(self._min) if not np.isinf(self._min) else self._min
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def max(self): """ Returns the maximum value of the domain. :rtype: `float` or `np.inf` """ return int(self._max) if not np.isinf(self._max) else self._max
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_continuous(self): """ Whether or not the domain has an uncountable number of values. :type: `bool` """ return False
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def is_finite(self): """ Whether or not the domain contains a finite number of points. :type: `bool` """ return not np.isinf(self.min) and not np.isinf(self.max)
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def dtype(self): """ The numpy dtype of a single element of the domain. :type: `np.dtype` """ return np.int
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def n_members(self): """ Returns the number of members in the domain if it `is_finite`, otherwise, returns `np.inf`. :type: ``int`` or ``np.inf`` """ if self.is_finite: return int(self.max - self.min + 1) else: return np.inf
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def example_point(self): """ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1 ``np.array`` of type ``dtype``. :type: ``np.ndarray`` """ if not np.isinf(self.min): ...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def values(self): """ Returns an `np.array` of type `self.dtype` containing some values from the domain. For domains where ``is_finite`` is ``True``, all elements of the domain will be yielded exactly once. :rtype: `np.ndarray` """ if self.is_finite: ...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def in_domain(self, points): """ Returns ``True`` if all of the given points are in the domain, ``False`` otherwise. :param np.ndarray points: An `np.ndarray` of type `self.dtype`. :rtype: `bool` """ if np.all(np.isreal(points)): try: ...
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]
def __init__(self, n_meas, n_elements=2): self._n_elements = n_elements self._n_meas = n_meas
QInfer/python-qinfer
[ 91, 32, 91, 22, 1344992565 ]