index int64 0 731k | package stringlengths 2 98 ⌀ | name stringlengths 1 76 | docstring stringlengths 0 281k ⌀ | code stringlengths 4 8.19k | signature stringlengths 2 42.8k ⌀ | embed_func_code listlengths 768 768 |
|---|---|---|---|---|---|---|
724,135 | pdfrw.tokens | __iter__ | null | def __iter__(self):
return self.iterator
| (self) | [
0.019309144467115402,
-0.0430755540728569,
-0.07206478714942932,
-0.0027560186572372913,
-0.035590071231126785,
0.012376565486192703,
-0.01509855967015028,
0.04171455651521683,
0.10234697163105011,
0.016229888424277306,
0.016017232090234756,
-0.026981763541698456,
-0.0070261466316878796,
0... |
724,136 | pdfrw.tokens | _gettoks | Given a source data string and a location inside it,
gettoks generates tokens. Each token is a tuple of the form:
<starting file loc>, <ending file loc>, <token string>
The ending file loc is past any trailing whitespace.
The main complication here is the literal stri... | def _gettoks(self, startloc, intern=intern,
delimiters=delimiters, findtok=findtok,
findparen=findparen, PdfString=PdfString,
PdfObject=PdfObject, BasePdfName=BasePdfName):
''' Given a source data string and a location inside it,
gettoks generates tokens. Each token i... | (self, startloc, intern=<built-in function intern>, delimiters='()<>{}[\\]/%', findtok=<built-in method finditer of re.Pattern object at 0x55b77025b280>, findparen=<built-in method finditer of re.Pattern object at 0x7ff9a4a59fc0>, PdfString=<class 'pdfrw.objects.pdfstring.PdfString'>, PdfObject=<class 'pdfrw.objects.pd... | [
0.030869515612721443,
-0.001600366667844355,
-0.01617681421339512,
0.013831917196512222,
-0.03504481539130211,
0.0040145209059119225,
-0.005461529828608036,
0.018145734444260597,
0.0016597311478108168,
-0.05544639751315117,
0.04088231921195984,
0.015444652177393436,
-0.020817134529352188,
... |
724,137 | pdfrw.tokens | error | null | def error(self, *arg):
s = self.msg(*arg)
if s:
log.error(s)
| (self, *arg) | [
-0.04296654835343361,
0.009536728262901306,
0.06265527755022049,
0.08859927952289581,
0.00852409191429615,
-0.0655607357621193,
0.03643782064318657,
0.04559854790568352,
0.056776005774736404,
-0.045974548906087875,
0.05537455156445503,
0.04662400484085083,
0.07048291712999344,
-0.011997818... |
724,138 | pdfrw.tokens | exception | null | def exception(self, *arg):
raise PdfParseError(self.msg(*arg))
| (self, *arg) | [
-0.011642713099718094,
0.02426408976316452,
0.04943934828042984,
0.08409751206636429,
-0.04100259765982628,
-0.03907902166247368,
0.033072054386138916,
0.04842693731188774,
0.0154055031016469,
-0.01984323374927044,
0.0654691681265831,
0.019421396777033806,
0.04201500862836838,
-0.004623338... |
724,139 | pdfrw.tokens | msg | null | def msg(self, msg, *arg):
dumped = self.msgs_dumped
if dumped is not None:
if msg in dumped:
return
dumped.add(msg)
if arg:
msg %= arg
fdata = self.fdata
begin, end = self.current[0]
if begin >= len(fdata):
return '%s (filepos %s past EOF %s)' % (msg, ... | (self, msg, *arg) | [
-0.015764156356453896,
0.024589067324995995,
0.014208483509719372,
0.06520628184080124,
0.04487881809473038,
-0.044577110558748245,
0.053703729063272476,
0.004949869588017464,
0.00399760901927948,
-0.07365406304597855,
0.01932806335389614,
0.006948674097657204,
-0.012237963266670704,
0.021... |
724,140 | pdfrw.tokens | multiple | Retrieve multiple tokens
| def multiple(self, count, islice=itertools.islice, list=list):
''' Retrieve multiple tokens
'''
return list(islice(self, count))
| (self, count, islice=<class 'itertools.islice'>, list=<class 'list'>) | [
0.0019418577430769801,
-0.043695464730262756,
-0.07364178448915482,
-0.017270272597670555,
-0.02602277882397175,
0.09463438391685486,
0.0030076263938099146,
-0.076592817902565,
0.0696847140789032,
0.0057218256406486034,
0.02099260315299034,
-0.005591879598796368,
-0.04198520630598068,
-0.0... |
724,141 | pdfrw.tokens | next_default | null | def next_default(self, default='nope'):
for result in self:
return result
return default
| (self, default='nope') | [
0.0527903251349926,
-0.03502754122018814,
-0.04060538858175278,
0.010524863377213478,
-0.041966646909713745,
0.008615778759121895,
0.03469552844762802,
-0.017497170716524124,
0.09103840589523315,
-0.007296021096408367,
-0.004976069089025259,
0.031076567247509956,
-0.004834963008761406,
0.0... |
724,142 | pdfrw.tokens | setstart | Change the starting location.
| def setstart(self, startloc):
''' Change the starting location.
'''
current = self.current
if startloc != current[0][1]:
current[0] = startloc, startloc
| (self, startloc) | [
0.03616273030638695,
0.05510344356298447,
-0.012627141550183296,
0.01815151609480381,
-0.06608203798532486,
-0.0007294585811905563,
0.010671688243746758,
0.057488568127155304,
-0.006177653558552265,
-0.017476314678788185,
-0.050122737884521484,
-0.04002102464437485,
0.031217100098729134,
0... |
724,143 | pdfrw.tokens | warning | null | def warning(self, *arg):
s = self.msg(*arg)
if s:
log.warning(s)
| (self, *arg) | [
-0.04368150606751442,
0.006347468588501215,
0.07862670719623566,
0.0737125426530838,
0.00038658559788018465,
-0.07521409541368484,
0.04378388449549675,
0.05108688399195671,
0.01849638670682907,
-0.06937851756811142,
-0.008198813535273075,
0.03214685618877411,
0.03965461626648903,
-0.030474... |
724,164 | asyncmock | AsyncCallableMixin | null | class AsyncCallableMixin(CallableMixin):
def __init__(_mock_self, not_async=False, *args, **kwargs):
super().__init__(*args, **kwargs)
_mock_self.not_async = not_async
_mock_self.aenter_return_value = _mock_self
def __call__(_mock_self, *args, **kwargs):
# can't use self in-case... | (not_async=False, *args, **kwargs) | [
0.022567538544535637,
-0.04295055568218231,
-0.012217476963996887,
0.05094873160123825,
0.017555465921759605,
-0.0037920866161584854,
0.0010184901766479015,
0.02103484980762005,
0.0005219073500484228,
-0.033948201686143875,
0.04971553012728691,
0.03125278279185295,
0.01950215920805931,
-0.... |
724,165 | asyncmock | __aenter__ | null | def __call__(_mock_self, *args, **kwargs):
# can't use self in-case a function / method we are mocking uses self
# in the signature
if _mock_self.not_async:
_mock_self._mock_check_sig(*args, **kwargs)
return _mock_self._mock_call(*args, **kwargs)
else:
async def wrapper():
... | (_mock_self) | [
0.03972407430410385,
-0.07746725529432297,
0.02184293605387211,
0.07584008574485779,
-0.03165899217128754,
-0.0453130379319191,
-0.008852137252688408,
0.025380253791809082,
0.03763705864548683,
0.010337810032069683,
0.022674204781651497,
0.033321529626846313,
0.04892110079526901,
-0.041032... |
724,168 | asyncmock | __init__ | null | def __init__(_mock_self, not_async=False, *args, **kwargs):
super().__init__(*args, **kwargs)
_mock_self.not_async = not_async
_mock_self.aenter_return_value = _mock_self
| (_mock_self, not_async=False, *args, **kwargs) | [
0.03265399858355522,
-0.020643332973122597,
0.038932301104068756,
0.016437893733382225,
-0.005941356066614389,
0.0009809847688302398,
-0.03239808976650238,
0.018561938777565956,
-0.008368226699531078,
0.002883242443203926,
0.03992181643843651,
0.04398224130272865,
-0.02436254546046257,
0.0... |
724,173 | asyncmock | AsyncMock |
Create a new `AsyncMock` object. `AsyncMock` several options that extends
the behaviour of the basic `Mock` object:
* `not_async`: This is a boolean flag used to indicate that when the mock
is called it should not return a normal Mock instance to make the mock
non-awaitable. If this flag is se... | class AsyncMock(AsyncCallableMixin, NonCallableMock):
"""
Create a new `AsyncMock` object. `AsyncMock` several options that extends
the behaviour of the basic `Mock` object:
* `not_async`: This is a boolean flag used to indicate that when the mock
is called it should not return a normal Mock inst... | (spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs) | [
0.05540618672966957,
-0.0038359537720680237,
0.029277756810188293,
-0.023876294493675232,
0.013970562256872654,
-0.0021766063291579485,
-0.030211569741368294,
0.008051840588450432,
-0.025286167860031128,
-0.0313284806907177,
0.04236943647265434,
0.01579241082072258,
-0.015261420048773289,
... |
724,211 | mock.mock | CallableMixin | null | class CallableMixin(Base):
def __init__(self, spec=None, side_effect=None, return_value=DEFAULT,
wraps=None, name=None, spec_set=None, parent=None,
_spec_state=None, _new_name='', _new_parent=None, **kwargs):
self.__dict__['_mock_return_value'] = return_value
_safe... | (spec=None, side_effect=None, return_value=sentinel.DEFAULT, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs) | [
-0.0004180676769465208,
-0.06706483662128448,
0.013378165662288666,
0.058425839990377426,
-0.005568264983594418,
0.0046496037393808365,
-0.039837662130594254,
0.01802521012723446,
0.015476501546800137,
-0.03592759370803833,
0.02145419828593731,
0.026899633929133415,
0.04204858839511871,
-0... |
724,437 | flask_gzip | Gzip | null | class Gzip(object):
def __init__(self, app, compress_level=6, minimum_size=500):
self.app = app
self.compress_level = compress_level
self.minimum_size = minimum_size
self.app.after_request(self.after_request)
def after_request(self, response):
accept_encoding = request.h... | (app, compress_level=6, minimum_size=500) | [
0.015812648460268974,
-0.057683028280735016,
-0.06393233686685562,
0.036662619560956955,
0.03861316293478012,
0.00810043141245842,
-0.05908438563346863,
0.0587056428194046,
0.012290310114622116,
-0.039238091558218,
0.07627946138381958,
0.0024665838573127985,
0.0005142661393620074,
-0.03069... |
724,438 | flask_gzip | __init__ | null | def __init__(self, app, compress_level=6, minimum_size=500):
self.app = app
self.compress_level = compress_level
self.minimum_size = minimum_size
self.app.after_request(self.after_request)
| (self, app, compress_level=6, minimum_size=500) | [
0.01401996985077858,
-0.03121046908199787,
-0.054943621158599854,
0.02749013714492321,
0.04028221592307091,
0.005191054195165634,
-0.049848783761262894,
0.013378533534705639,
-0.015486110933125019,
-0.03296983987092972,
0.045303747057914734,
0.045413706451654434,
-0.00781636219471693,
-0.0... |
724,439 | flask_gzip | after_request | null | def after_request(self, response):
accept_encoding = request.headers.get('Accept-Encoding', '')
if response.status_code < 200 or \
response.status_code >= 300 or \
response.direct_passthrough or \
len(response.get_data()) < self.minimum_size or \
'gzip' not in accept_encoding.lower()... | (self, response) | [
-0.012951995246112347,
-0.03501623496413231,
-0.03528368100523949,
0.014212808571755886,
0.0308708306401968,
0.050394341349601746,
-0.06162704527378082,
0.06965040415525436,
0.0032308350782841444,
-0.04943917691707611,
0.0775209367275238,
-0.002913243602961302,
0.009202984161674976,
-0.048... |
724,441 | hypertion.main | HyperFunction |
Handles the creation of a schema for LLM function calling, as well as the validation and invocation of functions based on the provided signature or metadata.
| class HyperFunction:
"""
Handles the creation of a schema for LLM function calling, as well as the validation and invocation of functions based on the provided signature or metadata.
"""
def __init__(self) -> None:
self._registered_functions: dict[str, info.FunctionInfo] = {}
"""Register... | () -> None | [
0.035233642905950546,
-0.05413581058382988,
-0.012806219048798084,
-0.0048106019385159016,
0.017304934561252594,
0.0013940349454060197,
-0.025858165696263313,
-0.04532739892601967,
-0.024913057684898376,
-0.011993425898253918,
-0.031528815627098083,
0.02604718692600727,
0.0041868300177156925... |
724,442 | hypertion.main | __init__ | null | def __init__(self) -> None:
self._registered_functions: dict[str, info.FunctionInfo] = {}
"""Registered functions."""
| (self) -> NoneType | [
0.0025312933139503,
-0.02618742175400257,
0.01623241975903511,
-0.02989336848258972,
0.001639077439904213,
0.03431781381368637,
0.0021803155541419983,
0.03549010306596756,
-0.024958409368991852,
-0.010474968701601028,
0.0004283818125259131,
0.03463924676179886,
0.021762976422905922,
0.0079... |
724,443 | hypertion.main | _construct_mappings | Construct schema mappings of registered functions. | def _construct_mappings(self):
"""Construct schema mappings of registered functions."""
for f_name, f_info in self._registered_functions.items():
signature = inspect.signature(f_info.memloc)
properties, required = {}, []
for name, instance in signature.parameters.items():
cri... | (self) | [
0.03298632800579071,
-0.015682483091950417,
-0.0058005619794130325,
-0.038912687450647354,
-0.010259306989610195,
0.03673223406076431,
-0.0076688556000590324,
-0.03846541419625282,
0.010622715577483177,
0.024991337209939957,
-0.01956816017627716,
0.06977447122335434,
0.009369421750307083,
... |
724,444 | hypertion.main | attach_hyperfunction | Attach new `HyperFunction` instance in the current instance | def attach_hyperfunction(self, __obj: "HyperFunction"):
"""Attach new `HyperFunction` instance in the current instance"""
self._registered_functions.update(__obj._registered_functions)
| (self, _HyperFunction__obj: hypertion.main.HyperFunction) | [
0.01703066937625408,
-0.040983814746141434,
0.0030673283617943525,
-0.0008540088310837746,
-0.011391089297831059,
0.04050165042281151,
-0.013440280221402645,
0.0013280994025990367,
-0.03740203380584717,
0.005553478840738535,
0.0005327465478330851,
-0.03905516490340233,
0.04449671134352684,
... |
724,445 | hypertion.main | criteria | Adding criteria to parameters. | @staticmethod
def criteria(
default: Any | None = None, *, description: str
):
"""Adding criteria to parameters."""
return info.CriteriaInfo(description=description, default=default)
| (default: Optional[Any] = None, *, description: str) | [
0.038382768630981445,
-0.026684841141104698,
0.02198871597647667,
-0.0030389183666557074,
-0.028397146612405777,
-0.0712725967168808,
-0.01964912936091423,
-0.03397485241293907,
0.05581098794937134,
-0.03624662756919861,
-0.015478563494980335,
0.015105586498975754,
-0.03221168741583824,
-0... |
724,446 | hypertion.main | invoke | Validate and invoke the function from signature or metadata. | def invoke(self, __signature_or_metadata: types.Signature | types.Metadata):
"""Validate and invoke the function from signature or metadata."""
function = __signature_or_metadata
if isinstance(function, types.Signature):
function = function.as_metadata()
function_info = self._registered_function... | (self, _HyperFunction__signature_or_metadata: hypertion.types.Signature | hypertion.types.Metadata) | [
0.06526566296815872,
-0.06767018884420395,
0.039617400616407394,
-0.003804778214544058,
-0.002881612628698349,
-0.013014965690672398,
-0.0158297847956419,
-0.023968910798430443,
-0.004012311343103647,
0.02927413024008274,
-0.007933976128697395,
0.044998954981565475,
-0.004002769943326712,
... |
724,447 | hypertion.main | takeover | Register the function by decorating it to generate function schema. | def takeover(self, description: str | None = None):
"""Register the function by decorating it to generate function schema."""
def __wrapper__(func: Callable[..., Any]):
_description = description or func.__doc__
if _description is None:
raise RuntimeError(f"No description found for {... | (self, description: Optional[str] = None) | [
-0.00018788872694130987,
-0.01232750341296196,
0.035193465650081635,
-0.02842891402542591,
0.05689343065023422,
0.00910544116050005,
-0.0013974137837067246,
-0.007610119413584471,
-0.024014154449105263,
-0.017187299206852913,
-0.01676006428897381,
0.04500206187367439,
-0.008099659346044064,
... |
724,455 | nylas.client | Client |
API client for the Nylas API.
Attributes:
api_key: The Nylas API key to use for authentication
api_uri: The URL to use for communicating with the Nylas API
http_client: The HTTP client to use for requests to the Nylas API
| class Client:
"""
API client for the Nylas API.
Attributes:
api_key: The Nylas API key to use for authentication
api_uri: The URL to use for communicating with the Nylas API
http_client: The HTTP client to use for requests to the Nylas API
"""
def __init__(
self, ap... | (api_key: str, api_uri: str = 'https://api.us.nylas.com', timeout: int = 90) | [
-0.022810233756899834,
-0.03643736615777016,
-0.08025071769952774,
-0.0004589821910485625,
0.004559280816465616,
-0.028194701299071312,
-0.0770052820444107,
0.0122533543035388,
0.02976209856569767,
0.011810795404016972,
-0.015323608182370663,
-0.010068219155073166,
-0.027862781658768654,
0... |
724,456 | nylas.client | __init__ |
Initialize the Nylas API client.
Args:
api_key: The Nylas API key to use for authentication
api_uri: The URL to use for communicating with the Nylas API
timeout: The timeout for requests to the Nylas API, in seconds
| def __init__(
self, api_key: str, api_uri: str = DEFAULT_SERVER_URL, timeout: int = 90
):
"""
Initialize the Nylas API client.
Args:
api_key: The Nylas API key to use for authentication
api_uri: The URL to use for communicating with the Nylas API
timeout: The timeout for requests... | (self, api_key: str, api_uri: str = 'https://api.us.nylas.com', timeout: int = 90) | [
-0.04924136400222778,
-0.02087240293622017,
-0.013375842012465,
0.0009210161515511572,
-0.014346209354698658,
0.02279411070048809,
-0.059401679784059525,
0.04071735963225365,
0.056775979697704315,
0.008823679760098457,
-0.012424502521753311,
0.017390497028827667,
-0.01094992458820343,
0.00... |
724,464 | json_logic | jsonLogic | null | def jsonLogic(tests, data=None):
# You've recursed to a primitive, stop!
if tests is None or type(tests) != dict:
return tests
data = data or {}
op = tests.keys()[0]
values = tests[op]
operations = {
"==" : (lambda a, b: a == b),
"===" : (lambda a, b: a is b),
"!=" : (lambda a, b: a != b... | (tests, data=None) | [
0.012337041087448597,
-0.05262332037091255,
0.03598993644118309,
-0.036762725561857224,
0.01873095892369747,
0.01795816794037819,
-0.07105988264083862,
-0.018280163407325745,
0.027802040800452232,
-0.06038802117109299,
0.04228265583515167,
0.08493330329656601,
0.03521714732050896,
-0.04772... |
724,466 | tlo.tl_config | TlConfig | null | class TlConfig(TlBase):
def __init__(
self,
):
self.types: List['TlType'] = []
self.id_to_type: Dict[int, 'TlType'] = {} # orig int32_t
self.name_to_type: Dict[str, 'TlType'] = {}
self.functions: List['TlCombinator'] = []
self.id_to_function: Dict[int, 'TlCombina... | () | [
0.02301243506371975,
-0.047546662390232086,
-0.009130740538239479,
0.01257332693785429,
0.008453357964754105,
0.011079373769462109,
-0.07015080749988556,
-0.05690010264515877,
-0.04324110969901085,
-0.04880863428115845,
-0.041756436228752136,
0.04465154930949211,
-0.009469431824982166,
0.0... |
724,467 | tlo.tl_config | __init__ | null | def __init__(
self,
):
self.types: List['TlType'] = []
self.id_to_type: Dict[int, 'TlType'] = {} # orig int32_t
self.name_to_type: Dict[str, 'TlType'] = {}
self.functions: List['TlCombinator'] = []
self.id_to_function: Dict[int, 'TlCombinator'] = {} # orig int32_t
self.name_to_function: Di... | (self) | [
0.0029999890830367804,
0.006137963384389877,
-0.005019807256758213,
0.005881024990230799,
-0.016881776973605156,
-0.0018616109155118465,
-0.03768423944711685,
-0.0076415264047682285,
-0.03387774899601936,
-0.021164078265428543,
-0.047504980117082596,
0.06425353139638901,
-0.02181118167936802... |
724,468 | tlo.tl_core | __repr__ | null | def __repr__(self):
return f'<{__name__}.{type(self).__name__}> {vars(self)}'
| (self) | [
0.02418082393705845,
-0.043834324926137924,
0.06819062680006027,
-0.00031394054531119764,
0.024812543764710426,
-0.04436075687408447,
0.0022921771742403507,
-0.03811375051736832,
0.01589827798306942,
-0.020864296704530716,
-0.03772770240902901,
0.0017240681918337941,
-0.02112751267850399,
... |
724,470 | tlo.tl_config | add_function | null | def add_function(self, function: 'TlCombinator') -> None:
self.functions.append(function)
self.id_to_function[function.id] = function
self.name_to_function[function.name] = function
| (self, function: tlo.tl_core.TlCombinator) -> NoneType | [
0.004137229640036821,
-0.0027276037726551294,
0.011277005076408386,
0.017910538241267204,
0.00026348652318120003,
0.04392096772789955,
-0.05031010881066322,
-0.008955269120633602,
-0.014209724962711334,
-0.0004012305289506912,
-0.03938223421573639,
0.008021337911486626,
-0.00280834105797112,... |
724,471 | tlo.tl_config | add_type | null | def add_type(self, type_: 'TlType') -> None:
self.types.append(type_)
self.id_to_type[type_.id] = type_
self.name_to_type[type_.name] = type_
| (self, type_: tlo.tl_core.TlType) -> NoneType | [
-0.04458535835146904,
0.05718475207686424,
0.014202442951500416,
0.025723764672875404,
0.01526176743209362,
0.011568194255232811,
-0.0054841116070747375,
0.05410990118980408,
-0.07443392276763916,
0.0007974226609803736,
-0.03262343257665634,
0.010180761106312275,
0.03669198974967003,
0.003... |
724,472 | tlo.tl_config | get_function | null | def get_function(self, function_id_or_name: Union[int, str]) -> 'TlCombinator': # orig int32_t
if isinstance(function_id_or_name, int):
return self.id_to_function[function_id_or_name]
else:
return self.name_to_function[function_id_or_name]
| (self, function_id_or_name: Union[int, str]) -> tlo.tl_core.TlCombinator | [
0.03269578889012337,
-0.046389803290367126,
0.05410374328494072,
0.020629484206438065,
-0.00371543038636446,
0.009262037463486195,
-0.00021949790243525058,
0.0016376643907278776,
-0.008045676164329052,
-0.02082410268485546,
-0.03276655822992325,
0.009465501643717289,
0.0026184937451034784,
... |
724,473 | tlo.tl_config | get_function_by_num | null | def get_function_by_num(self, num: int) -> 'TlCombinator': # orig size_t
return self.functions[num]
| (self, num: int) -> tlo.tl_core.TlCombinator | [
0.048157818615436554,
-0.05632132291793823,
0.009338295087218285,
0.02255254052579403,
0.01015293039381504,
0.06311281025409698,
-0.028898121789097786,
-0.06009437143802643,
-0.04122912883758545,
0.014946416951715946,
-0.012768339365720749,
-0.005668147932738066,
0.008090616203844547,
-0.0... |
724,474 | tlo.tl_config | get_function_count | null | def get_function_count(self) -> int: # orig size_t
return len(self.functions)
| (self) -> int | [
-0.05268010124564171,
-0.0535508468747139,
0.03347346559166908,
0.030174678191542625,
0.021534204483032227,
0.08339062333106995,
-0.026373540982604027,
-0.004864452872425318,
-0.024196676909923553,
-0.001442172098904848,
-0.008569307625293732,
-0.027009854093194008,
-0.015062222257256508,
... |
724,475 | tlo.tl_config | get_type | null | def get_type(self, type_id_or_name: Union[int, str]) -> 'TlType': # orig int32_t
if isinstance(type_id_or_name, int):
return self.id_to_type[type_id_or_name]
else:
return self.name_to_type[type_id_or_name]
| (self, type_id_or_name: Union[int, str]) -> tlo.tl_core.TlType | [
0.017218509688973427,
-0.010671406984329224,
0.01208624616265297,
0.025393139570951462,
-0.005455918610095978,
-0.006907747592777014,
0.0193638876080513,
0.03700777143239975,
-0.02182367444038391,
-0.03475142642855644,
-0.03776605427265167,
0.010615922510623932,
0.015896141529083252,
-0.04... |
724,476 | tlo.tl_config | get_type_by_num | null | def get_type_by_num(self, num: int) -> 'TlType': # orig size_t
return self.types[num]
| (self, num: int) -> tlo.tl_core.TlType | [
0.052217207849025726,
-0.015427003614604473,
-0.022518448531627655,
0.03200925514101982,
0.0003365770389791578,
0.02729939855635166,
0.006487161852419376,
-0.0051986160688102245,
-0.054065603762865067,
-0.02904115617275238,
-0.021114379167556763,
-0.00007734051905572414,
0.008651030249893665... |
724,477 | tlo.tl_config | get_type_count | null | def get_type_count(self) -> int: # orig size_t
return len(self.types)
| (self) -> int | [
-0.048145685344934464,
-0.03483642637729645,
0.031744033098220825,
0.04527539387345314,
0.033657558262348175,
0.0569274015724659,
-0.020502066239714622,
0.003963732626289129,
-0.021971380338072777,
-0.014829827472567558,
-0.014565009623765945,
-0.01860562525689602,
0.002321431878954172,
-0... |
724,478 | tlo.tl_config_parser | TlConfigParser | null | class TlConfigParser(TlBase):
def __init__(self, data: bytes):
self.p = TlSimpleParser(data)
self.schema_version = -1
self.config = TlConfig() # should be TlConfig
def parse_config(self) -> 'TlConfig':
self.schema_version = self.get_schema_version(self.try_parse_int())
... | (data: bytes) | [
0.011013606563210487,
0.024567289277911186,
-0.00838423240929842,
0.026214368641376495,
0.00955008715391159,
0.027901137247681618,
-0.02278129942715168,
-0.026750165969133377,
-0.03734704107046127,
-0.10708004236221313,
-0.005085111130028963,
0.06449409574270248,
-0.03097700886428356,
-0.0... |
724,479 | tlo.tl_config_parser | __init__ | null | def __init__(self, data: bytes):
self.p = TlSimpleParser(data)
self.schema_version = -1
self.config = TlConfig() # should be TlConfig
| (self, data: bytes) | [
0.036251336336135864,
0.011448736302554607,
0.013731294311583042,
-0.010145701467990875,
-0.04579494521021843,
-0.015879055485129356,
0.006856660824269056,
0.03330378234386444,
-0.004192178603261709,
-0.0069555118680000305,
0.0036979238502681255,
0.03671863302588463,
-0.052337080240249634,
... |
724,482 | tlo.tl_config_parser | get_schema_version | null | @staticmethod
def get_schema_version(version_id: int) -> int:
if version_id == TLS_SCHEMA_V4:
return 4
elif version_id == TLS_SCHEMA_V3:
return 3
elif version_id == TLS_SCHEMA_V2:
return 2
return -1
| (version_id: int) -> int | [
0.05542527139186859,
-0.04308956116437912,
-0.003504657419398427,
0.007218611892312765,
-0.016914617270231247,
-0.022774934768676758,
0.03316290304064751,
0.008717861957848072,
0.012720134109258652,
-0.026174943894147873,
-0.04855691269040108,
-0.0005261791520752013,
-0.016555821523070335,
... |
724,483 | tlo.tl_config_parser | parse_config | null | def parse_config(self) -> 'TlConfig':
self.schema_version = self.get_schema_version(self.try_parse_int())
if self.schema_version < 2:
raise RuntimeError(f'Unsupported tl-schema version {self.schema_version}')
self.try_parse_int() # date
self.try_parse_int() # version
types_n = self.try_par... | (self) -> tlo.tl_config.TlConfig | [
-0.0032569768372923136,
0.009389439597725868,
0.007863476872444153,
-0.015526670962572098,
-0.0343150869011879,
0.03528789058327675,
-0.015326389111578465,
-0.01279901247471571,
-0.06710421293973923,
-0.04314659908413887,
-0.04390957951545715,
0.023213708773255348,
-0.04352808743715286,
0.... |
724,484 | tlo.tl_config_parser | read_args_list | null | def read_args_list(self, tl_combinator: TlCombinator) -> List[Arg]:
schema_flag_opt_field = 2 << int(self.schema_version >= 3)
schema_flag_has_vars = schema_flag_opt_field ^ 6
args_num = self.try_parse_int()
args_list = []
for i in range(args_num):
arg = Arg()
arg_v = self.try_parse_... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> List[tlo.tl_core.Arg] | [
0.014142467640340328,
0.017625389620661736,
-0.04123296961188316,
0.010519024915993214,
0.034247055649757385,
0.026177115738391876,
0.01907075010240078,
-0.02129901759326458,
-0.03197863698005676,
0.0034829212818294764,
-0.01638077199459076,
0.04845978319644928,
-0.07005991786718369,
-0.03... |
724,485 | tlo.tl_config_parser | read_array | null | def read_array(self, tl_combinator: TlCombinator) -> TlTree:
flags = FLAG_NOVAR
multiplicity = self.read_nat_expr(tl_combinator)
tl_tree_array = TlTreeArray(flags, multiplicity, self.read_args_list(tl_combinator))
for i in range(len(tl_tree_array.args)):
if not (tl_tree_array.args[i].flags & FLA... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.031266842037439346,
0.06169787421822548,
0.04065069183707237,
-0.004905626643449068,
0.005038596224039793,
0.01679215580224991,
-0.07035989314317703,
-0.04927472025156021,
-0.054365552961826324,
-0.027714654803276062,
0.000535439932718873,
0.02446639910340309,
-0.05527734383940697,
-0.02... |
724,486 | tlo.tl_config_parser | read_combinator | null | def read_combinator(self):
t = self.try_parse_int()
if t != TLS_COMBINATOR:
raise RuntimeError(f'Wrong tls_combinator magic {t}')
tl_combinator = TlCombinator()
tl_combinator.id = self.try_parse_int()
tl_combinator.name = self.try_parse_string()
tl_combinator.type_id = self.try_parse_int... | (self) | [
-0.0037868740037083626,
-0.0033475253731012344,
0.043390706181526184,
0.018135959282517433,
0.022266283631324768,
0.005588872823864222,
-0.02856435999274254,
-0.017841573804616928,
-0.05127668380737305,
-0.023176204413175583,
0.025317193940281868,
0.09620176255702972,
-0.03323885053396225,
... |
724,487 | tlo.tl_config_parser | read_expr | null | def read_expr(self, tl_combinator: TlCombinator) -> TlTree:
tree_type = self.try_parse_int()
if tree_type == TLS_EXPR_NAT:
return self.read_nat_expr(tl_combinator)
elif tree_type == TLS_EXPR_TYPE:
return self.read_type_expr(tl_combinator)
else:
raise RuntimeError(f'tree_type = {t... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.04721822217106819,
-0.028400156646966934,
0.06572660058736801,
0.015602780506014824,
0.01565743051469326,
0.02193315513432026,
0.014946972019970417,
-0.041461680084466934,
-0.0974968820810318,
-0.06029795855283737,
0.05308406427502632,
0.015593672171235085,
-0.004274141509085894,
0.01134... |
724,488 | tlo.tl_config_parser | read_nat_expr | null | def read_nat_expr(self, tl_combinator: TlCombinator) -> TlTree:
tree_type = self.try_parse_int()
if tree_type in (TLS_NAT_CONST_OLD, TLS_NAT_CONST):
return self.read_num_const()
elif tree_type == TLS_NAT_VAR:
return self.read_num_var(tl_combinator)
else:
raise RuntimeError(f'tree... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.020039750263094902,
-0.0005400775698944926,
0.07125645130872726,
0.01594890095293522,
0.03579041734337807,
0.04051201045513153,
-0.005473987199366093,
-0.03478122130036354,
-0.07309462875127792,
-0.0667150691151619,
0.007645560894161463,
0.041268907487392426,
-0.013606125488877296,
-0.00... |
724,489 | tlo.tl_config_parser | read_num_const | null | def read_num_const(self) -> TlTree:
num = self.try_parse_int()
return TlTreeNatConst(FLAG_NOVAR, num)
| (self) -> tlo.tl_core.TlTree | [
0.004203371703624725,
0.019267627969384193,
0.03282633051276207,
0.003513687988743186,
0.0318516343832016,
0.04883917421102524,
-0.009224790148437023,
-0.004242533352226019,
-0.04333911091089249,
-0.074076808989048,
0.008889739401638508,
0.02400186099112034,
-0.009799164719879627,
-0.04507... |
724,490 | tlo.tl_config_parser | read_num_var | null | def read_num_var(self, tl_combinator: TlCombinator) -> TlTree:
diff = self.try_parse_int()
var_num = self.try_parse_int()
if var_num >= tl_combinator.var_count:
tl_combinator.var_count = var_num + 1
return TlTreeVarNum(0, var_num, diff)
| (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.02961825206875801,
0.03087296150624752,
0.008464882150292397,
0.030272115021944046,
0.037782710045576096,
0.07952394336462021,
-0.01852024346590042,
-0.0019483366049826145,
-0.08715824037790298,
-0.002611036179587245,
-0.0011260369792580605,
0.0020190246868878603,
-0.02530628629028797,
-... |
724,491 | tlo.tl_config_parser | read_type | null | def read_type(self):
t = self.try_parse_int()
if t != TLS_TYPE:
raise RuntimeError(f'Wrong tls_type magic {t}')
tl_type = TlType()
tl_type.id = self.try_parse_int()
tl_type.name = self.try_parse_string()
tl_type.constructors_num = self.try_parse_int() # orig size_t
tl_type.construct... | (self) | [
0.016319405287504196,
0.02950369380414486,
-0.010235784575343132,
0.01540499646216631,
0.010039839893579483,
0.007669840473681688,
0.01910928636789322,
0.024577079340815544,
-0.08143840730190277,
-0.05124424025416374,
-0.039412904530763626,
0.07419777661561966,
-0.023644009605050087,
-0.01... |
724,492 | tlo.tl_config_parser | read_type_expr | null | def read_type_expr(self, tl_combinator: TlCombinator) -> TlTree:
tree_type = self.try_parse_int()
if tree_type == TLS_TYPE_VAR:
return self.read_type_var(tl_combinator)
elif tree_type == TLS_TYPE_EXPR:
return self.read_type_tree(tl_combinator)
elif tree_type == TLS_ARRAY:
return ... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.04491338133811951,
-0.006424040999263525,
0.055784836411476135,
0.009425587952136993,
0.03653101623058319,
0.027929022908210754,
0.004776851274073124,
-0.033547770231962204,
-0.11076437681913376,
-0.04088691622018814,
0.039605770260095596,
0.01996760442852974,
0.010834850370883942,
-0.01... |
724,493 | tlo.tl_config_parser | read_type_tree | null | def read_type_tree(self, tl_combinator: TlCombinator) -> TlTree:
tl_type = self.config.get_type(self.try_parse_int())
# there is assert not needed because we have KeyError exception
flags = self.try_parse_int() | FLAG_NOVAR
arity = self.try_parse_int()
assert tl_type.arity == arity
tl_tree_type ... | (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.0345333106815815,
0.04352299124002457,
0.03877157345414162,
-0.0304280836135149,
0.0437130481004715,
0.04318089038133621,
-0.0383344441652298,
-0.024745387956500053,
-0.09776518493890762,
-0.03871455788612366,
0.002129823202267289,
0.040101971477270126,
-0.048274412751197815,
-0.01574620... |
724,494 | tlo.tl_config_parser | read_type_var | null | def read_type_var(self, tl_combinator: TlCombinator) -> TlTree:
var_num = self.try_parse_int()
flags = self.try_parse_int()
if var_num >= tl_combinator.var_count:
tl_combinator.var_count = var_num + 1
assert not (flags & (FLAG_NOVAR | FLAG_BARE))
return TlTreeVarType(flags, var_num)
| (self, tl_combinator: tlo.tl_core.TlCombinator) -> tlo.tl_core.TlTree | [
0.047258052974939346,
0.03372490033507347,
0.00861118733882904,
-0.013560145162045956,
0.041643235832452774,
0.05456451326608658,
0.00380394933745265,
-0.03800800070166588,
-0.1176232397556305,
-0.03365291655063629,
-0.006051226053386927,
0.05665207654237747,
-0.0413912869989872,
-0.030377... |
724,495 | tlo.tl_config_parser | try_parse | null | def try_parse(self, res):
if self.p.get_error():
raise RuntimeError(f'Wrong TL-scheme specified: {self.p.get_error()} at {self.p.get_error_pos()}')
return res
| (self, res) | [
-0.00462120259180665,
0.024006683379411697,
0.012264284305274487,
0.024225538596510887,
-0.03632989153265953,
0.006157394498586655,
0.034915752708911896,
0.04589216038584709,
0.05097632482647896,
-0.02808074839413166,
0.043198563158512115,
0.0457574799656868,
0.014461249113082886,
-0.00521... |
724,496 | tlo.tl_config_parser | try_parse_int | null | def try_parse_int(self) -> int: # orig int32_t
return self.try_parse(self.p.fetch_int())
| (self) -> int | [
-0.024506105110049248,
-0.012789496220648289,
-0.02155992202460766,
0.05337187647819519,
0.028831712901592255,
0.011869878508150578,
0.059468600898981094,
0.051975421607494354,
-0.017319463193416595,
-0.11750669032335281,
0.006918419152498245,
0.03695500269532204,
-0.00571354990825057,
-0.... |
724,497 | tlo.tl_config_parser | try_parse_long | null | def try_parse_long(self) -> int: # orig int64_t
return self.try_parse(self.p.fetch_long())
| (self) -> int | [
0.017970558255910873,
0.04651203379034996,
0.023742614313960075,
0.12201858311891556,
-0.0030622100457549095,
-0.007684888783842325,
0.0248164851218462,
0.02760183811187744,
-0.0075296806171536446,
-0.11107852309942245,
-0.0013360463781282306,
0.042283665388822556,
-0.04634423926472664,
-0... |
724,498 | tlo.tl_config_parser | try_parse_string | null | def try_parse_string(self) -> str:
return self.try_parse(self.p.fetch_string())
| (self) -> str | [
0.009681814350187778,
0.0347345806658268,
-0.02044319361448288,
0.03663666918873787,
-0.006584490183740854,
-0.027640294283628464,
0.07539819926023483,
0.04102347418665886,
0.04355959594249725,
-0.08053898811340332,
0.0167161226272583,
0.07341042906045914,
-0.06635041534900665,
0.041263379... |
724,499 | tlo | read_tl_config | null | def read_tl_config(data: bytes) -> TlConfig:
if not data:
raise RuntimeError(f'Config data is empty')
if len(data) % struct.calcsize('i') != 0:
raise RuntimeError(f'Config size = {len(data)} is not multiple of {struct.calcsize("i")}')
parser = TlConfigParser(data)
return parser.parse_co... | (data: bytes) -> tlo.tl_config.TlConfig | [
0.01067348849028349,
0.015582741238176823,
0.023056941106915474,
-0.02156761661171913,
-0.03864887356758118,
0.024435944855213165,
0.0021776766516268253,
-0.011252669617533684,
-0.030650654807686806,
-0.03263641893863678,
0.03226868435740471,
-0.017881080508232117,
-0.044238436967134476,
-... |
724,500 | tlo | read_tl_config_from_file | null | def read_tl_config_from_file(file_name: str) -> TlConfig:
with open(file_name, 'rb') as config:
return read_tl_config(config.read())
| (file_name: str) -> tlo.tl_config.TlConfig | [
-0.013133353553712368,
-0.03492933139204979,
0.04022728651762009,
0.0016346982447430491,
-0.06506261974573135,
0.012742978520691395,
-0.04093367978930473,
0.01126512698829174,
0.022548843175172806,
-0.002430553548038006,
-0.01972326822578907,
-0.012910282239317894,
-0.0763649195432663,
0.0... |
724,506 | domain2idna.converter | Converter |
Provides a base for every core logic we add.
:param subject: The subject to convert.
:type subject: str, list
:param str original_encoding:
The encoding to provide as output.
| class Converter:
"""
Provides a base for every core logic we add.
:param subject: The subject to convert.
:type subject: str, list
:param str original_encoding:
The encoding to provide as output.
"""
to_ignore = [
"0.0.0.0",
"localhost",
"127.0.0.1",
... | (subject, original_encoding='utf-8') | [
-0.016016362234950066,
0.01554726343601942,
-0.010932866483926773,
-0.023665539920330048,
-0.02224867045879364,
-0.049935054033994675,
-0.03731726109981537,
-0.009673959575593472,
0.09764906764030457,
-0.05422395467758179,
-0.015939773991703987,
0.035268545150756836,
0.020640332251787186,
... |
724,507 | domain2idna.converter | __get_converted |
Process the actual conversion.
:param str subject: The subject to convert.
:rtype: str
| def __get_converted(self, subject):
"""
Process the actual conversion.
:param str subject: The subject to convert.
:rtype: str
"""
if (
not subject
or not subject.strip()
or subject in self.to_ignore
or subject.startswith("#")
):
return subject
if ... | (self, subject) | [
-0.026041096076369286,
0.07649128884077072,
0.042432088404893875,
-0.03576216101646423,
0.006798535585403442,
-0.08486417680978775,
-0.015645945444703102,
0.011858632788062096,
0.13119888305664062,
-0.043035220354795456,
-0.013215679675340652,
0.004838357679545879,
-0.02524283342063427,
0.... |
724,508 | domain2idna.converter | __init__ | null | def __init__(self, subject, original_encoding="utf-8"):
self.subject = subject
self.encoding = original_encoding
| (self, subject, original_encoding='utf-8') | [
-0.014088485389947891,
0.05446517467498779,
0.01616612821817398,
-0.0026077863294631243,
-0.04989778995513916,
-0.0588265098631382,
-0.04017922654747963,
0.00774823734536767,
0.13173291087150574,
-0.03155957907438278,
-0.00579078821465373,
0.010345292277634144,
-0.03404931724071503,
0.0688... |
724,509 | domain2idna.converter | convert_to_idna |
Converts the given subject to IDNA.
:param str subject: The subject to convert.
:rtype: str
| def convert_to_idna(self, subject, original_encoding="utf-8"):
"""
Converts the given subject to IDNA.
:param str subject: The subject to convert.
:rtype: str
"""
if subject in self.to_ignore:
return subject
if "://" not in subject:
try:
return subject.encode("idn... | (self, subject, original_encoding='utf-8') | [
-0.03233397752046585,
0.07280921936035156,
0.029383214190602303,
-0.010007712990045547,
-0.00973218958824873,
-0.051087331026792526,
-0.05261604115366936,
-0.044865839183330536,
0.13239333033561707,
-0.039710890501737595,
-0.03580023720860481,
0.012176346965134144,
-0.00491942185908556,
0.... |
724,510 | domain2idna.converter | get_converted |
Provides the converted data.
| def get_converted(self):
"""
Provides the converted data.
"""
if isinstance(self.subject, list):
return [self.__get_converted(x) for x in self.subject]
return self.__get_converted(self.subject)
| (self) | [
0.006671716459095478,
0.01841937005519867,
-0.005449417047202587,
-0.020167935639619827,
-0.028978675603866577,
-0.03147420287132263,
-0.020286770537495613,
-0.036125730723142624,
0.14436711370944977,
-0.007057928945869207,
-0.00009250799485016614,
-0.028299620375037193,
-0.00873434636741876... |
724,512 | domain2idna | domain2idna |
Process the conversion of the given subject.
:param subject: The subject to convert.
:type subject: str, list
:param str encoding: The encoding to provide.
:rtype: list, str
| def domain2idna(subject, encoding="utf-8"):
"""
Process the conversion of the given subject.
:param subject: The subject to convert.
:type subject: str, list
:param str encoding: The encoding to provide.
:rtype: list, str
"""
return Converter(subject, original_encoding=encoding).get_c... | (subject, encoding='utf-8') | [
-0.02039768546819687,
0.10526087135076523,
0.02068593166768551,
-0.03998149558901787,
-0.004705201834440231,
-0.01565009355545044,
-0.052901726216077805,
-0.07711444050073624,
0.12113139033317566,
-0.021025044843554497,
-0.031062807887792587,
-0.015378803014755249,
-0.02034681849181652,
0.... |
724,513 | domain2idna | get |
This function is a passerelle between the front
and the backend of this module.
:param str domain_to_convert:
The domain to convert.
:return:
str:
if a string is given.
list:
if a list is given.
:rtype: str, list
.. deprecated:: 1.10.0
... | def get(domain_to_convert): # pragma: no cover
"""
This function is a passerelle between the front
and the backend of this module.
:param str domain_to_convert:
The domain to convert.
:return:
str:
if a string is given.
list:
if a list is given.
... | (domain_to_convert) | [
-0.010772229172289371,
0.0284286979585886,
0.01269838958978653,
-0.016015665605664253,
0.0280363317579031,
0.0556802973151207,
0.01633669249713421,
-0.04958079010248184,
0.07925792783498764,
-0.05774913728237152,
-0.031050415709614754,
-0.029498787596821785,
-0.01652395725250244,
-0.015213... |
724,566 | markov_clustering.utils | MessagePrinter | null | class MessagePrinter(object):
def __init__(self, enabled):
self._enabled = enabled
def enable(self):
self._enabled = True
def disable(self):
self._enabled = False
def print(self, string):
if self._enabled:
print(string)
| (enabled) | [
0.027348656207323074,
-0.010444581508636475,
-0.00511376466602087,
-0.013023169711232185,
0.03768036887049675,
-0.02526494860649109,
-0.02602897398173809,
0.004254235420376062,
0.005530505906790495,
-0.01680857129395008,
-0.0054870955646038055,
0.0012035579420626163,
-0.012215732596814632,
... |
724,567 | markov_clustering.utils | __init__ | null | def __init__(self, enabled):
self._enabled = enabled
| (self, enabled) | [
0.023216433823108673,
-0.01816137693822384,
0.009515892714262009,
0.01257905550301075,
-0.0013516417238861322,
0.0004192495543975383,
-0.013708910904824734,
0.04827411472797394,
-0.029292544350028038,
0.002299464773386717,
-0.017341187223792076,
0.04737022891640663,
-0.006398328579962254,
... |
724,568 | markov_clustering.utils | disable | null | def disable(self):
self._enabled = False
| (self) | [
0.047044284641742706,
0.05748730152845383,
0.03085591271519661,
0.012453892268240452,
-0.029132306575775146,
-0.008157553151249886,
-0.05025491863489151,
0.024857090786099434,
0.002614979399368167,
-0.0008787006954662502,
-0.045760028064250946,
-0.0002113581431331113,
-0.011304822750389576,
... |
724,569 | markov_clustering.utils | enable | null | def enable(self):
self._enabled = True
| (self) | [
0.01791684329509735,
0.021637646481394768,
0.021386241540312767,
0.025978585705161095,
0.031442467123270035,
0.019609641283750534,
-0.01695312187075615,
0.02234158292412758,
-0.016224045306444168,
0.020849909633398056,
-0.013626187108457088,
-0.03885055333375931,
0.024771837517619133,
0.04... |
724,570 | markov_clustering.utils | print | null | def print(self, string):
if self._enabled:
print(string)
| (self, string) | [
0.008533840999007225,
0.027992328628897667,
-0.0014485946157947183,
0.006396230310201645,
0.0912490114569664,
-0.03569602966308594,
-0.0025319275446236134,
0.022280963137745857,
0.002540229121223092,
-0.03166154772043228,
-0.019425280392169952,
0.01091634389013052,
-0.008135373704135418,
0... |
724,571 | markov_clustering.mcl | add_self_loops |
Add self-loops to the matrix by setting the diagonal
to loop_value
:param matrix: The matrix to add loops to
:param loop_value: Value to use for self-loops
:returns: The matrix with self-loops
| def add_self_loops(matrix, loop_value):
"""
Add self-loops to the matrix by setting the diagonal
to loop_value
:param matrix: The matrix to add loops to
:param loop_value: Value to use for self-loops
:returns: The matrix with self-loops
"""
shape = matrix.shape
assert shape[0] =... | (matrix, loop_value) | [
0.004331158474087715,
-0.0085945725440979,
-0.0039043657016009092,
0.0702018067240715,
-0.04270640015602112,
-0.006006716284900904,
-0.03567899018526077,
0.02986196056008339,
0.03638353943824768,
0.02310553379356861,
-0.06366216391324997,
0.013567049987614155,
0.03204786404967308,
0.036564... |
724,572 | markov_clustering.mcl | converged |
Check for convergence by determining if
matrix1 and matrix2 are approximately equal.
:param matrix1: The matrix to compare with matrix2
:param matrix2: The matrix to compare with matrix1
:returns: True if matrix1 and matrix2 approximately equal
| def converged(matrix1, matrix2):
"""
Check for convergence by determining if
matrix1 and matrix2 are approximately equal.
:param matrix1: The matrix to compare with matrix2
:param matrix2: The matrix to compare with matrix1
:returns: True if matrix1 and matrix2 approximately equal
"""
... | (matrix1, matrix2) | [
0.007200032006949186,
-0.030003082007169724,
0.0469505749642849,
0.04259871318936348,
-0.0008480381802655756,
-0.024589790031313896,
-0.03817608952522278,
0.004891422111541033,
0.01625756546854973,
0.0371854230761528,
-0.019229568541049957,
-0.009384808130562305,
0.0192649494856596,
0.0395... |
724,573 | markov_clustering.modularity | convert_to_adjacency_matrix |
Converts transition matrix into adjacency matrix
:param matrix: The matrix to be converted
:returns: adjacency matrix
| def convert_to_adjacency_matrix(matrix):
"""
Converts transition matrix into adjacency matrix
:param matrix: The matrix to be converted
:returns: adjacency matrix
"""
for i in range(matrix.shape[0]):
if isspmatrix(matrix):
col = find(matrix[:,i])[2]
else:
... | (matrix) | [
-0.02168875001370907,
0.032731276005506516,
0.03147030249238014,
0.018914606422185898,
0.021508609876036644,
-0.015374873764812946,
0.019527079537510872,
0.03001117706298828,
0.008903375826776028,
0.021148331463336945,
-0.053285151720047,
0.01212336216121912,
-0.04229666292667389,
0.036478... |
724,574 | scipy.sparse._csc | csc_matrix |
Compressed Sparse Column matrix.
This can be instantiated in several ways:
csc_matrix(D)
where D is a 2-D ndarray
csc_matrix(S)
with another sparse array or matrix S (equivalent to S.tocsc())
csc_matrix((M, N), [dtype])
to construct an empty matrix... | class csc_matrix(spmatrix, _csc_base):
"""
Compressed Sparse Column matrix.
This can be instantiated in several ways:
csc_matrix(D)
where D is a 2-D ndarray
csc_matrix(S)
with another sparse array or matrix S (equivalent to S.tocsc())
csc_matrix((M, N), [dt... | (arg1, shape=None, dtype=None, copy=False) | [
-0.021268777549266815,
0.0032556334044784307,
0.041537389159202576,
-0.007863528095185757,
0.03416883945465088,
-0.017645737156271935,
-0.00799109973013401,
0.046619851142168045,
0.05049803480505943,
-0.03649575263261795,
-0.06315316259860992,
-0.017155861482024193,
0.054090458899736404,
0... |
724,575 | scipy.sparse._data | __abs__ | null | def __abs__(self):
return self._with_data(abs(self._deduped_data()))
| (self) | [
0.05945440009236336,
-0.0134688476100564,
0.02502300590276718,
0.04400483891367912,
0.0215732641518116,
-0.04813132435083389,
0.00731213204562664,
-0.025452161207795143,
0.004799102433025837,
0.0033775281626731157,
-0.027350343763828278,
0.028291182592511177,
0.028192147612571716,
0.001516... |
724,576 | scipy.sparse._base | __add__ | null | def __add__(self, other): # self + other
if isscalarlike(other):
if other == 0:
return self.copy()
# Now we would add this scalar to every element.
raise NotImplementedError('adding a nonzero scalar to a '
'sparse array is not supported')
el... | (self, other) | [
-0.05676741153001785,
-0.048298947513103485,
0.036547161638736725,
0.07119250297546387,
0.007226003333926201,
-0.025746282190084457,
-0.05780802667140961,
-0.012747549451887608,
0.04851424694061279,
-0.010325425304472446,
-0.017636651173233986,
-0.04252173379063606,
0.02841958962380886,
0.... |
724,577 | scipy.sparse._base | __bool__ | null | def __bool__(self): # Simple -- other ideas?
if self.shape == (1, 1):
return self.nnz != 0
else:
raise ValueError("The truth value of an array with more than one "
"element is ambiguous. Use a.any() or a.all().")
| (self) | [
-0.03144470974802971,
-0.03603222593665123,
0.031233787536621094,
0.018420377746224403,
-0.012962812557816505,
0.0009134389110840857,
-0.04594548046588898,
-0.009315649047493935,
-0.008924567140638828,
-0.004288713913410902,
0.012602490372955799,
0.017717309296131134,
0.049460820853710175,
... |
724,578 | scipy.sparse._base | __div__ | null | def __div__(self, other):
# Always do true division
return self._divide(other, true_divide=True)
| (self, other) | [
-0.008056903257966042,
-0.04189755767583847,
0.007990557700395584,
0.07185281813144684,
0.0050837695598602295,
-0.02842930145561695,
-0.015516692772507668,
-0.04332399740815163,
-0.0026807968970388174,
0.03841438889503479,
0.058915331959724426,
-0.04329082742333412,
0.07178647071123123,
0.... |
724,579 | scipy.sparse._compressed | __eq__ | null | def __eq__(self, other):
# Scalar other.
if isscalarlike(other):
if np.isnan(other):
return self.__class__(self.shape, dtype=np.bool_)
if other == 0:
warn("Comparing a sparse matrix with 0 using == is inefficient"
", try using != instead.", SparseEfficien... | (self, other) | [
0.03789824619889259,
-0.06578563153743744,
0.05551133304834366,
0.055134985595941544,
-0.03951654210686684,
-0.055134985595941544,
-0.0745169073343277,
0.00170297478325665,
0.001664163894020021,
-0.01311572827398777,
-0.03315626084804535,
-0.02214808203279972,
0.04836072027683258,
0.021207... |
724,580 | scipy.sparse._compressed | __ge__ | null | def __ge__(self, other):
return self._inequality(other, operator.ge, '_ge_',
"Comparing a sparse matrix with a scalar "
"less than zero using >= is inefficient, "
"try using < instead.")
| (self, other) | [
0.02673347108066082,
-0.016823945567011833,
0.03239850327372551,
0.06657695770263672,
0.00235757720656693,
-0.04583369940519333,
-0.054664988070726395,
-0.0053869145922362804,
0.025997530668973923,
-0.041828811168670654,
-0.015480426140129566,
-0.025021981447935104,
0.04343761131167412,
0.... |
724,581 | scipy.sparse._index | __getitem__ | null | def __getitem__(self, key):
row, col = self._validate_indices(key)
# Dispatch to specialized methods.
if isinstance(row, INT_TYPES):
if isinstance(col, INT_TYPES):
return self._get_intXint(row, col)
elif isinstance(col, slice):
self._raise_on_1d_array_slice()
... | (self, key) | [
0.047574859112501144,
-0.07890281081199646,
-0.02359938621520996,
0.05900786817073822,
0.026213183999061584,
-0.019932549446821213,
0.004078180994838476,
0.03311435878276825,
0.06246785819530487,
-0.05457005649805069,
-0.0011212059762328863,
0.026363618671894073,
0.0032014306634664536,
-0.... |
724,582 | scipy.sparse._compressed | __gt__ | null | def __gt__(self, other):
return self._inequality(other, operator.gt, '_gt_',
"Comparing a sparse matrix with a scalar "
"less than zero using > is inefficient, "
"try using <= instead.")
| (self, other) | [
0.004713092930614948,
-0.004811460617929697,
0.015422334894537926,
0.033975325524806976,
0.014977541752159595,
-0.052896127104759216,
-0.058473147451877594,
0.01744956336915493,
0.020169641822576523,
-0.05577017366886139,
-0.014755145646631718,
-0.0009922301396727562,
0.039757631719112396,
... |
724,583 | scipy.sparse._base | __iadd__ | null | def __iadd__(self, other):
return NotImplemented
| (self, other) | [
-0.07062508910894394,
-0.045580971986055374,
0.03765089809894562,
0.1007864773273468,
-0.030500277876853943,
-0.05998387932777405,
-0.03061889111995697,
-0.013504845090210438,
0.013894570991396904,
-0.04019258916378021,
0.025654122233390808,
-0.024095220491290092,
0.018639057874679565,
0.0... |
724,584 | scipy.sparse._base | __idiv__ | null | def __idiv__(self, other):
return self.__itruediv__(other)
| (self, other) | [
0.012003117240965366,
-0.03745174780488014,
0.054828010499477386,
0.05860692635178566,
-0.0063684843480587006,
-0.04217539355158806,
-0.015065050683915615,
-0.036169618368148804,
0.02108769677579403,
0.01754496432840824,
0.015756726264953613,
-0.02037915028631687,
0.015714552253484726,
0.0... |
724,585 | scipy.sparse._data | __imul__ | null | def __imul__(self, other): # self *= other
if isscalarlike(other):
self.data *= other
return self
else:
return NotImplemented
| (self, other) | [
0.016485122963786125,
-0.056423310190439224,
0.04863961040973663,
0.07192272692918777,
-0.04561450704932213,
-0.06509074568748474,
-0.00838701892644167,
-0.04904749244451523,
0.019068360328674316,
0.01940825954079628,
0.027157966047525406,
-0.021090760827064514,
0.030794890597462654,
0.049... |
724,586 | scipy.sparse._compressed | __init__ | null | def __init__(self, arg1, shape=None, dtype=None, copy=False):
_data_matrix.__init__(self)
if issparse(arg1):
if arg1.format == self.format and copy:
arg1 = arg1.copy()
else:
arg1 = arg1.asformat(self.format)
self.indptr, self.indices, self.data, self._shape = (
... | (self, arg1, shape=None, dtype=None, copy=False) | [
0.00389383127912879,
-0.015434006229043007,
0.07978442311286926,
0.007227435242384672,
-0.01372808963060379,
-0.029454827308654785,
-0.022833043709397316,
0.04788680747151375,
0.0027178588788956404,
-0.0021021137945353985,
-0.0718705877661705,
0.03216006979346275,
-0.051439959555864334,
0.... |
724,587 | scipy.sparse._base | __isub__ | null | def __isub__(self, other):
return NotImplemented
| (self, other) | [
-0.02094244211912155,
-0.019279560074210167,
-0.028927572071552277,
0.05634043738245964,
-0.08996029943227768,
-0.04251052439212799,
-0.012134104035794735,
0.025206666439771652,
0.033109474927186966,
-0.010166633874177933,
0.013813450001180172,
-0.020893050357699394,
-0.006186417303979397,
... |
724,588 | scipy.sparse._csc | __iter__ | null | def __iter__(self):
yield from self.tocsr()
| (self) | [
0.009615830145776272,
-0.025106562301516533,
0.012354571372270584,
0.018972475081682205,
-0.019594522193074226,
-0.019439009949564934,
-0.04081328213214874,
-0.011939872056245804,
0.09455134719610214,
0.02533118985593319,
-0.0229985099285841,
-0.011196870356798172,
0.06344892829656601,
0.0... |
724,589 | scipy.sparse._data | __itruediv__ | null | def __itruediv__(self, other): # self /= other
if isscalarlike(other):
recip = 1.0 / other
self.data *= recip
return self
else:
return NotImplemented
| (self, other) | [
0.002973110880702734,
-0.03823070973157883,
0.03742622211575508,
0.08772426098585129,
-0.002291044220328331,
-0.07233404368162155,
-0.022822998464107513,
-0.07527217268943787,
0.020287109538912773,
0.037566132843494415,
0.048933908343315125,
0.004059608094394207,
0.03490782156586647,
0.054... |
724,590 | scipy.sparse._compressed | __le__ | null | def __le__(self, other):
return self._inequality(other, operator.le, '_le_',
"Comparing a sparse matrix with a scalar "
"greater than zero using <= is inefficient, "
"try using > instead.")
| (self, other) | [
-0.014044031500816345,
0.0023635076358914375,
0.030280301347374916,
0.06816492974758148,
0.02051798813045025,
-0.03928903490304947,
-0.05336732044816017,
-0.0014054735656827688,
0.00502245407551527,
-0.043879035860300064,
-0.006653788033872843,
-0.02145996503531933,
0.06230754405260086,
0.... |
724,591 | scipy.sparse._base | __len__ | null | def __len__(self):
raise TypeError("sparse array length is ambiguous; use getnnz()"
" or shape[0]")
| (self) | [
-0.05951324477791786,
-0.004346800502389669,
0.04524340108036995,
0.05041121691465378,
0.01785397343337536,
0.022338304668664932,
-0.033590808510780334,
0.008205993101000786,
0.07294956594705582,
-0.03147367015480995,
-0.03490776941180229,
-0.03914204239845276,
0.010252281092107296,
-0.044... |
724,592 | scipy.sparse._compressed | __lt__ | null | def __lt__(self, other):
return self._inequality(other, operator.lt, '_lt_',
"Comparing a sparse matrix with a scalar "
"greater than zero using < is inefficient, "
"try using >= instead.")
| (self, other) | [
-0.010858332738280296,
-0.005692141596227884,
0.03228657320141792,
0.045876454561948776,
0.03238837048411369,
-0.027722680941224098,
-0.019578929990530014,
-0.0016913125291466713,
0.006744042504578829,
-0.04879463091492653,
-0.019222641363739967,
-0.03003007546067238,
0.040684815496206284,
... |
724,593 | scipy.sparse._base | __matmul__ | null | def __matmul__(self, other):
if isscalarlike(other):
raise ValueError("Scalar operands are not allowed, "
"use '*' instead")
return self._matmul_dispatch(other)
| (self, other) | [
-0.004787989426404238,
-0.05774787813425064,
0.08121117204427719,
0.05578973889350891,
-0.05012144893407822,
-0.0622825101017952,
-0.04950308799743652,
-0.03710155189037323,
-0.0009930247906595469,
0.02468283846974373,
-0.021539511159062386,
-0.02064632624387741,
0.04197971895337105,
0.067... |
724,594 | scipy.sparse._matrix | __mul__ | null | def __mul__(self, other):
return self._matmul_dispatch(other)
| (self, other) | [
-0.002907684538513422,
-0.05206804350018501,
0.07330678403377533,
0.08551295846700668,
-0.06713394820690155,
-0.07023780047893524,
-0.061449360102415085,
-0.036653392016887665,
-0.004230746533721685,
0.0344562791287899,
-0.012328234501183033,
-0.040419869124889374,
0.06919156014919281,
0.0... |
724,595 | scipy.sparse._compressed | __ne__ | null | def __ne__(self, other):
# Scalar other.
if isscalarlike(other):
if np.isnan(other):
warn("Comparing a sparse matrix with nan using != is"
" inefficient", SparseEfficiencyWarning, stacklevel=3)
all_true = self.__class__(np.ones(self.shape, dtype=np.bool_))
... | (self, other) | [
0.010734646581113338,
-0.03824451565742493,
0.07316017150878906,
0.0465666726231575,
-0.06878402084112167,
-0.06466969847679138,
-0.09036552906036377,
0.007868645712733269,
0.019374728202819824,
-0.014428188093006611,
-0.023115022107958794,
-0.016073917970061302,
0.020160188898444176,
0.00... |
724,596 | scipy.sparse._data | __neg__ | null | def __neg__(self):
if self.dtype.kind == 'b':
raise NotImplementedError('negating a boolean sparse array is not '
'supported')
return self._with_data(-self.data)
| (self) | [
0.011806182563304901,
-0.024134837090969086,
0.051539335399866104,
-0.0028483152855187654,
-0.013474722392857075,
-0.03792135789990425,
-0.07058428227901459,
0.014873598702251911,
0.023174162954092026,
-0.036640457808971405,
-0.042640458792448044,
-0.0032338490709662437,
0.008241575211286545... |
724,598 | scipy.sparse._matrix | __pow__ | null | def __pow__(self, power):
from .linalg import matrix_power
return matrix_power(self, power)
| (self, power) | [
0.035591986030340195,
-0.056617919355630875,
0.11552632600069046,
0.09169096499681473,
-0.03267519548535347,
-0.052180103957653046,
-0.0560452975332737,
0.004549654200673103,
-0.016409175470471382,
0.06824928522109985,
-0.004381894133985043,
-0.009886662475764751,
0.07297341525554657,
0.03... |
724,599 | scipy.sparse._base | __radd__ | null | def __radd__(self,other): # other + self
return self.__add__(other)
| (self, other) | [
-0.08065029233694077,
-0.03858761861920357,
0.0416644923388958,
0.10106626152992249,
-0.039202991873025894,
-0.058967385441064835,
-0.05397198721766472,
-0.0004980124067515135,
0.04720286652445793,
-0.02238878235220909,
-0.006221619900316,
-0.031221220269799232,
0.05129329860210419,
0.0651... |
724,600 | scipy.sparse._base | __rdiv__ | null | def __rdiv__(self, other):
# Implementing this as the inverse would be too magical -- bail out
return NotImplemented
| (self, other) | [
-0.0349261499941349,
-0.03852440044283867,
-0.01170257106423378,
0.08946112543344498,
-0.02299249917268753,
-0.05674673989415169,
-0.01873401738703251,
-0.02439548633992672,
-0.0002550653007347137,
0.010472893714904785,
0.07480402290821075,
-0.018403902649879456,
0.04796568676829338,
0.041... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.