index int64 0 731k | package stringlengths 2 98 ⌀ | name stringlengths 1 76 | docstring stringlengths 0 281k ⌀ | code stringlengths 4 1.07M ⌀ | signature stringlengths 2 42.8k ⌀ |
|---|---|---|---|---|---|
724,127 | pdfrw.objects.pdfstring | PdfString | A PdfString is an encoded string. It has a decode
method to get the actual string data out, and there
is an encode class method to create such a string.
Like any PDF object, it could be indirect, but it
defaults to being a direct object.
| class PdfString(str):
""" A PdfString is an encoded string. It has a decode
method to get the actual string data out, and there
is an encode class method to create such a string.
Like any PDF object, it could be indirect, but it
defaults to being a direct object.
"""
indirec... | null |
724,128 | pdfrw.objects.pdfstring | to_unicode | Decode a PDF string to a unicode string. This is a
convenience function for user code, in that (as of
pdfrw 0.3) it is never actually used inside pdfrw.
There are two Unicode storage methods used -- either
UTF16_BE, or something called PDFDocEncoding, which
... | def to_unicode(self):
""" Decode a PDF string to a unicode string. This is a
convenience function for user code, in that (as of
pdfrw 0.3) it is never actually used inside pdfrw.
There are two Unicode storage methods used -- either
UTF16_BE, or something called PDFDocEncoding, which... | (self) |
724,129 | pdfrw.objects.pdfstring | decode_hex | Decode a PDF hexadecimal-encoded string, which is enclosed
in angle brackets <>.
| def decode_hex(self):
""" Decode a PDF hexadecimal-encoded string, which is enclosed
in angle brackets <>.
"""
hexstr = convert_store(''.join(self[1:-1].split()))
if len(hexstr) % 1: # odd number of chars indicates a truncated 0
hexstr += '0'
return binascii.unhexlify(hexstr)
| (self) |
724,130 | pdfrw.objects.pdfstring | decode_literal | Decode a PDF literal string, which is enclosed in parentheses ()
Many pdfrw users never decode strings, so defer creating
data structures to do so until the first string is decoded.
Possible string escapes from the spec:
(PDF 1.7 Reference, section 3.2.3, page 53)
... | def decode_literal(self):
""" Decode a PDF literal string, which is enclosed in parentheses ()
Many pdfrw users never decode strings, so defer creating
data structures to do so until the first string is decoded.
Possible string escapes from the spec:
(PDF 1.7 Reference, section 3.2.3... | (self) |
724,131 | pdfrw.objects.pdfstring | to_bytes | Decode a PDF string to bytes. This is a convenience function
for user code, in that (as of pdfrw 0.3) it is never
actually used inside pdfrw.
| def to_bytes(self):
""" Decode a PDF string to bytes. This is a convenience function
for user code, in that (as of pdfrw 0.3) it is never
actually used inside pdfrw.
"""
if self.startswith('(') and self.endswith(')'):
return self.decode_literal()
elif self.startswith('<') and se... | (self) |
724,133 | pdfrw.tokens | PdfTokens | null | class PdfTokens(object):
# Table 3.1, page 50 of reference, defines whitespace
eol = '\n\r'
whitespace = '\x00 \t\f' + eol
# Text on page 50 defines delimiter characters
# Escape the ]
delimiters = r'()<>{}[\]/%'
# "normal" stuff is all but delimiters or whitespace.
p_normal = r'(?:[... | (fdata, startloc=0, strip_comments=True, verbose=True) |
724,134 | pdfrw.tokens | __init__ | null | def __init__(self, fdata, startloc=0, strip_comments=True, verbose=True):
self.fdata = fdata
self.strip_comments = strip_comments
self.iterator = iterator = self._gettoks(startloc)
self.msgs_dumped = None if verbose else set()
self.next = getattr(iterator, nextattr)
self.current = [(startloc, st... | (self, fdata, startloc=0, strip_comments=True, verbose=True) |
724,135 | pdfrw.tokens | __iter__ | null | def __iter__(self):
return self.iterator
| (self) |
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... |
724,137 | pdfrw.tokens | error | null | def error(self, *arg):
s = self.msg(*arg)
if s:
log.error(s)
| (self, *arg) |
724,138 | pdfrw.tokens | exception | null | def exception(self, *arg):
raise PdfParseError(self.msg(*arg))
| (self, *arg) |
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) |
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'>) |
724,141 | pdfrw.tokens | next_default | null | def next_default(self, default='nope'):
for result in self:
return result
return default
| (self, default='nope') |
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) |
724,143 | pdfrw.tokens | warning | null | def warning(self, *arg):
s = self.msg(*arg)
if s:
log.warning(s)
| (self, *arg) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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 |
724,442 | hypertion.main | __init__ | null | def __init__(self) -> None:
self._registered_functions: dict[str, info.FunctionInfo] = {}
"""Registered functions."""
| (self) -> NoneType |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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... | () |
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) |
724,468 | tlo.tl_core | __repr__ | null | def __repr__(self):
return f'<{__name__}.{type(self).__name__}> {vars(self)}'
| (self) |
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 |
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 |
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 |
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 |
724,474 | tlo.tl_config | get_function_count | null | def get_function_count(self) -> int: # orig size_t
return len(self.functions)
| (self) -> int |
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 |
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 |
724,477 | tlo.tl_config | get_type_count | null | def get_type_count(self) -> int: # orig size_t
return len(self.types)
| (self) -> int |
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) |
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) |
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 |
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 |
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] |
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 |
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) |
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 |
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 |
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 |
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 |
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) |
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 |
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 |
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 |
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) |
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 |
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 |
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 |
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 |
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 |
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') |
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) |
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') |
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') |
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) |
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') |
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) |
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) |
724,567 | markov_clustering.utils | __init__ | null | def __init__(self, enabled):
self._enabled = enabled
| (self, enabled) |
724,568 | markov_clustering.utils | disable | null | def disable(self):
self._enabled = False
| (self) |
724,569 | markov_clustering.utils | enable | null | def enable(self):
self._enabled = True
| (self) |
724,570 | markov_clustering.utils | print | null | def print(self, string):
if self._enabled:
print(string)
| (self, string) |
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) |
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) |
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) |
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) |
724,575 | scipy.sparse._data | __abs__ | null | def __abs__(self):
return self._with_data(abs(self._deduped_data()))
| (self) |
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) |
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) |
724,578 | scipy.sparse._base | __div__ | null | def __div__(self, other):
# Always do true division
return self._divide(other, true_divide=True)
| (self, other) |
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) |
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) |
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) |
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) |
724,583 | scipy.sparse._base | __iadd__ | null | def __iadd__(self, other):
return NotImplemented
| (self, other) |
724,584 | scipy.sparse._base | __idiv__ | null | def __idiv__(self, other):
return self.__itruediv__(other)
| (self, other) |
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) |
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) |
724,587 | scipy.sparse._base | __isub__ | null | def __isub__(self, other):
return NotImplemented
| (self, other) |
724,588 | scipy.sparse._csc | __iter__ | null | def __iter__(self):
yield from self.tocsr()
| (self) |
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) |
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) |
724,591 | scipy.sparse._base | __len__ | null | def __len__(self):
raise TypeError("sparse array length is ambiguous; use getnnz()"
" or shape[0]")
| (self) |
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) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.