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 |
|---|---|---|---|---|---|---|
722,677 | stackprinter.tracing | show | null | def show(self, frame, note=''):
if frame is None:
return
filepath = inspect.getsourcefile(frame) or inspect.getfile(frame)
if filepath in __file__:
return
elif match(filepath, self.suppressed_paths):
line_info = (filepath, frame.f_lineno, frame.f_code.co_name)
frame_str =... | (self, frame, note='') | [
0.005698633845895529,
-0.028186988085508347,
0.0551309697329998,
0.0784556120634079,
0.03092891350388527,
-0.04591810330748558,
0.018206382170319557,
0.05692236125469208,
-0.011662320233881474,
-0.017530038952827454,
-0.0421525239944458,
-0.03282998129725456,
0.022684859111905098,
0.019869... |
722,678 | stackprinter.tracing | trace | null | def trace(self, frame, event, arg):
depth = count_stack(frame) - self.starting_depth
if depth >= self.depth_limit:
return None
if 'call' in event:
callsite = frame.f_back
self.show(callsite)
self.show(frame)
elif 'return' in event:
val_str = ppr.format_value(arg, ... | (self, frame, event, arg) | [
-0.03966528922319412,
0.0007166796131059527,
0.017047058790922165,
0.05780314281582832,
-0.020589889958500862,
-0.053512077778577805,
-0.019724465906620026,
0.0264495350420475,
0.018029676750302315,
-0.11358696222305298,
-0.018552536144852638,
-0.03202070668339729,
0.02336646057665348,
-0.... |
722,679 | stackprinter | _guess_thing | default to the current exception or current stack frame | def _guess_thing(f):
""" default to the current exception or current stack frame"""
# the only reason this happens up here is to keep sys._getframe at the same
# call depth relative to an invocation of `show` or `format`, even when
# `format` is called _by_ `show`.
@wraps(f)
def show_or_format(... | (f) | [
0.05862991511821747,
-0.059322938323020935,
0.0594961941242218,
0.10464677214622498,
-0.01366125512868166,
-0.03000798262655735,
0.0450119711458683,
-0.013513986952602863,
0.02084272727370262,
-0.039814285933971405,
-0.009477117098867893,
-0.0326068252325058,
-0.043279409408569336,
-0.0762... |
722,680 | stackprinter | _is_exc_info | null | def _is_exc_info(thing):
if not isinstance(thing, tuple) or len(thing) != 3:
return False
a, b, c = thing
return ((a is None or (isinstance(a, type) and BaseException in a.mro())) and
(b is None or (isinstance(b, BaseException))))
| (thing) | [
-0.006292921025305986,
-0.03390471637248993,
0.025171684101223946,
0.0759907066822052,
-0.005027677398175001,
-0.05822022259235382,
0.03253483027219772,
0.022298725321888924,
0.005527115892618895,
-0.03672059625387192,
0.052626512944698334,
0.026180073618888855,
0.04147715121507645,
-0.071... |
722,681 | stackprinter | _is_running_in_ipython | null | def _is_running_in_ipython():
try:
return __IPYTHON__
except NameError:
return False
| () | [
0.05832069367170334,
-0.036795180290937424,
0.03333091735839844,
0.012150145135819912,
0.03270869329571724,
0.02941259928047657,
0.027999987825751305,
0.001623873133212328,
-0.06585462391376495,
-0.006655252072960138,
-0.0031342327129095793,
-0.003140539163723588,
-0.014176569879055023,
-0... |
722,682 | stackprinter | _patch_ipython_excepthook | Replace ipython's built-in traceback printer, excellent though it is | def _patch_ipython_excepthook(**kwargs):
""" Replace ipython's built-in traceback printer, excellent though it is"""
global ipy_tb
blacklist = kwargs.get('suppressed_paths', [])
blacklist.append('site-packages/IPython/')
kwargs['suppressed_paths'] = blacklist
if 'file' in kwargs:
del k... | (**kwargs) | [
-0.014964924193918705,
-0.015761710703372955,
0.0313219353556633,
0.05037153139710426,
-0.01739191636443138,
-0.013719374313950539,
-0.01506566721946001,
0.035937801003456116,
0.01162208616733551,
-0.041945748031139374,
0.03875860571861267,
-0.03597443178296089,
-0.04088336601853371,
-0.03... |
722,683 | stackprinter | _unpatch_ipython_excepthook | restore proper order in Ipython | def _unpatch_ipython_excepthook():
""" restore proper order in Ipython """
import IPython
shell = IPython.get_ipython()
if ipy_tb is not None:
shell.InteractiveTB.structured_traceback = ipy_tb
| () | [
-0.02312052994966507,
0.0033479840494692326,
0.04102252423763275,
0.05826788395643234,
-0.014048573561012745,
-0.012242821976542473,
-0.016476402059197426,
0.02374260686337948,
0.02666291408240795,
-0.04288875684142113,
0.011231946758925915,
-0.04962792620062828,
-0.052047114819288254,
-0.... |
722,687 | stackprinter | format |
Render the traceback of an exception or a frame's call stack
Call this without arguments inside an `except` block to get a traceback for
the currently handled exception:
```
try:
something()
except:
logger.err(stackprinter.format(**kwargs))
```
... | def _guess_thing(f):
""" default to the current exception or current stack frame"""
# the only reason this happens up here is to keep sys._getframe at the same
# call depth relative to an invocation of `show` or `format`, even when
# `format` is called _by_ `show`.
@wraps(f)
def show_or_format(... | (thing=None, **kwargs) | [
0.05862991511821747,
-0.059322938323020935,
0.0594961941242218,
0.10464677214622498,
-0.01366125512868166,
-0.03000798262655735,
0.0450119711458683,
-0.013513986952602863,
0.02084272727370262,
-0.039814285933971405,
-0.009477117098867893,
-0.0326068252325058,
-0.043279409408569336,
-0.0762... |
722,688 | stackprinter | format_current_exception |
Render a traceback for the currently handled exception.
Params
--
**kwargs:
See `format`
| def format_current_exception(**kwargs):
"""
Render a traceback for the currently handled exception.
Params
--
**kwargs:
See `format`
"""
return format(sys.exc_info(), **kwargs)
| (**kwargs) | [
0.033785704523324966,
-0.058888085186481476,
0.041142407804727554,
0.029754161834716797,
0.011362402699887753,
-0.043795645236968994,
-0.0034328412730246782,
-0.022156255319714546,
0.04600093141198158,
-0.032510772347450256,
0.008282752707600594,
-0.029409585520625114,
-0.027066467329859734,... |
722,689 | stackprinter | format_current_stack | Render the current thread's call stack.
Params
--
**kwargs:
See `format`
| def format_current_stack(**kwargs):
""" Render the current thread's call stack.
Params
--
**kwargs:
See `format`
"""
return format(sys._getframe(1), **kwargs)
| (**kwargs) | [
0.027379708364605904,
-0.03743216022849083,
0.05257697403430939,
0.02790878340601921,
-0.0014787274412810802,
-0.006625856272876263,
-0.016500571742653847,
-0.01617816649377346,
0.030752569437026978,
-0.03763056546449661,
-0.006204248405992985,
-0.03872178494930267,
-0.028652798384428024,
... |
722,690 | stackprinter | format_thread | null | def format_thread(thread, add_summary=False, **kwargs):
try:
fr = sys._current_frames()[thread.ident]
except KeyError:
return "%r: no frames found" % thread
else:
if 'suppressed_paths' not in kwargs:
kwargs['suppressed_paths'] = []
kwargs['suppressed_paths'] += [r... | (thread, add_summary=False, **kwargs) | [
-0.013828761875629425,
0.051966939121484756,
0.027087632566690445,
0.10193926095962524,
0.006063996814191341,
-0.04274182766675949,
0.005151280667632818,
0.021976422518491745,
-0.039286863058805466,
-0.060586538165807724,
0.010258038528263569,
0.00862850621342659,
-0.048013318330049515,
-0... |
722,694 | stackprinter | remove_excepthook | Reinstate the default excepthook | def remove_excepthook():
""" Reinstate the default excepthook """
if _is_running_in_ipython():
_unpatch_ipython_excepthook()
sys.excepthook = sys.__excepthook__
| () | [
-0.025089845061302185,
-0.006819024216383696,
0.04473141208291054,
0.04285747930407524,
-0.002702450379729271,
0.012744461186230183,
-0.03532705828547478,
0.046293020248413086,
0.017646176740527153,
-0.026373833417892456,
0.019953887909650803,
-0.027675174176692963,
-0.01766352914273739,
-... |
722,695 | stackprinter | set_excepthook |
Set sys.excepthook to print a detailed traceback for any uncaught exception.
See `format()` for available kwargs.
Examples:
----
Print to stdout instead of stderr:
```
set_excepthook(file='stdout')
```
Enable color output:
```
set_excepthook(style='darkbg') # or e.g. 'li... | def set_excepthook(**kwargs):
"""
Set sys.excepthook to print a detailed traceback for any uncaught exception.
See `format()` for available kwargs.
Examples:
----
Print to stdout instead of stderr:
```
set_excepthook(file='stdout')
```
Enable color output:
```
set_exc... | (**kwargs) | [
-0.004826047923415899,
-0.006926104426383972,
0.033419474959373474,
0.015067792497575283,
0.03334690257906914,
0.034489914774894714,
-0.028883716091513634,
0.009443450719118118,
0.029954154044389725,
-0.003918895963579416,
0.044631872326135635,
-0.03886238485574722,
0.02423909865319729,
-0... |
722,696 | stackprinter | show |
Print the traceback of an exception or a frame's call stack
Params
---
file: 'stderr', 'stdout' or file-like object
defaults to stderr
**kwargs:
See `format`
| def _guess_thing(f):
""" default to the current exception or current stack frame"""
# the only reason this happens up here is to keep sys._getframe at the same
# call depth relative to an invocation of `show` or `format`, even when
# `format` is called _by_ `show`.
@wraps(f)
def show_or_format(... | (thing=None, file='stderr', **kwargs) | [
0.05862991511821747,
-0.059322938323020935,
0.0594961941242218,
0.10464677214622498,
-0.01366125512868166,
-0.03000798262655735,
0.0450119711458683,
-0.013513986952602863,
0.02084272727370262,
-0.039814285933971405,
-0.009477117098867893,
-0.0326068252325058,
-0.043279409408569336,
-0.0762... |
722,697 | stackprinter | show_current_exception |
Print a traceback for the currently handled exception.
Params
--
**kwargs:
See `show`
| def show_current_exception(file=sys.stderr, **kwargs):
"""
Print a traceback for the currently handled exception.
Params
--
**kwargs:
See `show`
"""
if file is None:
return # see explanation in `show()`
print(format_current_exception(**kwargs), file=file)
| (file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, **kwargs) | [
0.05159914866089821,
-0.046488579362630844,
0.04268208518624306,
0.06918656826019287,
0.0731692835688591,
-0.028249124065041542,
0.017684340476989746,
-0.056145794689655304,
0.007894951850175858,
-0.022116439417004585,
0.010115407407283783,
-0.017384754493832588,
-0.038805097341537476,
-0.... |
722,698 | stackprinter | show_current_stack | Print the current thread's call stack.
Params
--
**kwargs:
See `show`
| def show_current_stack(**kwargs):
""" Print the current thread's call stack.
Params
--
**kwargs:
See `show`
"""
show(sys._getframe(1), **kwargs)
| (**kwargs) | [
0.03917309269309044,
-0.04322906956076622,
0.05927963927388191,
0.034181125462055206,
0.022879859432578087,
0.0059192972257733345,
-0.005559632554650307,
-0.031303808093070984,
0.022273197770118713,
-0.02235986292362213,
-0.022723861038684845,
-0.03208380565047264,
-0.02043587528169155,
-0... |
722,701 | stackprinter.tracing | trace |
Get a decorator to print all calls & returns in a function
Example:
```
@trace(style='color', depth_limit=5)
def dosometing():
(...)
```
Params
---
Accepts all keyword wargs accepted by stackprinter.format, and:
depth_limit: int (default: 20)
How many nested c... | def trace(*args, suppressed_paths=[], **formatter_kwargs):
"""
Get a decorator to print all calls & returns in a function
Example:
```
@trace(style='color', depth_limit=5)
def dosometing():
(...)
```
Params
---
Accepts all keyword wargs accepted by stackprinter.format, ... | (*args, suppressed_paths=[], **formatter_kwargs) | [
-0.023924829438328743,
-0.007882695645093918,
0.02603164315223694,
0.019032737240195274,
-0.009409243240952492,
-0.0035753336269408464,
-0.06049054116010666,
0.0052848877385258675,
0.016550982370972633,
-0.03313767537474632,
-0.00863704178482294,
-0.008931638672947884,
0.005168834701180458,
... |
722,707 | brewer2mpl.brewer2mpl | BrewerMap |
Representation of a colorbrewer2 color map with matplotlib compatible
views of the map.
Parameters
----------
name : str
map_type : str
colors : list
Colors as list of 0-255 RGB triplets.
Attributes
----------
name : str
map_type : str
number : int
Numb... | class BrewerMap(_ColorMap):
"""
Representation of a colorbrewer2 color map with matplotlib compatible
views of the map.
Parameters
----------
name : str
map_type : str
colors : list
Colors as list of 0-255 RGB triplets.
Attributes
----------
name : str
map_type ... | (name, map_type, colors) | [
0.03923302888870239,
-0.03569868952035904,
-0.07682044059038162,
0.04693751409649849,
-0.0035951142199337482,
-0.03274405747652054,
-0.07053717225790024,
0.049368537962436676,
-0.014642260037362576,
0.00964930560439825,
0.0032538354862481356,
0.03517508506774902,
0.061486270278692245,
0.07... |
722,708 | brewer2mpl.brewer2mpl | __init__ | null | def __init__(self, name, map_type, colors):
self.name = name
self.type = map_type
self.number = len(colors)
self.colors = colors
| (self, name, map_type, colors) | [
0.037116944789886475,
-0.05202839896082878,
-0.04746513441205025,
-0.005088758189231157,
-0.02348104864358902,
0.009494823403656483,
-0.035715628415346146,
0.01051886286586523,
0.009692445397377014,
0.020822137594223022,
-0.012063904665410519,
0.04426725581288338,
0.01633971929550171,
0.04... |
722,709 | brewer2mpl.brewer2mpl | colorbrewer2 |
View this color map at colorbrewer2.org. This will open
colorbrewer2.org in your default web browser.
| def colorbrewer2(self):
"""
View this color map at colorbrewer2.org. This will open
colorbrewer2.org in your default web browser.
"""
webbrowser.open_new_tab(self.colorbrewer2_url) # pragma: no cover
| (self) | [
-0.020385591313242912,
-0.038286011666059494,
-0.049091096967458725,
0.04354448616504669,
0.007455507759004831,
-0.007959744893014431,
-0.043292369693517685,
0.028669487684965134,
-0.015595337375998497,
0.019791310653090477,
0.025229869410395622,
0.0269766915589571,
0.027156775817275047,
0... |
722,710 | brewer2mpl.brewer2mpl | get_mpl_colormap |
A color map that can be used in matplotlib plots. Requires matplotlib
to be importable. Keyword arguments are passed to
`matplotlib.colors.LinearSegmentedColormap.from_list`.
| def get_mpl_colormap(self, **kwargs):
"""
A color map that can be used in matplotlib plots. Requires matplotlib
to be importable. Keyword arguments are passed to
`matplotlib.colors.LinearSegmentedColormap.from_list`.
"""
if not HAVE_MPL: # pragma: no cover
raise RuntimeError('matplotl... | (self, **kwargs) | [
0.057489339262247086,
-0.012812268920242786,
0.012390871532261372,
0.0032882431987673044,
-0.020747089758515358,
0.033335208892822266,
-0.0012406562454998493,
0.008629676885902882,
0.020262930542230606,
0.038230590522289276,
-0.01945599913597107,
-0.0197967030107975,
0.061506062746047974,
... |
722,711 | brewer2mpl.brewer2mpl | show_as_blocks |
Show colors in the IPython Notebook using ipythonblocks.
Parameters
----------
block_size : int, optional
Size of displayed blocks.
| def show_as_blocks(self, block_size=100):
"""
Show colors in the IPython Notebook using ipythonblocks.
Parameters
----------
block_size : int, optional
Size of displayed blocks.
"""
from ipythonblocks import BlockGrid
grid = BlockGrid(self.number, 1, block_size=block_size)
fo... | (self, block_size=100) | [
0.020743951201438904,
-0.1075320616364479,
-0.05025799572467804,
0.045425496995449066,
-0.02324969321489334,
0.06296567618846893,
-0.034668710082769394,
0.009575508534908295,
-0.04893353208899498,
0.013969503343105316,
-0.01162484660744667,
-0.010354077443480492,
0.03751451522111893,
0.024... |
722,713 | brewer2mpl.brewer2mpl | get_map |
Return a `BrewerMap` representation of the specified color map.
Parameters
----------
name : str
Name of color map. Use `print_maps` to see available color maps.
map_type : {'Sequential', 'Diverging', 'Qualitative'}
Select color map type.
number : int
Number of defined ... | def get_map(name, map_type, number, reverse=False):
"""
Return a `BrewerMap` representation of the specified color map.
Parameters
----------
name : str
Name of color map. Use `print_maps` to see available color maps.
map_type : {'Sequential', 'Diverging', 'Qualitative'}
Select ... | (name, map_type, number, reverse=False) | [
0.03224906325340271,
-0.02234359085559845,
-0.1112864688038826,
0.011903449892997742,
-0.008545344695448875,
-0.004263292532414198,
-0.05875745415687561,
0.00551085639744997,
0.027052441611886024,
-0.050540417432785034,
-0.01102171279489994,
0.03609493747353554,
0.00009973770647775382,
0.0... |
722,714 | brewer2mpl.brewer2mpl | print_all_maps |
Print the name and number of defined colors of all available color maps.
| def print_all_maps():
"""
Print the name and number of defined colors of all available color maps.
"""
for t in MAP_TYPES:
print_maps_by_type(t)
| () | [
0.009642397984862328,
-0.029625656083226204,
-0.06360536068677902,
-0.000637799734249711,
0.010458782315254211,
0.028555287048220634,
-0.02064543589949608,
-0.06610893458127975,
0.014241360127925873,
0.020337024703621864,
-0.05043436959385872,
-0.01624603569507599,
0.00617730338126421,
0.0... |
722,715 | brewer2mpl.brewer2mpl | print_maps |
Print maps by type and/or number of defined colors.
Parameters
----------
map_type : {'Sequential', 'Diverging', 'Qualitative'}, optional
Filter output by map type. By default all maps are printed.
number : int, optional
Filter output by number of defined colors. By default there i... | def print_maps(map_type=None, number=None):
"""
Print maps by type and/or number of defined colors.
Parameters
----------
map_type : {'Sequential', 'Diverging', 'Qualitative'}, optional
Filter output by map type. By default all maps are printed.
number : int, optional
Filter out... | (map_type=None, number=None) | [
0.03873235732316971,
0.030115611851215363,
-0.03090677037835121,
-0.01127400528639555,
0.023665951564908028,
0.006445359904319048,
-0.05624103173613548,
-0.05242283642292023,
-0.019520970061421394,
0.014318244531750679,
-0.028189312666654587,
-0.000941650359891355,
0.0066904472187161446,
0... |
722,716 | brewer2mpl.brewer2mpl | print_maps_by_type |
Print all available maps of a given type.
Parameters
----------
map_type : {'Sequential', 'Diverging', 'Qualitative'}
Select map type to print.
number : int, optional
Filter output by number of defined colors. By default there is
no numeric filtering.
| def print_maps_by_type(map_type, number=None):
"""
Print all available maps of a given type.
Parameters
----------
map_type : {'Sequential', 'Diverging', 'Qualitative'}
Select map type to print.
number : int, optional
Filter output by number of defined colors. By default there i... | (map_type, number=None) | [
0.04741925746202469,
0.0168440081179142,
-0.06039642170071602,
-0.013380507938563824,
0.035652127116918564,
0.002317037433385849,
-0.04903263598680496,
-0.08228223025798798,
-0.0020145291928201914,
-0.007830140180885792,
-0.03966803103685379,
-0.0035731042735278606,
-0.0002316763566341251,
... |
722,720 | trading212_rest | Trading212 | Rest API client for Trading212 | class Trading212:
"""Rest API client for Trading212"""
def __init__(self, api_key: str, demo: bool = True):
""" """
self._api_key = api_key
self.host = (
"https://live.trading212.com" if demo else "https://live.trading212.com"
)
def _get(self, endpoint: str, par... | (api_key: str, demo: bool = True) | [
0.012390455231070518,
-0.04223528876900673,
-0.11965359002351761,
-0.011332613416016102,
-0.01883544959127903,
-0.03436024859547615,
-0.09003403782844543,
0.005132488906383514,
-0.020784620195627213,
-0.028287457302212715,
0.003707341616973281,
-0.02709248848259449,
0.0063470471650362015,
... |
722,721 | trading212_rest | __init__ | def __init__(self, api_key: str, demo: bool = True):
""" """
self._api_key = api_key
self.host = (
"https://live.trading212.com" if demo else "https://live.trading212.com"
)
| (self, api_key: str, demo: bool = True) | [
0.03377995267510414,
-0.051163677126169205,
-0.029345517978072166,
0.015054716728627682,
0.0027389151509851217,
-0.023345990106463432,
-0.012464858591556549,
0.039649054408073425,
-0.009166981093585491,
0.015241037122905254,
0.018566863611340523,
0.03432028368115425,
-0.009837735444307327,
... | |
722,722 | trading212_rest | __repr__ | null | def __repr__(self):
return "Trading212(api_key=****{}, demo={})".format(
self._api_key[-4:], self.host == "https://demo.trading212.com"
)
| (self) | [
0.00597428111359477,
-0.04973531514406204,
0.00504952622577548,
0.016059599816799164,
0.03486599400639534,
-0.05394706875085831,
-0.0245563555508852,
0.015327121131122112,
0.04332612827420235,
-0.001534772221930325,
-0.008954554796218872,
0.01715831831097603,
-0.004257533699274063,
0.02730... |
722,723 | trading212_rest | _delete_url | null | def _delete_url(
self,
url,
):
return self._process_response(
requests.delete(
f"{self.host}/{url}",
headers={"Authorization": self._api_key},
)
)
| (self, url) | [
-0.011275106109678745,
-0.003772381227463484,
-0.05256995931267738,
0.009000614285469055,
0.0038874333258718252,
0.043117985129356384,
-0.053950585424900055,
0.06715502589941025,
-0.019027847796678543,
0.06740283221006393,
0.0060313851572573185,
-0.008128873072564602,
0.05044592171907425,
... |
722,724 | trading212_rest | _get | null | def _get(self, endpoint: str, params=None, api_version: str = "v0"):
return self._process_response(
requests.get(
f"{self.host}/api/{api_version}/{endpoint}",
headers={"Authorization": self._api_key},
params=params,
)
)
| (self, endpoint: str, params=None, api_version: str = 'v0') | [
0.004259433131664991,
-0.052785612642765045,
-0.07100797444581985,
0.04073028638958931,
-0.0012967752991244197,
0.011349777691066265,
0.018274623900651932,
0.02576565183699131,
-0.027141910046339035,
-0.007447475101798773,
0.010426465421915054,
0.004294275306165218,
0.01678512804210186,
-0... |
722,725 | trading212_rest | _get_url | null | def _get_url(
self,
url,
):
return self._process_response(
requests.get(
f"{self.host}/{url}",
headers={"Authorization": self._api_key},
)
)
| (self, url) | [
-0.012666422873735428,
-0.0038665449246764183,
-0.06301702558994293,
0.07547639310359955,
0.017158636823296547,
0.04947736859321594,
0.013629683293402195,
0.02445060759782791,
0.019967395812273026,
0.02978004701435566,
0.02113771252334118,
0.01702360063791275,
0.054302673786878586,
-0.0247... |
722,726 | trading212_rest | _post | null | def _post(self, endpoint: str, data: dict, api_version: str = "v0"):
return self._process_response(
requests.post(
f"{self.host}/api/{api_version}/{endpoint}",
headers={"Authorization": self._api_key},
data=data,
)
)
| (self, endpoint: str, data: dict, api_version: str = 'v0') | [
-0.021506646648049355,
-0.03379616141319275,
-0.07559479027986526,
0.03424272686243057,
-0.022239016368985176,
0.007864037528634071,
-0.027204837650060654,
0.06109030917286873,
-0.037261515855789185,
-0.026008037850260735,
0.017040980979800224,
0.018452132120728493,
0.003152760211378336,
-... |
722,727 | trading212_rest | _process_items | null | def _process_items(self, response):
res = []
res += response["items"]
while next_page := response.get("nextPagePath"):
response = self._get_url(next_page)
res += response["items"]
return res
| (self, response) | [
-0.03164416924118996,
0.0028547560796141624,
-0.13894502818584442,
-0.005980747751891613,
-0.013570827431976795,
0.07970713824033737,
-0.012928903102874756,
-0.025713147595524788,
0.037864506244659424,
0.031047450378537178,
0.07442708313465118,
0.01393247488886118,
0.045748427510261536,
0.... |
722,728 | trading212_rest | _process_response | null | @staticmethod
def _process_response(resp):
try:
resp.raise_for_status()
except HTTPError as http_err:
logging.error(resp.text)
raise http_err
return resp.json()
| (resp) | [
-0.016321862116456032,
-0.038389164954423904,
-0.05113628879189491,
0.027932828292250633,
-0.02939228154718876,
-0.028745688498020172,
-0.04201008751988411,
0.041086383163928986,
0.04507678747177124,
0.0038102816324681044,
0.07936470210552216,
0.008087034337222576,
0.08919291943311691,
-0.... |
722,729 | trading212_rest | _validate_time_validity | null | @staticmethod
def _validate_time_validity(time_validity: str):
if time_validity not in ["GTC", "DAY"]:
raise ValueError("time_validity must be one of GTC or DAY")
| (time_validity: str) | [
0.06091369315981865,
0.024927424266934395,
-0.04582035169005394,
0.03396901860833168,
-0.07132413238286972,
-0.07629521191120148,
0.04837793484330177,
0.02146928384900093,
0.01663329266011715,
-0.050287116318941116,
0.05143982917070389,
0.03166359290480614,
0.024279022589325905,
-0.0381476... |
722,730 | trading212_rest | account_info | Account info | def account_info(self):
"""Account info"""
return self._get("equity/account/info")
| (self) | [
0.028131527826189995,
-0.02698403410613537,
0.019292239099740982,
0.005006838124245405,
0.05048972740769386,
-0.01705104112625122,
0.002156033180654049,
-0.10757753998041153,
0.03453239053487778,
-0.03148436173796654,
0.019543252885341644,
-0.06257426738739014,
0.006472581997513771,
-0.039... |
722,731 | trading212_rest | cash | Account cash | def cash(self):
"""Account cash"""
return self._get("equity/account/cash")
| (self) | [
-0.014218214899301529,
-0.026868244633078575,
0.00786270759999752,
-0.0018731104210019112,
0.02582278661429882,
-0.02479475364089012,
-0.03871675580739975,
-0.06551530212163925,
0.0465228334069252,
-0.0362076610326767,
0.06133347377181053,
-0.03906524181365967,
0.020769745111465454,
-0.025... |
722,732 | trading212_rest | dividends | Dividends paid out | def dividends(self, cursor: int = 0, ticker: str = None, limit: int = 50):
"""Dividends paid out"""
params = {"cursor": cursor, "limit": limit}
if ticker:
params["ticker"] = ticker
return self._process_items(self._get("history/dividends", params=params))
| (self, cursor: int = 0, ticker: Optional[str] = None, limit: int = 50) | [
-0.029952839016914368,
-0.00043602369260042906,
-0.07322187721729279,
-0.04252924770116806,
-0.054159414023160934,
0.06640893965959549,
-0.01729901134967804,
-0.005995729006826878,
-0.03160446137189865,
0.011423713527619839,
-0.008249503560364246,
-0.08079180866479874,
0.02603023871779442,
... |
722,733 | trading212_rest | equity_order | Equity order by ID | def equity_order(self, id: int):
"""Equity order by ID"""
return self._get(f"equity/orders/{id}")
| (self, id: int) | [
0.005660735536366701,
-0.014266262762248516,
-0.03177956864237785,
-0.03298857435584068,
0.014499427750706673,
-0.002551864832639694,
-0.03613198548555374,
-0.01873958297073841,
0.01418854109942913,
-0.04905107244849205,
-0.009577048942446709,
-0.08960456401109695,
-0.018895026296377182,
-... |
722,734 | trading212_rest | equity_order_cancel | Camcel equity order | def equity_order_cancel(self, id: int):
"""Camcel equity order"""
return self._delete_url(f"equity/orders/{id}")
| (self, id: int) | [
-0.004049570765346289,
0.006747812498360872,
0.0064077721908688545,
-0.049955010414123535,
-0.026849934831261635,
-0.052569348365068436,
-0.04610416665673256,
0.02866937220096588,
0.045644890516996384,
-0.03327978774905205,
-0.021232645958662033,
-0.05850459635257721,
-0.01720515638589859,
... |
722,735 | trading212_rest | equity_order_place_limit | Place limit order | def equity_order_place_limit(
self, ticker: str, quantity: int, limit_price: float, time_validity: str
):
"""Place limit order"""
self._validate_time_validity(time_validity)
return self._post(
f"equity/orders/limit",
data={
"quantity": quantity,
"limitPrice": limi... | (self, ticker: str, quantity: int, limit_price: float, time_validity: str) | [
0.045161932706832886,
0.02095806784927845,
-0.09185951203107834,
-0.00020258958102203906,
-0.047151293605566025,
0.03203914687037468,
-0.001248802524060011,
-0.05475971847772598,
-0.025617355480790138,
-0.037239398807287216,
0.012206635437905788,
-0.08013276755809784,
-0.02895040437579155,
... |
722,736 | trading212_rest | equity_order_place_market | Place market order | def equity_order_place_market(self, ticker: str, quantity: int):
"""Place market order"""
return self._post(
f"equity/orders/market", data={"quantity": quantity, "ticker": ticker}
)
| (self, ticker: str, quantity: int) | [
0.03954601660370827,
-0.03022691048681736,
-0.08810164779424667,
-0.037345193326473236,
0.002630669856444001,
0.012095922604203224,
-0.030656758695840836,
-0.01704777218401432,
-0.012216280214488506,
0.0026220728177577257,
0.045529499650001526,
-0.07503426820039749,
-0.01301579736173153,
-... |
722,737 | trading212_rest | equity_order_place_stop | Place stop order | def equity_order_place_stop(
self, ticker: str, quantity: int, stop_price: float, time_validity: str
):
"""Place stop order"""
self._validate_time_validity(time_validity)
return self._post(
f"equity/orders/stop",
data={
"quantity": quantity,
"stopPrice": stop_pric... | (self, ticker: str, quantity: int, stop_price: float, time_validity: str) | [
0.05846630409359932,
0.032385069876909256,
-0.07287506014108658,
-0.028488468378782272,
-0.07065833359956741,
-0.013335027731955051,
-0.026063919067382812,
-0.0031042906921356916,
-0.02201145514845848,
-0.0017177507979795337,
0.009758816100656986,
-0.07086615264415741,
0.002783903619274497,
... |
722,738 | trading212_rest | equity_order_place_stop_limit | Place stop-limit order | def equity_order_place_stop_limit(
self,
ticker: str,
quantity: int,
stop_price: float,
limit_price: float,
time_validity: str,
):
"""Place stop-limit order"""
self._validate_time_validity(time_validity)
return self._post(
f"equity/orders/stop_limit",
data={
... | (self, ticker: str, quantity: int, stop_price: float, limit_price: float, time_validity: str) | [
0.05284443497657776,
0.03007025457918644,
-0.07129308581352234,
-0.013575912453234196,
-0.07511483877897263,
0.010857255198061466,
-0.001341956784017384,
-0.026526447385549545,
-0.04318581894040108,
-0.02359064482152462,
-0.004716391675174236,
-0.08178553730249405,
-0.0029140873812139034,
... |
722,739 | trading212_rest | equity_orders | All equity orders | def equity_orders(self):
"""All equity orders"""
return self._get("equity/orders")
| (self) | [
0.018521450459957123,
-0.043650370091199875,
-0.04495131969451904,
-0.05022360011935234,
0.004745907615870237,
0.0049384827725589275,
-0.05063442885875702,
-0.09627046436071396,
0.06059698387980461,
-0.013368995860219002,
0.019668342545628548,
-0.09401091188192368,
-0.01614207774400711,
-0... |
722,740 | trading212_rest | exchanges | Exhange list | def exchanges(self):
"""Exhange list"""
return self._get("equity/metadata/exchanges")
| (self) | [
0.047994449734687805,
-0.0766819640994072,
-0.04161565378308296,
-0.034895751625299454,
-0.008186685852706432,
-0.0033961955923587084,
-0.01743081957101822,
-0.07797818630933762,
0.10431202501058578,
0.016066372394561768,
0.0009007487096823752,
-0.07763707637786865,
-0.027271898463368416,
... |
722,741 | trading212_rest | instruments | Tradeable instruments metadata | def instruments(self):
"""Tradeable instruments metadata"""
return self._get("equity/metadata/instruments")
| (self) | [
0.0418182909488678,
-0.059716250747442245,
0.027219107374548912,
-0.04564148560166359,
0.061204928904771805,
0.020993730053305626,
-0.035423748195171356,
-0.060460589826107025,
0.026880770921707153,
0.030145710334181786,
-0.023446664214134216,
-0.011444205418229103,
-0.013964805752038956,
... |
722,742 | trading212_rest | orders | Historical order data | def orders(self, cursor: int = 0, ticker: str = None, limit: int = 50):
"""Historical order data"""
params = {"cursor": cursor, "limit": limit}
if ticker:
params["ticker"] = ticker
return self._process_items(self._get("equity/history/orders", params=params))
| (self, cursor: int = 0, ticker: Optional[str] = None, limit: int = 50) | [
-0.00842258706688881,
-0.0018502858001738787,
-0.08940234780311584,
-0.05169546976685524,
0.019874881953001022,
0.04255440831184387,
-0.050379712134599686,
-0.020221134647727013,
-0.0019476691959425807,
-0.009876847267150879,
0.013754872605204582,
-0.07624475657939911,
-0.010872322134673595,... |
722,743 | trading212_rest | portfolio | All open positions | def portfolio(self):
"""All open positions"""
return self._get("equity/portfolio")
| (self) | [
0.026772387325763702,
-0.08358694612979889,
-0.06582720577716827,
-0.013776243664324284,
0.004141171928495169,
0.008199354633688927,
-0.04833303764462471,
-0.03535349294543266,
0.06635834276676178,
0.004182666540145874,
0.013178720138967037,
-0.07303068786859512,
-0.023087656125426292,
-0.... |
722,744 | trading212_rest | position | Open position by ticker | def position(self, ticker: str):
"""Open position by ticker"""
return self._get(f"equity/portfolio/{ticker}")
| (self, ticker: str) | [
0.05444777384400368,
-0.050267141312360764,
-0.07637950778007507,
0.025647854432463646,
0.03938422352075577,
0.027074579149484634,
-0.03329576179385185,
0.04101002588868141,
0.02871697023510933,
-0.009431309998035431,
0.011546512134373188,
-0.09091219305992126,
-0.007917489856481552,
-0.01... |
722,745 | trading212_rest | transactions | Transactions list | def transactions(self, cursor: int = 0, limit: int = 50):
"""Transactions list"""
params = {"cursor": cursor, "limit": limit}
return self._process_items(self._get("history/transactions", params=params))
| (self, cursor: int = 0, limit: int = 50) | [
-0.03481806814670563,
-0.016707884147763252,
-0.0036425581201910973,
-0.04514719918370247,
-0.011936645954847336,
0.05465547367930412,
-0.0542108416557312,
-0.06570285558700562,
0.008255610242486,
-0.03895656019449234,
-0.02214607037603855,
-0.025497907772660255,
-0.00006149088585516438,
-... |
722,752 | beobench.utils | restart | Clean up remaining beobench processes and containers
before running new experiments.
This stops all docker containers still running. This
function is not called by other scheduler functions
to enable the parallel running of experiments.
| def restart() -> None:
"""Clean up remaining beobench processes and containers
before running new experiments.
This stops all docker containers still running. This
function is not called by other scheduler functions
to enable the parallel running of experiments.
"""
shutdown()
| () -> NoneType | [
0.04783540964126587,
-0.029056614264845848,
-0.005260849837213755,
-0.00864904560148716,
-0.08340711146593094,
0.00048748869448900223,
-0.07776302099227905,
0.003601591568440199,
0.028185611590743065,
0.030136656016111374,
0.015695448964834213,
-0.02252410165965557,
0.05919326841831207,
0.... |
722,753 | beobench.experiment.scheduler | run | Run experiment.
This function allows the use to run experiments from the command line or python
interface.
Args:
config (str, dict, pathlib.Path or list, optional): experiment configuration.
This can either be a dictionary, or a path (str or pathlib) to a yaml file,
or a js... | def run(
config: Union[str, dict, pathlib.Path, list] = None,
method: str = None,
gym: str = None,
env: str = None,
local_dir: str = None,
wandb_project: str = None,
wandb_entity: str = None,
wandb_group: str = None,
wandb_api_key: str = None,
mlflow_name: str = None,
use_gpu... | (config: Union[str, dict, pathlib.Path, list, NoneType] = None, method: Optional[str] = None, gym: Optional[str] = None, env: Optional[str] = None, local_dir: Optional[str] = None, wandb_project: Optional[str] = None, wandb_entity: Optional[str] = None, wandb_group: Optional[str] = None, wandb_api_key: Optional[str] = ... | [
0.09486947953701019,
-0.0724216029047966,
-0.04296128824353218,
0.028412483632564545,
-0.047313835471868515,
-0.003954574465751648,
-0.08120731264352798,
-0.06029088795185089,
-0.036674268543720245,
0.01281584333628416,
0.016946736723184586,
0.0314149372279644,
-0.031152978539466858,
0.086... |
722,755 | fuzzy | DMetaphone | null | from fuzzy import DMetaphone
| null | [
0.05918518081307411,
0.0019523472292348742,
0.053108882158994675,
0.006391026079654694,
0.010171928443014622,
-0.040721286088228226,
-0.007205116096884012,
-0.02103205770254135,
0.026537654921412468,
0.04676401615142822,
-0.00631549209356308,
0.05911803990602493,
-0.027695845812559128,
0.0... |
722,756 | fuzzy | Soundex | null | from fuzzy import Soundex
| null | [
0.020645512267947197,
-0.03795947507023811,
0.02485201507806778,
0.008665394969284534,
-0.006780881434679031,
-0.03255832567811012,
-0.01956864818930626,
-0.0258279237896204,
0.07733233273029327,
-0.016624096781015396,
-0.03482983633875847,
0.04068528860807419,
-0.04734838753938675,
-0.014... |
722,759 | gitdb.db.base | CachingDB | A database which uses caches to speed-up access | class CachingDB:
"""A database which uses caches to speed-up access"""
#{ Interface
def update_cache(self, force=False):
"""
Call this method if the underlying data changed to trigger an update
of the internal caching structures.
:param force: if True, the update must be p... | () | [
0.04074731841683388,
-0.03996799886226654,
-0.05525752156972885,
0.019223233684897423,
0.057558368891477585,
-0.06824619323015213,
-0.04983938857913017,
0.045868564397096634,
0.019594339653849602,
-0.07002749294042587,
-0.01286806259304285,
0.0200211089104414,
-0.02482691779732704,
0.03967... |
722,760 | gitdb.db.base | update_cache |
Call this method if the underlying data changed to trigger an update
of the internal caching structures.
:param force: if True, the update must be performed. Otherwise the implementation
may decide not to perform an update if it thinks nothing has changed.
:return: True if ... | def update_cache(self, force=False):
"""
Call this method if the underlying data changed to trigger an update
of the internal caching structures.
:param force: if True, the update must be performed. Otherwise the implementation
may decide not to perform an update if it thinks nothing has changed... | (self, force=False) | [
0.06509651243686676,
0.014173409901559353,
-0.026254678145051003,
0.041774261742830276,
0.07380805909633636,
-0.024934226647019386,
-0.08286257833242416,
0.022379068657755852,
0.09651295095682144,
-0.034057341516017914,
-0.019429489970207214,
-0.009920530021190643,
0.026597652584314346,
0.... |
722,761 | gitdb.db.base | CompoundDB | A database which delegates calls to sub-databases.
Databases are stored in the lazy-loaded _dbs attribute.
Define _set_cache_ to update it with your databases | class CompoundDB(ObjectDBR, LazyMixin, CachingDB):
"""A database which delegates calls to sub-databases.
Databases are stored in the lazy-loaded _dbs attribute.
Define _set_cache_ to update it with your databases"""
def _set_cache_(self, attr):
if attr == '_dbs':
self._dbs = list(... | () | [
-0.004325530957430601,
-0.0522029809653759,
-0.09111793339252472,
0.08289200812578201,
0.041446004062891006,
-0.040220025926828384,
-0.0054724146611988544,
0.028968699276447296,
0.017598731443285942,
-0.11002174019813538,
-0.03175681456923485,
0.072293221950531,
-0.03907313942909241,
0.039... |
722,762 | gitdb.db.base | __contains__ | null | def __contains__(self, sha):
return self.has_obj
| (self, sha) | [
0.023488324135541916,
-0.05820946767926216,
-0.0629708394408226,
0.08302225917577744,
0.015239748172461987,
-0.03116687759757042,
0.014074552804231644,
0.02484632097184658,
0.018726950511336327,
-0.017251595854759216,
0.015591821633279324,
0.015608586370944977,
0.049323804676532745,
-0.016... |
722,763 | gitdb.util | __getattr__ |
Whenever an attribute is requested that we do not know, we allow it
to be created and set. Next time the same attribute is requested, it is simply
returned from our dict/slots. | def __getattr__(self, attr):
"""
Whenever an attribute is requested that we do not know, we allow it
to be created and set. Next time the same attribute is requested, it is simply
returned from our dict/slots. """
self._set_cache_(attr)
# will raise in case the cache was not created
return o... | (self, attr) | [
0.07305805385112762,
0.010327131487429142,
-0.024085260927677155,
-0.0012887577759101987,
0.031066743656992912,
-0.0068406579084694386,
0.00881646852940321,
0.026696914806962013,
0.016523411497473717,
-0.01881074160337448,
0.002767415251582861,
0.074355348944664,
0.016233226284384727,
0.05... |
722,764 | gitdb.db.base | _db_query | :return: database containing the given 20 byte sha
:raise BadObject: | def _db_query(self, sha):
""":return: database containing the given 20 byte sha
:raise BadObject:"""
# most databases use binary representations, prevent converting
# it every time a database is being queried
try:
return self._db_cache[sha]
except KeyError:
pass
# END first l... | (self, sha) | [
0.014310646802186966,
-0.013816246762871742,
-0.057170674204826355,
0.0964350625872612,
0.02851342409849167,
-0.017106257379055023,
0.05889658257365227,
0.021897446364164352,
0.010867821983993053,
-0.06572829931974411,
-0.027308885008096695,
0.07737816870212555,
-0.05127382650971413,
-0.00... |
722,765 | gitdb.db.base | _set_cache_ | null | def _set_cache_(self, attr):
if attr == '_dbs':
self._dbs = list()
elif attr == '_db_cache':
self._db_cache = dict()
else:
super()._set_cache_(attr)
| (self, attr) | [
0.023886296898126602,
0.039769724011421204,
0.0067840926349163055,
0.015979530289769173,
0.012082936242222786,
-0.0035099927335977554,
0.0003085167845711112,
0.053154438734054565,
0.030211709439754486,
-0.02282041311264038,
-0.01913350075483322,
0.0711871087551117,
-0.009418225847184658,
0... |
722,766 | gitdb.db.base | databases | :return: tuple of database instances we use for lookups | def databases(self):
""":return: tuple of database instances we use for lookups"""
return tuple(self._dbs)
| (self) | [
0.03347954526543617,
-0.03003772348165512,
-0.031167615205049515,
0.006197019014507532,
0.013280567713081837,
0.0037286411970853806,
0.002590058371424675,
-0.019694874063134193,
0.04366595298051834,
-0.01833900436758995,
-0.045612841844558716,
0.01740901730954647,
-0.05680745467543602,
0.0... |
722,767 | gitdb.db.base | has_object | null | def has_object(self, sha):
try:
self._db_query(sha)
return True
except BadObject:
return False
# END handle exceptions
| (self, sha) | [
0.0029646523762494326,
-0.033474963158369064,
-0.07382548600435257,
0.09125746786594391,
0.04816366359591484,
-0.01296981144696474,
0.02814466506242752,
0.04167007654905319,
-0.005508263595402241,
-0.010339387692511082,
0.0038826963864266872,
0.05094166845083237,
0.029776742681860924,
-0.0... |
722,768 | gitdb.db.base | info | null | def info(self, sha):
return self._db_query(sha).info(sha)
| (self, sha) | [
0.02333720028400421,
-0.008741083554923534,
-0.014513184316456318,
0.08220267295837402,
0.06070657819509506,
-0.021114610135555267,
0.05931331217288971,
-0.02358599752187729,
0.03416818380355835,
-0.032393425703048706,
-0.024116765707731247,
0.028296563774347305,
-0.02159561775624752,
-0.0... |
722,769 | gitdb.db.base | partial_to_complete_sha_hex |
:return: 20 byte binary sha1 from the given less-than-40 byte hexsha (bytes or str)
:param partial_hexsha: hexsha with less than 40 byte
:raise AmbiguousObjectName: | def partial_to_complete_sha_hex(self, partial_hexsha):
"""
:return: 20 byte binary sha1 from the given less-than-40 byte hexsha (bytes or str)
:param partial_hexsha: hexsha with less than 40 byte
:raise AmbiguousObjectName: """
databases = list()
_databases_recursive(self, databases)
partial... | (self, partial_hexsha) | [
-0.009851361624896526,
-0.005371443927288055,
-0.02013065665960312,
0.04311419650912285,
0.01587807759642601,
-0.04125982150435448,
0.02309052273631096,
0.00824215728789568,
0.028172219172120094,
-0.07802635431289673,
0.03558971732854843,
0.06939637660980225,
-0.028546661138534546,
-0.0038... |
722,770 | gitdb.db.base | sha_iter | null | def sha_iter(self):
return chain(*(db.sha_iter() for db in self._dbs))
| (self) | [
-0.023973612114787102,
-0.05610845237970352,
-0.062059350311756134,
0.08528484404087067,
-0.008382262662053108,
-0.0028415529523044825,
0.0015536090359091759,
-0.015829384326934814,
0.07555938512086868,
0.006690507754683495,
0.016007911413908005,
0.02242637798190117,
-0.016186438500881195,
... |
722,771 | gitdb.db.base | size | :return: total size of all contained databases | def size(self):
""":return: total size of all contained databases"""
return reduce(lambda x, y: x + y, (db.size() for db in self._dbs), 0)
| (self) | [
-0.01639929972589016,
-0.048251453787088394,
-0.025777703151106834,
0.059746451675891876,
0.04801053926348686,
0.05706198886036873,
0.0013174936175346375,
-0.05510026961565018,
0.0004159515374340117,
-0.013775067403912544,
-0.018016858026385307,
-0.007231695111840963,
-0.026104656979441643,
... |
722,772 | gitdb.db.base | stream | null | def stream(self, sha):
return self._db_query(sha).stream(sha)
| (self, sha) | [
-0.04297848045825958,
-0.008566213771700859,
-0.09159132838249207,
0.04740080609917641,
0.022701285779476166,
0.024519354104995728,
0.008541645482182503,
0.023700403049588203,
0.052052441984415054,
-0.0016921547940000892,
-0.02561674639582634,
0.034854497760534286,
-0.019392728805541992,
0... |
722,773 | gitdb.db.base | update_cache | null | def update_cache(self, force=False):
# something might have changed, clear everything
self._db_cache.clear()
stat = False
for db in self._dbs:
if isinstance(db, CachingDB):
stat |= db.update_cache(force)
# END if is caching db
# END for each database to update
return ... | (self, force=False) | [
0.05441135913133621,
-0.010735665448009968,
-0.02950684167444706,
0.06124061346054077,
0.07653220742940903,
-0.030638864263892174,
-0.05374327674508095,
-0.008402026258409023,
0.06187157705426216,
-0.01614525355398655,
-0.04242304340004921,
0.0009603641810826957,
-0.0028254191856831312,
0.... |
722,774 | gitdb.stream | DecompressMemMapReader | Reads data in chunks from a memory map and decompresses it. The client sees
only the uncompressed data, respective file-like read calls are handling on-demand
buffered decompression accordingly
A constraint on the total size of bytes is activated, simulating
a logical file within a possibly larger phys... | class DecompressMemMapReader(LazyMixin):
"""Reads data in chunks from a memory map and decompresses it. The client sees
only the uncompressed data, respective file-like read calls are handling on-demand
buffered decompression accordingly
A constraint on the total size of bytes is activated, simulating... | (m, close_on_deletion, size=None) | [
0.03894999995827675,
-0.04164748266339302,
-0.055993180721998215,
0.010554919019341469,
0.042669255286455154,
-0.0005217430298216641,
-0.004720592871308327,
0.07512077689170837,
-0.04262838512659073,
-0.048718154430389404,
0.022928593680262566,
0.046511124819517136,
-0.049944281578063965,
... |
722,777 | gitdb.stream | __init__ | Initialize with mmap for stream reading
:param m: must be content data - use new if you have object data and no size | def __init__(self, m, close_on_deletion, size=None):
"""Initialize with mmap for stream reading
:param m: must be content data - use new if you have object data and no size"""
self._m = m
self._zip = zlib.decompressobj()
self._buf = None # buffer of decompressed bytes
self... | (self, m, close_on_deletion, size=None) | [
0.06760815531015396,
-0.02099507302045822,
-0.039943628013134,
0.009382915683090687,
0.014663660898804665,
-0.03089875541627407,
-0.03347517177462578,
0.10247203707695007,
-0.0773291140794754,
-0.020593078806996346,
0.014206849038600922,
0.03418780118227005,
-0.05441543087363243,
0.0292359... |
722,778 | gitdb.stream | _parse_header_info | If this stream contains object data, parse the header info and skip the
stream to a point where each read will yield object content
:return: parsed type_string, size | def _parse_header_info(self):
"""If this stream contains object data, parse the header info and skip the
stream to a point where each read will yield object content
:return: parsed type_string, size"""
# read header
# should really be enough, cgit uses 8192 I believe
# And for good reason !! Thi... | (self) | [
-0.0000435421425208915,
0.011888671666383743,
-0.058311983942985535,
-0.05163504183292389,
0.023276571184396744,
-0.023387854918837547,
0.043919458985328674,
0.05686531215906143,
-0.03036155179142952,
-0.04955776780843735,
0.022590329870581627,
0.01889018900692463,
-0.030862322077155113,
0... |
722,779 | gitdb.stream | _set_cache_ | null | def _set_cache_(self, attr):
assert attr == '_s'
# only happens for size, which is a marker to indicate we still
# have to parse the header from the stream
self._parse_header_info()
| (self, attr) | [
0.0042287809774279594,
0.06698591262102127,
-0.04776035249233246,
0.0021902809385210276,
0.048637308180332184,
0.022986356168985367,
0.007559525780379772,
0.06651370972394943,
-0.02092888206243515,
-0.007681793533265591,
0.010118718259036541,
0.0453655868768692,
0.016822369769215584,
0.023... |
722,780 | gitdb.stream | close | Close our underlying stream of compressed bytes if this was allowed during initialization
:return: True if we closed the underlying stream
:note: can be called safely
| def close(self):
"""Close our underlying stream of compressed bytes if this was allowed during initialization
:return: True if we closed the underlying stream
:note: can be called safely
"""
if self._close:
if hasattr(self._m, 'close'):
self._m.close()
self._close = False... | (self) | [
0.019853193312883377,
-0.0478549525141716,
0.022122640162706375,
0.044281020760536194,
0.004154696129262447,
-0.05471690371632576,
-0.04413806274533272,
0.11522357910871506,
-0.0133218327537179,
-0.024749480187892914,
0.022372815757989883,
0.01495690643787384,
0.006718992721289396,
0.04285... |
722,781 | gitdb.stream | compressed_bytes_read |
:return: number of compressed bytes read. This includes the bytes it
took to decompress the header ( if there was one ) | def compressed_bytes_read(self):
"""
:return: number of compressed bytes read. This includes the bytes it
took to decompress the header ( if there was one )"""
# ABSTRACT: When decompressing a byte stream, it can be that the first
# x bytes which were requested match the first x bytes in the loo... | (self) | [
-0.02160322107374668,
-0.025780221447348595,
-0.034001920372247696,
0.04343324527144432,
0.05855360999703407,
-0.005618160590529442,
0.008065769448876381,
0.07208633422851562,
-0.02394687756896019,
-0.0632031261920929,
0.02294515259563923,
0.0509934276342392,
-0.03137475624680519,
0.008221... |
722,782 | gitdb.stream | data | :return: random access compatible data we are working on | def data(self):
""":return: random access compatible data we are working on"""
return self._m
| (self) | [
0.047824978828430176,
0.006040301639586687,
-0.016690775752067566,
0.043170392513275146,
0.08307191729545593,
0.0064844414591789246,
-0.045693106949329376,
0.010206333361566067,
0.04395207762718201,
-0.02227805368602276,
-0.021105526015162468,
-0.007132885977625847,
-0.0177655927836895,
0.... |
722,783 | gitdb.stream | read | null | def read(self, size=-1):
if size < 1:
size = self._s - self._br
else:
size = min(size, self._s - self._br)
# END clamp size
if size == 0:
return b''
# END handle depletion
# deplete the buffer, then just continue using the decompress object
# which has an own buffer. ... | (self, size=-1) | [
0.01357010193169117,
-0.020598029717803,
-0.07652173191308975,
0.0018525824416428804,
0.04526812210679054,
-0.012298873625695705,
-0.014924011193215847,
0.051469236612319946,
-0.01180278416723013,
-0.05969604477286339,
0.011885466054081917,
0.041568126529455185,
-0.05696755647659302,
0.027... |
722,784 | gitdb.stream | seek | Allows to reset the stream to restart reading
:raise ValueError: If offset and whence are not 0 | def seek(self, offset, whence=getattr(os, 'SEEK_SET', 0)):
"""Allows to reset the stream to restart reading
:raise ValueError: If offset and whence are not 0"""
if offset != 0 or whence != getattr(os, 'SEEK_SET', 0):
raise ValueError("Can only seek to position 0")
# END handle offset
self._z... | (self, offset, whence=0) | [
0.05840197578072548,
0.027404284104704857,
-0.038220807909965515,
-0.01891077123582363,
0.022213803604245186,
-0.02056228742003441,
-0.0179035272449255,
0.07462676614522934,
-0.018965216353535652,
-0.003089787671342492,
-0.0034799810964614153,
-0.022921595722436905,
0.03782154247164726,
0.... |
722,785 | gitdb.stream | DeltaApplyReader | A reader which dynamically applies pack deltas to a base object, keeping the
memory demands to a minimum.
The size of the final object is only obtainable once all deltas have been
applied, unless it is retrieved from a pack index.
The uncompressed Delta has the following layout (MSB being a most signi... | class DeltaApplyReader(LazyMixin):
"""A reader which dynamically applies pack deltas to a base object, keeping the
memory demands to a minimum.
The size of the final object is only obtainable once all deltas have been
applied, unless it is retrieved from a pack index.
The uncompressed Delta has t... | (stream_list) | [
0.020255548879504204,
-0.07617337256669998,
-0.09455195814371109,
0.02885829098522663,
-0.00492458138614893,
0.015739107504487038,
-0.03769565373659134,
0.02983587421476841,
-0.04950487241148949,
-0.026766259223222733,
0.004296483471989632,
0.027470121160149574,
-0.018759844824671745,
0.05... |
722,787 | gitdb.stream | __init__ | Initialize this instance with a list of streams, the first stream being
the delta to apply on top of all following deltas, the last stream being the
base object onto which to apply the deltas | def __init__(self, stream_list):
"""Initialize this instance with a list of streams, the first stream being
the delta to apply on top of all following deltas, the last stream being the
base object onto which to apply the deltas"""
assert len(stream_list) > 1, "Need at least one delta and one base stream... | (self, stream_list) | [
-0.005748240277171135,
-0.045375172048807144,
-0.09060663729906082,
0.01886141300201416,
-0.06847590953111649,
-0.013265861198306084,
-0.033196087926626205,
0.03926766663789749,
-0.03474092856049538,
0.046596672385931015,
-0.025561705231666565,
0.05421309173107147,
-0.027465810999274254,
0... |
722,788 | gitdb.stream | _set_cache_brute_ | If we are here, we apply the actual deltas | def _set_cache_brute_(self, attr):
"""If we are here, we apply the actual deltas"""
# TODO: There should be a special case if there is only one stream
# Then the default-git algorithm should perform a tad faster, as the
# delta is not peaked into, causing less overhead.
buffer_info_list = list()
... | (self, attr) | [
0.028000595048069954,
-0.0685967430472374,
-0.08055120706558228,
0.019741835072636604,
-0.02151426300406456,
-0.013924875296652317,
-0.05011823773384094,
0.020609192550182343,
-0.06863445788621902,
0.009748355485498905,
-0.00001605673969606869,
0.03407210484147072,
-0.015744442120194435,
0... |
722,790 | gitdb.stream | _set_cache_too_slow_without_c | null | def _set_cache_too_slow_without_c(self, attr):
# the direct algorithm is fastest and most direct if there is only one
# delta. Also, the extra overhead might not be worth it for items smaller
# than X - definitely the case in python, every function call costs
# huge amounts of time
# if len(self._ds... | (self, attr) | [
-0.013016020879149437,
0.005966884084045887,
-0.05511758103966713,
0.04901058226823807,
-0.00955667719244957,
-0.02943340688943863,
-0.06667449325323105,
0.030361050739884377,
-0.021065274253487587,
-0.06679044663906097,
-0.004759012721478939,
0.07301340252161026,
-0.014716703444719315,
0.... |
722,791 | gitdb.stream | read | null | def read(self, count=0):
bl = self._size - self._br # bytes left
if count < 1 or count > bl:
count = bl
# NOTE: we could check for certain size limits, and possibly
# return buffers instead of strings to prevent byte copying
data = self._mm_target.read(count)
self._br += len(data)
... | (self, count=0) | [
-0.0223433505743742,
0.0076258061453700066,
-0.06366804242134094,
0.009569467976689339,
0.028349438682198524,
0.04013397917151451,
0.012353630736470222,
-0.00967453047633171,
0.04111456498503685,
-0.05162084475159645,
0.004859153181314468,
-0.00676779355853796,
-0.05999084562063217,
0.0371... |
722,792 | gitdb.stream | seek | Allows to reset the stream to restart reading
:raise ValueError: If offset and whence are not 0 | def seek(self, offset, whence=getattr(os, 'SEEK_SET', 0)):
"""Allows to reset the stream to restart reading
:raise ValueError: If offset and whence are not 0"""
if offset != 0 or whence != getattr(os, 'SEEK_SET', 0):
raise ValueError("Can only seek to position 0")
# END handle offset
self._b... | (self, offset, whence=0) | [
0.04783986136317253,
0.03460346907377243,
-0.05350510776042938,
-0.007050958927720785,
-0.0031757729593664408,
-0.005953754764050245,
-0.01689957082271576,
0.06378648430109024,
-0.011111927218735218,
-0.0038795575965195894,
-0.021279646083712578,
-0.05147681012749672,
0.06805290281772614,
... |
722,793 | gitdb.stream | FDCompressedSha1Writer | Digests data written to it, making the sha available, then compress the
data and write it to the file descriptor
**Note:** operates on raw file descriptors
**Note:** for this to work, you have to use the close-method of this instance | class FDCompressedSha1Writer(Sha1Writer):
"""Digests data written to it, making the sha available, then compress the
data and write it to the file descriptor
**Note:** operates on raw file descriptors
**Note:** for this to work, you have to use the close-method of this instance"""
__slots__ = ("fd... | (fd) | [
-0.01531852874904871,
-0.02477000653743744,
0.010057799518108368,
0.051073648035526276,
0.05727952718734741,
-0.043548133224248886,
-0.06337840110063553,
0.03791291266679764,
0.0011039727833122015,
-0.018162887543439865,
0.05553189292550087,
0.054033923894166946,
-0.023771360516548157,
0.0... |
722,794 | gitdb.stream | __init__ | null | def __init__(self, fd):
super().__init__()
self.fd = fd
self.zip = zlib.compressobj(zlib.Z_BEST_SPEED)
| (self, fd) | [
0.03777888044714928,
-0.008365698158740997,
-0.006696926895529032,
0.013594805262982845,
0.015342209488153458,
-0.01967577263712883,
-0.044663652777671814,
0.08198820799589157,
-0.042357079684734344,
-0.01210077479481697,
0.038582686334848404,
0.040994103997945786,
-0.07255222648382187,
0.... |
722,795 | gitdb.stream | close | null | def close(self):
remainder = self.zip.flush()
if write(self.fd, remainder) != len(remainder):
raise self.exc
return close(self.fd)
| (self) | [
0.02181560918688774,
0.01806740090250969,
-0.008260739967226982,
0.0516112744808197,
0.0421457514166832,
-0.06591319292783737,
-0.07434234023094177,
0.07199323922395706,
0.008416195400059223,
-0.002461381023749709,
0.018671950325369835,
-0.0655677393078804,
0.011788719333708286,
0.00270967... |
722,796 | gitdb.stream | sha | :return: sha so far
:param as_hex: if True, sha will be hex-encoded, binary otherwise | def sha(self, as_hex=False):
""":return: sha so far
:param as_hex: if True, sha will be hex-encoded, binary otherwise"""
if as_hex:
return self.sha1.hexdigest()
return self.sha1.digest()
| (self, as_hex=False) | [
-0.003129544435068965,
-0.008332384750247002,
0.0481213741004467,
0.028747381642460823,
0.04986364021897316,
-0.026064293459057808,
-0.02069811522960663,
0.026064293459057808,
0.0396539643406868,
-0.021011723205447197,
0.06617124378681183,
0.05198920518159866,
0.013685495592653751,
0.02088... |
722,797 | gitdb.stream | write | :raise IOError: If not all bytes could be written
:return: length of incoming data | def write(self, data):
""":raise IOError: If not all bytes could be written
:return: length of incoming data"""
self.sha1.update(data)
cdata = self.zip.compress(data)
bytes_written = write(self.fd, cdata)
if bytes_written != len(cdata):
raise self.exc
return len(data)
| (self, data) | [
-0.05764906853437424,
-0.003379946108907461,
0.027675794437527657,
0.06998476386070251,
0.07330727577209473,
-0.004776106681674719,
-0.05425586551427841,
0.00880995113402605,
0.020129457116127014,
-0.0401175320148468,
0.029955601319670677,
0.00929595623165369,
-0.008951334282755852,
-0.037... |
722,798 | gitdb.stream | FDStream | A simple wrapper providing the most basic functions on a file descriptor
with the fileobject interface. Cannot use os.fdopen as the resulting stream
takes ownership | class FDStream:
"""A simple wrapper providing the most basic functions on a file descriptor
with the fileobject interface. Cannot use os.fdopen as the resulting stream
takes ownership"""
__slots__ = ("_fd", '_pos')
def __init__(self, fd):
self._fd = fd
self._pos = 0
def write(... | (fd) | [
0.015803303569555283,
-0.050344809889793396,
-0.06927114725112915,
0.0030030980706214905,
0.06234779581427574,
0.024137666448950768,
0.010403841733932495,
0.05760680511593819,
-0.0023516821675002575,
-0.04488890990614891,
0.01474975049495697,
0.0042871166951954365,
-0.027279512956738472,
0... |
722,799 | gitdb.stream | __init__ | null | def __init__(self, fd):
self._fd = fd
self._pos = 0
| (self, fd) | [
0.02740815281867981,
0.0013532884186133742,
-0.03852050378918648,
0.019537627696990967,
0.0010834975400939584,
0.03434253856539726,
0.0036080465652048588,
0.09680400043725967,
-0.0016848385566845536,
-0.0334584042429924,
-0.002591725904494524,
0.014614214189350605,
-0.030736656859517097,
0... |
722,800 | gitdb.stream | close | null | def close(self):
close(self._fd)
| (self) | [
0.028728442266583443,
-0.0018225280800834298,
-0.0034768227487802505,
0.022181879729032516,
-0.020620010793209076,
-0.03339743614196777,
-0.03446083888411522,
0.08527147024869919,
0.008266281336545944,
-0.000686952902469784,
-0.027166573330760002,
-0.0730423554778099,
0.019390452653169632,
... |
722,801 | gitdb.stream | fileno | null | def fileno(self):
return self._fd
| (self) | [
0.008839955553412437,
0.020532580092549324,
0.005278266035020351,
0.04040174558758736,
0.025392066687345505,
0.033253490924835205,
0.025624260306358337,
0.02743205614387989,
0.013177006505429745,
-0.03199300915002823,
-0.014371147379279137,
-0.05695385858416557,
-0.04478026181459427,
0.001... |
722,802 | gitdb.stream | read | null | def read(self, count=0):
if count == 0:
count = os.path.getsize(self._filepath)
# END handle read everything
bytes = os.read(self._fd, count)
self._pos += len(bytes)
return bytes
| (self, count=0) | [
-0.014426114037632942,
-0.05215458199381828,
-0.04521723836660385,
0.06222262233495712,
0.06489083170890808,
0.05820252001285553,
0.02392493560910225,
-0.0037288214080035686,
0.035504959523677826,
-0.032018501311540604,
0.031929560005664825,
0.013083115220069885,
-0.040948107838630676,
0.0... |
722,803 | gitdb.stream | tell | null | def tell(self):
return self._pos
| (self) | [
0.03285292536020279,
0.04666683077812195,
-0.022125108167529106,
0.057639580219984055,
0.0645628571510315,
-0.00926641933619976,
0.007119222544133663,
0.058031462132930756,
0.010964582674205303,
-0.06374643743038177,
-0.04180094227194786,
-0.08902294188737869,
-0.026599114760756493,
0.0320... |
722,804 | gitdb.stream | write | null | def write(self, data):
self._pos += len(data)
os.write(self._fd, data)
| (self, data) | [
-0.032594162970781326,
0.02554677426815033,
-0.05993732810020447,
0.05662091076374054,
0.08981962502002716,
0.02808590605854988,
-0.04480617493391037,
0.061008255928754807,
0.012358834967017174,
-0.02117670513689518,
0.022420361638069153,
-0.07009385526180267,
0.021729441359639168,
-0.0063... |
722,805 | gitdb.db.base | FileDBBase | Provides basic facilities to retrieve files of interest, including
caching facilities to help mapping hexsha's to objects | class FileDBBase:
"""Provides basic facilities to retrieve files of interest, including
caching facilities to help mapping hexsha's to objects"""
def __init__(self, root_path):
"""Initialize this instance to look for its files at the given root path
All subsequent operations will be relati... | (root_path) | [
0.012965698726475239,
-0.07388108223676682,
-0.053622759878635406,
0.06717823445796967,
0.03815753757953644,
-0.05043984577059746,
-0.019228553399443626,
0.048118188977241516,
-0.04074131324887276,
-0.07384363561868668,
0.027373071759939194,
0.030499817803502083,
-0.027167117223143578,
0.0... |
722,806 | gitdb.db.base | __init__ | Initialize this instance to look for its files at the given root path
All subsequent operations will be relative to this path
:raise InvalidDBRoot:
**Note:** The base will not perform any accessablity checking as the base
might not yet be accessible, but become accessible before the ... | def __init__(self, root_path):
"""Initialize this instance to look for its files at the given root path
All subsequent operations will be relative to this path
:raise InvalidDBRoot:
**Note:** The base will not perform any accessablity checking as the base
might not yet be accessible, but become ... | (self, root_path) | [
-0.009460855275392532,
-0.024048883467912674,
-0.004379460588097572,
0.045133076608181,
0.0069931852631270885,
-0.0016382102621719241,
0.031983792781829834,
0.07150139659643173,
-0.0007368131773546338,
-0.02199103869497776,
0.03043169155716896,
0.032977838069200516,
0.012922569178044796,
0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.