function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def disconnect(self):
try:
self.__socket.close()
except socket.error, msg:
self.__socket = None
return 0
return 1 | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def recv(self):
buffer, self.__recv_addr = self.__socket.recvfrom(8192)
return buffer | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def get_socket(self):
return self.__socket | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def __init__(self, dstip, dstport = 135):
DCERPCTransport.__init__(self, dstip, dstport)
self.__socket = 0 | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def disconnect(self):
try:
self.__socket.close()
except socket.error, msg:
self.__socket = None
return 0
return 1 | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def recv(self):
buffer = self.__socket.recv(8192)
return buffer | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def connect(self):
TCPTransport.connect(self)
self.__socket.send('RPC_CONNECT ' + self.get_dip() + ':593 HTTP/1.0\r\n\r\n')
data = self.__socket.recv(8192)
if data[10:13] != '200':
raise Exception("Service not supported.") | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def __init__(self, dstip, dstport = 445, filename = '', username='', password='', lm_hash='', nt_hash=''):
DCERPCTransport.__init__(self, dstip, dstport)
self.__socket = None
self.__smb_server = 0
self.__tid = 0
self.__filename = filename
self.__handle = 0
self.__... | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def connect(self):
self.setup_smb_server()
if self.__smb_server.is_login_required():
if self._password != '' or (self._password == '' and self._nt_hash == '' and self._lm_hash == ''):
self.__smb_server.login(self._username, self._password)
elif self._nt_hash != ''... | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def disconnect(self):
self.__smb_server.disconnect_tree(self.__tid)
self.__smb_server.logoff() | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def recv(self):
if self._max_send_frag or self.__pending_recv:
# _max_send_frag is checked because it's the same condition we checked
# to decide whether to use write_andx() or send_trans() in send() above.
if self.__pending_recv:
self.__pending_recv -= 1
... | pwnieexpress/pwn_plug_sources | [
124,
97,
124,
24,
1321552607
] |
def testAdd(self): ## test method names begin 'test*'
self.assertEqual((1 + 2), 3)
self.assertEqual(0 + 1, 1) | Microvellum/Fluid-Designer | [
69,
30,
69,
37,
1461884765
] |
def __init__(self, head, size):
self.head = head
self.size = size | lvh/txyoga | [
24,
5,
24,
15,
1301588690
] |
def test_complete(self):
"""
Test serialization of a screwdriver.
"""
screwdriver = Screwdriver("philips", "m3")
state = screwdriver.toState()
self.assertEqual(state, {"head": "philips", "size": "m3"}) | lvh/txyoga | [
24,
5,
24,
15,
1301588690
] |
def test_deserialize(self):
"""
Deserialize a screwdriver.
"""
state = {"head": "philips", "size": "m3"}
screwdriver = Screwdriver.fromState(state)
for attr, value in state.iteritems():
self.assertEqual(getattr(screwdriver, attr), value) | lvh/txyoga | [
24,
5,
24,
15,
1301588690
] |
def test_createElement(self):
"""
Creates a screwdriver from some state, and verify that it has
correctly materialized.
"""
toolbox = Toolbox()
state = {"head": "philips", "size": "m3"}
screwdriver = toolbox.createElementFromState(state)
for attr, value i... | lvh/txyoga | [
24,
5,
24,
15,
1301588690
] |
def load(cur_graph, rdf_file_path, tmp_dir=None):
if os.path.isfile(rdf_file_path):
try:
cur_graph = __load_graph(cur_graph, rdf_file_path)
except IOError:
if tmp_dir is not None:
current_file_path = tmp_dir + os.sep + "tmp_rdf_file_create_nq.rdf"
... | essepuntato/opencitations | [
61,
3,
61,
25,
1460444527
] |
def db_table_exists(table):
"""Check if table exists."""
return table in connection.introspection.table_names() | tonioo/modoboa | [
2442,
336,
2442,
81,
1366105435
] |
def nolr(tile_type):
'''
Remove _L or _R suffix tile_type suffix, if present
Ex: BRAM_INT_INTERFACE_L => BRAM_INT_INTERFACE
Ex: VBRK => VBRK
'''
postfix = tile_type[-2:]
if postfix in ('_L', '_R'):
return tile_type[:-2]
else:
return tile_type | SymbiFlow/prjuray | [
48,
12,
48,
18,
1594844148
] |
def propagate_INT_bits_in_column(database, tiles_by_grid, tile_frames_map):
""" Propigate INT offsets up and down INT columns.
INT columns appear to be fairly regular, where starting from offset 0,
INT tiles next to INT tiles increase the word offset by 3.
"""
int_frames, int_words = localutil.get... | SymbiFlow/prjuray | [
48,
12,
48,
18,
1594844148
] |
def propagate_bits_in_column(database, tiles_by_grid, tile_type, term_b,
term_t, rbrk, rclk_types, tile_frames, tile_words,
tile_frames_map):
""" Propigate offsets up and down columns, based on a fixed pattern. """
rclk_frames, rclk_words = localutil.ge... | SymbiFlow/prjuray | [
48,
12,
48,
18,
1594844148
] |
def propagate_XIPHY_bits_in_column(database, tiles_by_grid, tile_frames_map):
xiphy_frames, xiphy_words = localutil.get_entry('XIPHY', 'CLB_IO_CLK')
rclk_frames, rclk_words = localutil.get_entry('RCLK_INT_L', 'CLB_IO_CLK')
_, ecc_words = localutil.get_entry('ECC', 'CLB_IO_CLK')
for tile, tile_data in d... | SymbiFlow/prjuray | [
48,
12,
48,
18,
1594844148
] |
def main():
import argparse
parser = argparse.ArgumentParser(
description="Generate tilegrid.json from bitstream deltas")
parser.add_argument("--verbose", action="store_true", help="")
parser.add_argument(
"--json-in",
default="tiles_basic.json",
help="Input .json witho... | SymbiFlow/prjuray | [
48,
12,
48,
18,
1594844148
] |
def join(
manager: bool = typer.Option(
False, "--manager", show_default=False, help="join new node with manager role"
) | rapydo/do | [
11,
3,
11,
11,
1495096286
] |
def email_sender(self):
return NotImplemented | jupiny/EnglishDiary | [
4,
1,
4,
1,
1466937386
] |
def email_subject(self):
return NotImplemented | jupiny/EnglishDiary | [
4,
1,
4,
1,
1466937386
] |
def email_template(self):
return NotImplemented | jupiny/EnglishDiary | [
4,
1,
4,
1,
1466937386
] |
def _declr(self):
addClkRstn(self)
self.tick1 = Signal()._m()
self.tick2 = Signal()._m()
self.tick16 = Signal()._m()
self.tick17 = Signal()._m()
self.tick34 = Signal()._m()
self.tick256 = Signal()._m()
self.tick384 = Signal()._m() | Nic30/hwtLib | [
34,
7,
34,
20,
1468185180
] |
def _declr(self):
addClkRstn(self)
self.tick1 = HandshakeSync()._m()
self.tick2 = HandshakeSync()._m()
self.tick16 = HandshakeSync()._m()
self.tick17 = HandshakeSync()._m()
self.tick34 = HandshakeSync()._m()
self.tick256 = HandshakeSync()._m()
self.tic... | Nic30/hwtLib | [
34,
7,
34,
20,
1468185180
] |
def _declr(self):
addClkRstn(self)
self.period = VectSignal(10)
self.en = Signal()
self.rstCntr = Signal()
self.cntr0 = Signal()._m()
self.cntr1 = Signal()._m() | Nic30/hwtLib | [
34,
7,
34,
20,
1468185180
] |
def tearDown(self):
self.rmSim()
SimTestCase.tearDown(self) | Nic30/hwtLib | [
34,
7,
34,
20,
1468185180
] |
def test_dynamic_simple(self):
u = DynamicCounterInstancesExample()
self.compileSimAndStart(u)
u.en._ag.data.append(1)
u.rstCntr._ag.data.extend([0, 0, 0, 0, 1, 1, 1, 0])
u.period._ag.data.append(5)
self.runSim(200 * Time.ns)
self.assertValSequenceEqual(
... | Nic30/hwtLib | [
34,
7,
34,
20,
1468185180
] |
def test_upgrade_atac_alignment_enrichment_quality_metric_1_2(
upgrader, atac_alignment_enrichment_quality_metric_1 | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def __init__(self, config, handlers):
super(KorrekturApp, self).__init__(handlers)
for handler in handlers:
handler[1].config = config
self.config = config | hhucn/netsec-uebungssystem | [
1,
2,
1,
6,
1412599680
] |
def users(self):
return self.config('korrektoren') | hhucn/netsec-uebungssystem | [
1,
2,
1,
6,
1412599680
] |
def create_acceleration_pc_fixtures(request):
""" Parameterized Acceleration path constraint.
Return:
-------
data: A tuple. Contains path, ss, alim.
pc: A `PathConstraint`.
"""
dof = request.param
if dof == 1: # Scalar
pi = ta.PolynomialPath([1, 2, 3]) # 1 + 2s + 3s^2
... | hungpham2511/toppra | [
434,
141,
434,
22,
1500429799
] |
def test_constraint_params(accel_constraint_setup):
""" Test constraint satisfaction with cvxpy.
"""
(path, ss, alim), accel_const = accel_constraint_setup
# An user of the class
a, b, c, F, g, ubound, xbound = accel_const.compute_constraint_params(path, ss)
assert xbound is None
N = ss.sh... | hungpham2511/toppra | [
434,
141,
434,
22,
1500429799
] |
def star_topology(random, population, args):
"""Returns the neighbors using a star topology. | aarongarrett/inspyred | [
175,
54,
175,
11,
1331181888
] |
def ring_topology(random, population, args):
"""Returns the neighbors using a ring topology. | aarongarrett/inspyred | [
175,
54,
175,
11,
1331181888
] |
def rgb_to_cairo(rgb):
if len(rgb) == 4:
r,g,b,a = rgb
return (r / 255.0, g / 255.0, b / 255.0, a / 255.0)
else:
r,g,b = rgb
return (r / 255.0, g / 255.0, b / 255.0, 1.0) | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def cairo_line_cap(line_cap):
if line_cap == 'round':
return cairo.LINE_CAP_ROUND
elif line_cap == 'square':
return cairo.LINE_CAP_SQUARE
else:
return cairo.LINE_CAP_BUTT | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def __init__(self, fname, def_styles, padding=0, scale=1.0):
BaseSurface.__init__(self, fname, def_styles, padding, scale)
self.ctx = None | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def text_bbox(self, text, font_params, spacing=0):
return CairoSurface.cairo_text_bbox(text, font_params, spacing, self.scale) | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def cairo_text_bbox(text, font_params, spacing=0, scale=1.0):
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 8, 8)
ctx = cairo.Context(surf)
# The scaling must match the final context.
# If not there can be a mismatch between the computed extents here
# and those generated for the final render.
... | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def draw_text(x, y, text, font, text_color, spacing, c):
c.save()
c.set_source_rgba(*rgb_to_cairo(text_color))
font = cairo_font(font)
c.translate(x, y)
if use_pygobject:
status, attrs, plain_text, _ = pango.parse_markup(text, len(text), '\0')
layout = pangocairo.create_layout(c)
... | SymbiFlow/symbolator | [
12,
3,
12,
4,
1594952177
] |
def __init__(
self, plotly_name="outlinecolor", parent_name="choropleth.colorbar", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def run_pydoc(module_name, *args):
"""
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
"""
cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read()
return output.strip() | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def get_pydoc_html(module):
"Returns pydoc generated output as html"
doc = pydoc.HTMLDoc()
output = doc.docmodule(module)
loc = doc.getdocloc(pydoc_mod) or ""
if loc:
loc = "<br><a href=\"" + loc + "\">Module Docs</a>"
return output.strip(), loc | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def get_pydoc_text(module):
"Returns pydoc generated output as text"
doc = pydoc.TextDoc()
loc = doc.getdocloc(pydoc_mod) or ""
if loc:
loc = "\nMODULE DOCS\n " + loc + "\n" | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def print_diffs(text1, text2):
"Prints unified diffs for two texts"
lines1 = text1.splitlines(True)
lines2 = text2.splitlines(True)
diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected',
tofile='got')
print '\n' + ''.join(diffs) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_html_doc(self):
result, doc_loc = get_pydoc_html(pydoc_mod)
mod_file = inspect.getabsfile(pydoc_mod)
if sys.platform == 'win32':
import nturl2path
mod_url = nturl2path.pathname2url(mod_file)
else:
mod_url = mod_file
expected_ht... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_text_doc(self):
result, doc_loc = get_pydoc_text(pydoc_mod)
expected_text = expected_text_pattern % \
(inspect.getabsfile(pydoc_mod), doc_loc)
if result != expected_text:
print_diffs(expected_text, result)
self.fail("outputs are not ... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_issue8225(self):
# Test issue8225 to ensure no doc link appears for xml.etree
result, doc_loc = get_pydoc_text(xml.etree)
self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_not_here(self):
missing_module = "test.i_am_not_here"
result = run_pydoc(missing_module)
expected = missing_pattern % missing_module
self.assertEqual(expected, result,
"documentation for missing module found") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_badimport(self):
# This tests the fix for issue 5230, where if pydoc found the module
# but the module had an internal import error pydoc would report no doc
# found.
modname = 'testmod_xyzzy'
testpairs = (
('i_am_not_here', 'i_am_not_here'),
... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def newdirinpath(dir):
os.mkdir(dir)
sys.path.insert(0, dir)
yield
sys.path.pop(0)
rmtree(dir) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_input_strip(self):
missing_module = " test.i_am_not_here "
result = run_pydoc(missing_module)
expected = missing_pattern % missing_module.strip()
self.assertEqual(expected, result,
"white space was not stripped from module name "
"or other error out... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_stripid(self):
# test with strings, other implementations might have different repr()
stripid = pydoc.stripid
# strip the id
self.assertEqual(stripid('<function stripid at 0x88dcee4>'),
'<function stripid>')
self.assertEqual(stripid('<funct... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_module(self):
# Check that pydocfodder module can be described
from test import pydocfodder
doc = pydoc.render_doc(pydocfodder)
self.assert_("pydocfodder" in doc) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_classic_class(self):
class C: "Classic class"
c = C()
self.assertEqual(pydoc.describe(C), 'class C')
self.assertEqual(pydoc.describe(c), 'instance of C')
expected = 'instance of C in module %s' % __name__
self.assert_(expected in pydoc.render_doc(c)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_class(self):
class C(object): "New-style class"
c = C() | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_main():
test.test_support.run_unittest(PyDocDocTest,
TestDescriptions) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def __init__(
self, plotly_name="size", parent_name="scatterternary.selected.marker", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self,domain='r-kvstore.aliyuncs.com',port=80):
RestApi.__init__(self,domain, port)
self.InstanceIds = None
self.InstanceStatus = None
self.PageNumber = None
self.PageSize = None
self.RegionId = None | francisar/rds_manager | [
11,
11,
11,
1,
1448422655
] |
def __init__(
self, plotly_name="thicknessmode", parent_name="surface.colorbar", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(
self, plotly_name="alignsrc", parent_name="contour.hoverlabel", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('discovery', sa.Column('num_datasets', sa.Integer(), nullable=True))
# ### end Alembic commands ### | ahoarfrost/metaseek | [
15,
1,
15,
11,
1473026988
] |
def convert_DBUS_to_python(val):
'''
quick hack to convert DBUS types to python types
'''
if isinstance(val, (str, six.text_type,)):
return str(val)
elif isinstance(val, (int,)):
return int(val)
elif isinstance(val, (dict,)):
return convert_DBUSDictionary_to_dict(val)
... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def convert_DBUSDictionary_to_dict(dbusdict):
return {convert_DBUS_to_python(k): convert_DBUS_to_python(dbusdict[k])
for k in dbusdict} | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def uPowerDeviceGetAll(conn, device):
'''
Utility method that uses the given DBUS connection to call the
UPower.GetAll method on the UPower device specified and returns pure
python data.
:param conn: DBUS connection
:param device: the device
'''
log.debug("uPowerDeviceGetAll %s", device... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def __init__(self, connect, devices):
'''
A DBUS signal handler class for the org.freedesktop.UPower.Device
'Changed' event. To re-read the device data, a DBUS connection is
required. This is established when an event is fired using the provided
connect method.
Essential... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def notify_observers(self, device=None, attributes=None):
"""notify observers """
log.debug("%s %r", device, attributes)
for observer, devices in list(self._observers.items()):
#log.debug("trying to notify the observer")
if devices is None or device is None or device in d... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def Changed(self, message):
device = message.get_path()
if device in self.device_paths:
log.debug('signal received: %s, args = %r', message.get_member(),
message.get_args())
conn = self.connect()
self.notify_observers(... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def upower_present(connect):
conn = connect()
result = conn.call_method(tdbus.DBUS_PATH_DBUS, 'ListNames',
tdbus.DBUS_INTERFACE_DBUS,
destination=tdbus.DBUS_SERVICE_DBUS)
conn.close()
# see if UPower is in the known services:
return UPOWER_... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def is_rechargeable(conn, device):
log.debug("testing IsRechargeable for '%s'", device)
return uPowerDeviceGet(conn, device, 'IsRechargeable') | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def main():
logging.basicConfig(level=logging.DEBUG)
if not upower_present(connect_dbus_system):
raise EnvironmentError("DBUS connection to UPower impossible")
conn = connect_dbus_system()
conn.add_handler(UPowerDeviceHandler(connect_dbus_system,
set(i... | infothrill/flask-socketio-dbus-demo | [
8,
4,
8,
12,
1399972424
] |
def display(self):
if self.username in MAINTAINERS:
return "* [#{}] {}"\
.format(self.pull_request_id, self.description)
else:
return "* [#{}] {} (by [@{}])"\
.format(self.pull_request_id, self.description, self.username) | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def __init__(self, header: str):
self.header = header
self.items = [] | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def display(self):
return """## {}\n\n""".format(self.header) + "\n\n".join(map(lambda l: l.display(), self.items)) | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def __init__(self, milestone_id=None):
self.milestone_id = milestone_id
self.labels = []
self.sections = {}
self.contributors = set()
self.__add_section("feature", ChangelogSection("New Features"))
self.__add_section("performance", ChangelogSection("Performance Improvemen... | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def add_item(self, label: str, item: ChangelogItem):
section = self.sections.get(label)
if section is not None:
section.add_item(item)
if item.username not in MAINTAINERS:
self.contributors.add(item.username) | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def collect_changelog(repo: Repository, milestone: Milestone):
print(f"Collecting changelog issues for `{milestone.title}` milestone")
changelog = Changelog(milestone.number)
issues = repo.get_issues(milestone=milestone, state="all")
comment_pattern = re.compile("<!--.*-->", re.RegexFlag.DOTALL)
c... | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def construct_repo(args: argparse.Namespace) -> Repository:
if args.token is not None:
login_or_token = args.token
password = None
else:
login_or_token = args.login
password = args.password
g = Github(login_or_token, password)
return g.get_repo(PLUGIN_REPO) | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def contributors():
last_post = "_posts/" + sorted(os.listdir("_posts"))[-1]
with open(last_post) as f:
text = f.read()
names = sorted({n[2:-1] for n in re.findall(r"\[@[^]]+]", text)})
with open(last_post) as f:
old_text = f.read()
with open(last_post, 'a') as f:
f.write... | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def contributor_list(args: argparse.Namespace) -> None:
if args.list is None:
raise ValueError("list flag should be set")
first = args.list[0]
last = args.list[1]
if first >= last:
raise ValueError("`first` should be less than `last`")
repo = construct_repo(args)
milestones = r... | intellij-rust/intellij-rust.github.io | [
70,
24,
70,
3,
1467554026
] |
def __init__(self, report):
self.data = report
self.type = self.data["reportMetadata"]["reportFormat"]
self.has_details = self.data["hasDetailRows"] | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def _flatten_record(record):
return [field["label"] for field in record] | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def records(self):
"""
Return a list of all records included in the report. If detail rows are not included
in the report a ValueError is returned instead.
Returns
-------
records: list
"""
if not self.has_details:
raise ValueError('Report doe... | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def __init__(self, report):
super().__init__(report)
self.data = report
self._check_type() | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def get_col_total(self, col_label, default=None):
"""
Return the total for the specified column. The default arg makes it possible to specify the return
value if the column label is not found.
Parameters
----------
col_label: string
default: string, optional, def... | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def _convert_parameter(parameter):
if type(parameter) is str:
new_parameter = [parameter]
elif parameter is None:
new_parameter = []
elif type(parameter) is list:
new_parameter = parameter
else:
raise ValueError
return new_parameter | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def _get_subgroup_index(group_above, subgroup_name):
subgroups_with_index = {subgroup['label']: index for index, subgroup in enumerate(group_above)}
index = subgroups_with_index[subgroup_name]
return index | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def _get_static_key(self, groups_of_interest, static_grouping_key):
grouping_depth = len(groups_of_interest)
group_index = grouping_depth - 1
top_grouping = self.data[static_grouping_key]["groupings"]
grouping = self._get_grouping(groups_of_interest, top_grouping, grouping_depth)
... | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def _build_keys(self, static_groups_of_interest, dynamic_groups_of_interest, static_grouping_key,
dynamic_grouping_key):
static_key = self._get_static_key(static_groups_of_interest, static_grouping_key)
dynamic_keys = self._get_dynamic_keys(dynamic_groups_of_interest, dynamic_groupin... | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def series_down(self, column_groups, row_groups=None, value_position=0):
"""
Return selected slice of a report on a vertical axis
Parameters
----------
column_groups: string or list
The selected column to return series from
If multiple grouping levels a l... | cghall/salesforce-reporting | [
22,
11,
22,
8,
1448899594
] |
def setUp(self):
# setting up our random data-set
rng = np.random.RandomState(42)
# D1 = train machines; D2 = create COBRA; D3 = calibrate epsilon, alpha; D4 = testing
n_features = 20
D1, D2, D3, D4 = 200, 200, 200, 200
D = D1 + D2 + D3 + D4
X = rng.uniform(-1, 1... | bhargavvader/pycobra | [
113,
22,
113,
3,
1490467649
] |
def test_alpha_grid(self):
(alpha, epsilon), mse = self.cobra_diagnostics.optimal_alpha_grid(self.test_data[0], self.test_response[0])
expected_alpha, expected_mse = 1, 0.01331659692231877
self.assertEqual(expected_alpha, alpha)
self.assertAlmostEqual(expected_mse, mse[0], places=3) | bhargavvader/pycobra | [
113,
22,
113,
3,
1490467649
] |
def test_machines_grid(self):
(machines, epsilon), mse = self.cobra_diagnostics.optimal_machines_grid(self.test_data[0], self.test_response[0])
expected_machines, expected_mse = ('svm','ridge'), 1.92151481985802e-05
self.assertEqual(sorted(expected_machines), sorted(machines))
self.asser... | bhargavvader/pycobra | [
113,
22,
113,
3,
1490467649
] |
def test_epsilon(self):
epsilon, mse = self.cobra_diagnostics.optimal_epsilon(self.test_data, self.test_response)
expected_epsilon= 0.3709790878655187
self.assertAlmostEqual(expected_epsilon, epsilon, places=3) | bhargavvader/pycobra | [
113,
22,
113,
3,
1490467649
] |
def test_beta(self):
beta, mse = self.cobra_diagnostics_ewa.optimal_beta(self.test_data, self.test_response)
expected_beta, expected_mse = 0.1, 0.07838339131485009
self.assertAlmostEqual(expected_beta, beta, places=3)
self.assertAlmostEqual(expected_mse, mse, places=3) | bhargavvader/pycobra | [
113,
22,
113,
3,
1490467649
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.