id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
50,200 | sbjorn/vici | vici/session.py | Session.list_policies | def list_policies(self, filters=None):
"""Retrieve installed trap, drop and bypass policies.
:param filters: retrieve only matching policies (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list
"""
_, policy_list =... | python | def list_policies(self, filters=None):
"""Retrieve installed trap, drop and bypass policies.
:param filters: retrieve only matching policies (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list
"""
_, policy_list =... | [
"def",
"list_policies",
"(",
"self",
",",
"filters",
"=",
"None",
")",
":",
"_",
",",
"policy_list",
"=",
"self",
".",
"handler",
".",
"streamed_request",
"(",
"\"list-policies\"",
",",
"\"list-policy\"",
",",
"filters",
")",
"return",
"policy_list"
] | Retrieve installed trap, drop and bypass policies.
:param filters: retrieve only matching policies (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list | [
"Retrieve",
"installed",
"trap",
"drop",
"and",
"bypass",
"policies",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L95-L105 |
50,201 | sbjorn/vici | vici/session.py | Session.list_conns | def list_conns(self, filters=None):
"""Retrieve loaded connections.
:param filters: retrieve only matching configuration names (optional)
:type filters: dict
:return: list of connections
:rtype: list
"""
_, connection_list = self.handler.streamed_request("list-co... | python | def list_conns(self, filters=None):
"""Retrieve loaded connections.
:param filters: retrieve only matching configuration names (optional)
:type filters: dict
:return: list of connections
:rtype: list
"""
_, connection_list = self.handler.streamed_request("list-co... | [
"def",
"list_conns",
"(",
"self",
",",
"filters",
"=",
"None",
")",
":",
"_",
",",
"connection_list",
"=",
"self",
".",
"handler",
".",
"streamed_request",
"(",
"\"list-conns\"",
",",
"\"list-conn\"",
",",
"filters",
")",
"return",
"connection_list"
] | Retrieve loaded connections.
:param filters: retrieve only matching configuration names (optional)
:type filters: dict
:return: list of connections
:rtype: list | [
"Retrieve",
"loaded",
"connections",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L107-L117 |
50,202 | sbjorn/vici | vici/session.py | Session.list_certs | def list_certs(self, filters=None):
"""Retrieve loaded certificates.
:param filters: retrieve only matching certificates (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list
"""
_, cert_list = self.handler.streamed... | python | def list_certs(self, filters=None):
"""Retrieve loaded certificates.
:param filters: retrieve only matching certificates (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list
"""
_, cert_list = self.handler.streamed... | [
"def",
"list_certs",
"(",
"self",
",",
"filters",
"=",
"None",
")",
":",
"_",
",",
"cert_list",
"=",
"self",
".",
"handler",
".",
"streamed_request",
"(",
"\"list-certs\"",
",",
"\"list-cert\"",
",",
"filters",
")",
"return",
"cert_list"
] | Retrieve loaded certificates.
:param filters: retrieve only matching certificates (optional)
:type filters: dict
:return: list of installed trap, drop and bypass policies
:rtype: list | [
"Retrieve",
"loaded",
"certificates",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L127-L137 |
50,203 | sbjorn/vici | vici/session.py | Session._result | def _result(self, command_response, log=None):
"""Create a CommandResult for a request response.
:param command_response: command request response
:type command_response: dict
:param log: list of log messages (optional)
:type log: list
:return: a CommandResult containing... | python | def _result(self, command_response, log=None):
"""Create a CommandResult for a request response.
:param command_response: command request response
:type command_response: dict
:param log: list of log messages (optional)
:type log: list
:return: a CommandResult containing... | [
"def",
"_result",
"(",
"self",
",",
"command_response",
",",
"log",
"=",
"None",
")",
":",
"if",
"command_response",
"[",
"\"success\"",
"]",
"==",
"\"yes\"",
":",
"return",
"CommandResult",
"(",
"True",
",",
"None",
",",
"log",
")",
"else",
":",
"return... | Create a CommandResult for a request response.
:param command_response: command request response
:type command_response: dict
:param log: list of log messages (optional)
:type log: list
:return: a CommandResult containing any given log messages
:rtype: :py:class:`vici.se... | [
"Create",
"a",
"CommandResult",
"for",
"a",
"request",
"response",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L234-L247 |
50,204 | sbjorn/vici | vici/session.py | SessionHandler.request | def request(self, command, message=None):
"""Send command request with an optional message.
:param command: command to send
:type command: str
:param message: message (optional)
:type message: str
:return: command result
:rtype: dict
"""
if messag... | python | def request(self, command, message=None):
"""Send command request with an optional message.
:param command: command to send
:type command: str
:param message: message (optional)
:type message: str
:return: command result
:rtype: dict
"""
if messag... | [
"def",
"request",
"(",
"self",
",",
"command",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"not",
"None",
":",
"message",
"=",
"Message",
".",
"serialize",
"(",
"message",
")",
"packet",
"=",
"Packet",
".",
"request",
"(",
"command",
... | Send command request with an optional message.
:param command: command to send
:type command: str
:param message: message (optional)
:type message: str
:return: command result
:rtype: dict | [
"Send",
"command",
"request",
"with",
"an",
"optional",
"message",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L268-L292 |
50,205 | sbjorn/vici | vici/session.py | SessionHandler.streamed_request | def streamed_request(self, command, event_stream_type, message=None):
"""Send command request and collect and return all emitted events.
:param command: command to send
:type command: str
:param event_stream_type: event type emitted on command execution
:type event_stream_type: ... | python | def streamed_request(self, command, event_stream_type, message=None):
"""Send command request and collect and return all emitted events.
:param command: command to send
:type command: str
:param event_stream_type: event type emitted on command execution
:type event_stream_type: ... | [
"def",
"streamed_request",
"(",
"self",
",",
"command",
",",
"event_stream_type",
",",
"message",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"if",
"message",
"is",
"not",
"None",
":",
"message",
"=",
"Message",
".",
"serialize",
"(",
"message",
")",... | Send command request and collect and return all emitted events.
:param command: command to send
:type command: str
:param event_stream_type: event type emitted on command execution
:type event_stream_type: str
:param message: message (optional)
:type message: str
... | [
"Send",
"command",
"request",
"and",
"collect",
"and",
"return",
"all",
"emitted",
"events",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L294-L355 |
50,206 | sbjorn/vici | vici/session.py | SessionHandler._read | def _read(self):
"""Get next packet from transport.
:return: parsed packet in a tuple with message type and payload
:rtype: :py:class:`collections.namedtuple`
"""
raw_response = self.transport.receive()
response = Packet.parse(raw_response)
# FIXME
if re... | python | def _read(self):
"""Get next packet from transport.
:return: parsed packet in a tuple with message type and payload
:rtype: :py:class:`collections.namedtuple`
"""
raw_response = self.transport.receive()
response = Packet.parse(raw_response)
# FIXME
if re... | [
"def",
"_read",
"(",
"self",
")",
":",
"raw_response",
"=",
"self",
".",
"transport",
".",
"receive",
"(",
")",
"response",
"=",
"Packet",
".",
"parse",
"(",
"raw_response",
")",
"# FIXME",
"if",
"response",
".",
"response_type",
"==",
"Packet",
".",
"EV... | Get next packet from transport.
:return: parsed packet in a tuple with message type and payload
:rtype: :py:class:`collections.namedtuple` | [
"Get",
"next",
"packet",
"from",
"transport",
"."
] | 147135905b68892734b09ec8a569c71733648090 | https://github.com/sbjorn/vici/blob/147135905b68892734b09ec8a569c71733648090/vici/session.py#L357-L373 |
50,207 | raamana/mrivis | mrivis/utils.py | _diff_image | def _diff_image(slice1, slice2,
abs_value=True,
cmap='gray',
**kwargs):
"""Computes the difference image"""
diff = slice1 - slice2
if abs_value:
diff = np.abs(diff)
return diff, cmap | python | def _diff_image(slice1, slice2,
abs_value=True,
cmap='gray',
**kwargs):
"""Computes the difference image"""
diff = slice1 - slice2
if abs_value:
diff = np.abs(diff)
return diff, cmap | [
"def",
"_diff_image",
"(",
"slice1",
",",
"slice2",
",",
"abs_value",
"=",
"True",
",",
"cmap",
"=",
"'gray'",
",",
"*",
"*",
"kwargs",
")",
":",
"diff",
"=",
"slice1",
"-",
"slice2",
"if",
"abs_value",
":",
"diff",
"=",
"np",
".",
"abs",
"(",
"dif... | Computes the difference image | [
"Computes",
"the",
"difference",
"image"
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L10-L21 |
50,208 | raamana/mrivis | mrivis/utils.py | diff_colormap | def diff_colormap():
"Custom colormap to map low values to black or another color."
# bottom = plt.cm.copper(np.linspace(0., 1, 6))
black = np.atleast_2d([0., 0., 0., 1.])
bottom = np.repeat(black, 6, axis=0)
middle = plt.cm.copper(np.linspace(0, 1, 250))
# remain = plt.cm.Reds(np.linspace(0, 1... | python | def diff_colormap():
"Custom colormap to map low values to black or another color."
# bottom = plt.cm.copper(np.linspace(0., 1, 6))
black = np.atleast_2d([0., 0., 0., 1.])
bottom = np.repeat(black, 6, axis=0)
middle = plt.cm.copper(np.linspace(0, 1, 250))
# remain = plt.cm.Reds(np.linspace(0, 1... | [
"def",
"diff_colormap",
"(",
")",
":",
"# bottom = plt.cm.copper(np.linspace(0., 1, 6))",
"black",
"=",
"np",
".",
"atleast_2d",
"(",
"[",
"0.",
",",
"0.",
",",
"0.",
",",
"1.",
"]",
")",
"bottom",
"=",
"np",
".",
"repeat",
"(",
"black",
",",
"6",
",",
... | Custom colormap to map low values to black or another color. | [
"Custom",
"colormap",
"to",
"map",
"low",
"values",
"to",
"black",
"or",
"another",
"color",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L24-L36 |
50,209 | raamana/mrivis | mrivis/utils.py | check_bounding_rect | def check_bounding_rect(rect_pos):
"""Ensure the rect spec is valid."""
if not isinstance(rect_pos, Iterable):
raise ValueError('rectangle spect must be a tuple of floats '
'specifying (left, right, width, height)')
left, bottom, width, height = rect_pos
for val, name ... | python | def check_bounding_rect(rect_pos):
"""Ensure the rect spec is valid."""
if not isinstance(rect_pos, Iterable):
raise ValueError('rectangle spect must be a tuple of floats '
'specifying (left, right, width, height)')
left, bottom, width, height = rect_pos
for val, name ... | [
"def",
"check_bounding_rect",
"(",
"rect_pos",
")",
":",
"if",
"not",
"isinstance",
"(",
"rect_pos",
",",
"Iterable",
")",
":",
"raise",
"ValueError",
"(",
"'rectangle spect must be a tuple of floats '",
"'specifying (left, right, width, height)'",
")",
"left",
",",
"bo... | Ensure the rect spec is valid. | [
"Ensure",
"the",
"rect",
"spec",
"is",
"valid",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L49-L70 |
50,210 | raamana/mrivis | mrivis/utils.py | check_num_slices | def check_num_slices(num_slices, img_shape=None, num_dims=3):
"""Ensures requested number of slices is valid.
Atleast 1 and atmost the image size, if available
"""
if not isinstance(num_slices, Iterable) or len(num_slices) == 1:
num_slices = np.repeat(num_slices, num_dims)
if img_shape is... | python | def check_num_slices(num_slices, img_shape=None, num_dims=3):
"""Ensures requested number of slices is valid.
Atleast 1 and atmost the image size, if available
"""
if not isinstance(num_slices, Iterable) or len(num_slices) == 1:
num_slices = np.repeat(num_slices, num_dims)
if img_shape is... | [
"def",
"check_num_slices",
"(",
"num_slices",
",",
"img_shape",
"=",
"None",
",",
"num_dims",
"=",
"3",
")",
":",
"if",
"not",
"isinstance",
"(",
"num_slices",
",",
"Iterable",
")",
"or",
"len",
"(",
"num_slices",
")",
"==",
"1",
":",
"num_slices",
"=",
... | Ensures requested number of slices is valid.
Atleast 1 and atmost the image size, if available | [
"Ensures",
"requested",
"number",
"of",
"slices",
"is",
"valid",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L85-L102 |
50,211 | raamana/mrivis | mrivis/utils.py | check_int | def check_int(num,
num_descr='number',
min_value=0,
max_value=np.Inf):
"""Validation and typecasting."""
if not np.isfinite(num) or num < min_value or num > max_value:
raise ValueError('{}={} is not finite or '
'is not >= {} or '
... | python | def check_int(num,
num_descr='number',
min_value=0,
max_value=np.Inf):
"""Validation and typecasting."""
if not np.isfinite(num) or num < min_value or num > max_value:
raise ValueError('{}={} is not finite or '
'is not >= {} or '
... | [
"def",
"check_int",
"(",
"num",
",",
"num_descr",
"=",
"'number'",
",",
"min_value",
"=",
"0",
",",
"max_value",
"=",
"np",
".",
"Inf",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"num",
")",
"or",
"num",
"<",
"min_value",
"or",
"num",
">",
... | Validation and typecasting. | [
"Validation",
"and",
"typecasting",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L105-L116 |
50,212 | raamana/mrivis | mrivis/utils.py | read_image | def read_image(img_spec, bkground_thresh, ensure_num_dim=3):
"""Image reader, with additional checks on size.
Can optionally remove stray values close to zero (smaller than 5 %ile)."""
img = load_image_from_disk(img_spec)
if not np.issubdtype(img.dtype, np.floating):
img = img.astype('float32... | python | def read_image(img_spec, bkground_thresh, ensure_num_dim=3):
"""Image reader, with additional checks on size.
Can optionally remove stray values close to zero (smaller than 5 %ile)."""
img = load_image_from_disk(img_spec)
if not np.issubdtype(img.dtype, np.floating):
img = img.astype('float32... | [
"def",
"read_image",
"(",
"img_spec",
",",
"bkground_thresh",
",",
"ensure_num_dim",
"=",
"3",
")",
":",
"img",
"=",
"load_image_from_disk",
"(",
"img_spec",
")",
"if",
"not",
"np",
".",
"issubdtype",
"(",
"img",
".",
"dtype",
",",
"np",
".",
"floating",
... | Image reader, with additional checks on size.
Can optionally remove stray values close to zero (smaller than 5 %ile). | [
"Image",
"reader",
"with",
"additional",
"checks",
"on",
"size",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L139-L154 |
50,213 | raamana/mrivis | mrivis/utils.py | load_image_from_disk | def load_image_from_disk(img_spec):
"""Vanilla image loader."""
if isinstance(img_spec, str):
if pexists(realpath(img_spec)):
hdr = nib.load(img_spec)
# trying to stick to an orientation
hdr = nib.as_closest_canonical(hdr)
img = hdr.get_data()
els... | python | def load_image_from_disk(img_spec):
"""Vanilla image loader."""
if isinstance(img_spec, str):
if pexists(realpath(img_spec)):
hdr = nib.load(img_spec)
# trying to stick to an orientation
hdr = nib.as_closest_canonical(hdr)
img = hdr.get_data()
els... | [
"def",
"load_image_from_disk",
"(",
"img_spec",
")",
":",
"if",
"isinstance",
"(",
"img_spec",
",",
"str",
")",
":",
"if",
"pexists",
"(",
"realpath",
"(",
"img_spec",
")",
")",
":",
"hdr",
"=",
"nib",
".",
"load",
"(",
"img_spec",
")",
"# trying to stic... | Vanilla image loader. | [
"Vanilla",
"image",
"loader",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L157-L174 |
50,214 | raamana/mrivis | mrivis/utils.py | threshold_image | def threshold_image(img, bkground_thresh, bkground_value=0.0):
"""
Thresholds a given image at a value or percentile.
Replacement value can be specified too.
Parameters
-----------
image_in : ndarray
Input image
bkground_thresh : float
a threshold value to identify the ba... | python | def threshold_image(img, bkground_thresh, bkground_value=0.0):
"""
Thresholds a given image at a value or percentile.
Replacement value can be specified too.
Parameters
-----------
image_in : ndarray
Input image
bkground_thresh : float
a threshold value to identify the ba... | [
"def",
"threshold_image",
"(",
"img",
",",
"bkground_thresh",
",",
"bkground_value",
"=",
"0.0",
")",
":",
"if",
"bkground_thresh",
"is",
"None",
":",
"return",
"img",
"if",
"isinstance",
"(",
"bkground_thresh",
",",
"str",
")",
":",
"try",
":",
"thresh_perc... | Thresholds a given image at a value or percentile.
Replacement value can be specified too.
Parameters
-----------
image_in : ndarray
Input image
bkground_thresh : float
a threshold value to identify the background
bkground_value : float
a value to fill the background... | [
"Thresholds",
"a",
"given",
"image",
"at",
"a",
"value",
"or",
"percentile",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L216-L261 |
50,215 | raamana/mrivis | mrivis/utils.py | row_wise_rescale | def row_wise_rescale(matrix):
"""
Row-wise rescale of a given matrix.
For fMRI data (num_voxels x num_time_points), this would translate to voxel-wise normalization over time.
Parameters
----------
matrix : ndarray
Input rectangular matrix, typically a carpet of size num_voxels x num_... | python | def row_wise_rescale(matrix):
"""
Row-wise rescale of a given matrix.
For fMRI data (num_voxels x num_time_points), this would translate to voxel-wise normalization over time.
Parameters
----------
matrix : ndarray
Input rectangular matrix, typically a carpet of size num_voxels x num_... | [
"def",
"row_wise_rescale",
"(",
"matrix",
")",
":",
"if",
"matrix",
".",
"shape",
"[",
"0",
"]",
"<=",
"matrix",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"'Number of voxels is less than the number of time points!! '",
"'Are you sure data is resh... | Row-wise rescale of a given matrix.
For fMRI data (num_voxels x num_time_points), this would translate to voxel-wise normalization over time.
Parameters
----------
matrix : ndarray
Input rectangular matrix, typically a carpet of size num_voxels x num_4th_dim, 4th_dim could be time points or g... | [
"Row",
"-",
"wise",
"rescale",
"of",
"a",
"given",
"matrix",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L302-L336 |
50,216 | raamana/mrivis | mrivis/utils.py | crop_to_extents | def crop_to_extents(img1, img2, padding):
"""Crop the images to ensure both fit within the bounding box"""
beg_coords1, end_coords1 = crop_coords(img1, padding)
beg_coords2, end_coords2 = crop_coords(img2, padding)
beg_coords = np.fmin(beg_coords1, beg_coords2)
end_coords = np.fmax(end_coords1, en... | python | def crop_to_extents(img1, img2, padding):
"""Crop the images to ensure both fit within the bounding box"""
beg_coords1, end_coords1 = crop_coords(img1, padding)
beg_coords2, end_coords2 = crop_coords(img2, padding)
beg_coords = np.fmin(beg_coords1, beg_coords2)
end_coords = np.fmax(end_coords1, en... | [
"def",
"crop_to_extents",
"(",
"img1",
",",
"img2",
",",
"padding",
")",
":",
"beg_coords1",
",",
"end_coords1",
"=",
"crop_coords",
"(",
"img1",
",",
"padding",
")",
"beg_coords2",
",",
"end_coords2",
"=",
"crop_coords",
"(",
"img2",
",",
"padding",
")",
... | Crop the images to ensure both fit within the bounding box | [
"Crop",
"the",
"images",
"to",
"ensure",
"both",
"fit",
"within",
"the",
"bounding",
"box"
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L350-L362 |
50,217 | raamana/mrivis | mrivis/utils.py | crop_image | def crop_image(img, padding=5):
"Crops an image or slice to its extents"
if padding < 1:
return img
beg_coords, end_coords = crop_coords(img, padding)
if len(img.shape) == 3:
img = crop_3dimage(img, beg_coords, end_coords)
elif len(img.shape) == 2:
img = crop_2dimage(img, ... | python | def crop_image(img, padding=5):
"Crops an image or slice to its extents"
if padding < 1:
return img
beg_coords, end_coords = crop_coords(img, padding)
if len(img.shape) == 3:
img = crop_3dimage(img, beg_coords, end_coords)
elif len(img.shape) == 2:
img = crop_2dimage(img, ... | [
"def",
"crop_image",
"(",
"img",
",",
"padding",
"=",
"5",
")",
":",
"if",
"padding",
"<",
"1",
":",
"return",
"img",
"beg_coords",
",",
"end_coords",
"=",
"crop_coords",
"(",
"img",
",",
"padding",
")",
"if",
"len",
"(",
"img",
".",
"shape",
")",
... | Crops an image or slice to its extents | [
"Crops",
"an",
"image",
"or",
"slice",
"to",
"its",
"extents"
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L365-L380 |
50,218 | raamana/mrivis | mrivis/utils.py | crop_coords | def crop_coords(img, padding):
"""Find coordinates describing extent of non-zero portion of image, padded"""
coords = np.nonzero(img)
empty_axis_exists = np.any([len(arr) == 0 for arr in coords])
if empty_axis_exists:
end_coords = img.shape
beg_coords = np.zeros((1, img.ndim)).astype(in... | python | def crop_coords(img, padding):
"""Find coordinates describing extent of non-zero portion of image, padded"""
coords = np.nonzero(img)
empty_axis_exists = np.any([len(arr) == 0 for arr in coords])
if empty_axis_exists:
end_coords = img.shape
beg_coords = np.zeros((1, img.ndim)).astype(in... | [
"def",
"crop_coords",
"(",
"img",
",",
"padding",
")",
":",
"coords",
"=",
"np",
".",
"nonzero",
"(",
"img",
")",
"empty_axis_exists",
"=",
"np",
".",
"any",
"(",
"[",
"len",
"(",
"arr",
")",
"==",
"0",
"for",
"arr",
"in",
"coords",
"]",
")",
"if... | Find coordinates describing extent of non-zero portion of image, padded | [
"Find",
"coordinates",
"describing",
"extent",
"of",
"non",
"-",
"zero",
"portion",
"of",
"image",
"padded"
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L383-L397 |
50,219 | raamana/mrivis | mrivis/utils.py | verify_sampler | def verify_sampler(sampler, image, image_shape, view_set, num_slices):
"""verifies the sampler requested is valid."""
if isinstance(sampler, str):
sampler = sampler.lower()
if sampler not in ['linear', ]:
raise ValueError('Sampling strategy: {} not implemented.'.format(sampler))
... | python | def verify_sampler(sampler, image, image_shape, view_set, num_slices):
"""verifies the sampler requested is valid."""
if isinstance(sampler, str):
sampler = sampler.lower()
if sampler not in ['linear', ]:
raise ValueError('Sampling strategy: {} not implemented.'.format(sampler))
... | [
"def",
"verify_sampler",
"(",
"sampler",
",",
"image",
",",
"image_shape",
",",
"view_set",
",",
"num_slices",
")",
":",
"if",
"isinstance",
"(",
"sampler",
",",
"str",
")",
":",
"sampler",
"=",
"sampler",
".",
"lower",
"(",
")",
"if",
"sampler",
"not",
... | verifies the sampler requested is valid. | [
"verifies",
"the",
"sampler",
"requested",
"is",
"valid",
"."
] | 199ad096b8a1d825f69109e7218a81b2f1cec756 | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/utils.py#L469-L498 |
50,220 | idlesign/django-sitegate | sitegate/signup_flows/modern.py | get_username_max_len | def get_username_max_len():
"""Returns username maximum length as supported by Django.
:rtype: int
"""
fields = [field for field in USER._meta.fields if field.name == 'username']
try:
length = fields[0].max_length
except IndexError:
length = 30
return length | python | def get_username_max_len():
"""Returns username maximum length as supported by Django.
:rtype: int
"""
fields = [field for field in USER._meta.fields if field.name == 'username']
try:
length = fields[0].max_length
except IndexError:
length = 30
return length | [
"def",
"get_username_max_len",
"(",
")",
":",
"fields",
"=",
"[",
"field",
"for",
"field",
"in",
"USER",
".",
"_meta",
".",
"fields",
"if",
"field",
".",
"name",
"==",
"'username'",
"]",
"try",
":",
"length",
"=",
"fields",
"[",
"0",
"]",
".",
"max_l... | Returns username maximum length as supported by Django.
:rtype: int | [
"Returns",
"username",
"maximum",
"length",
"as",
"supported",
"by",
"Django",
"."
] | 0e58de91605071833d75a7c21f2d0de2f2e3c896 | https://github.com/idlesign/django-sitegate/blob/0e58de91605071833d75a7c21f2d0de2f2e3c896/sitegate/signup_flows/modern.py#L11-L21 |
50,221 | pudo-attic/scrapekit | scrapekit/config.py | Config._get_env | def _get_env(self, config):
""" Read environment variables based on the settings defined in
the defaults. These are expected to be upper-case versions of
the actual setting names, prefixed by ``SCRAPEKIT_``. """
for option, value in config.items():
env_name = 'SCRAPEKIT_%s' %... | python | def _get_env(self, config):
""" Read environment variables based on the settings defined in
the defaults. These are expected to be upper-case versions of
the actual setting names, prefixed by ``SCRAPEKIT_``. """
for option, value in config.items():
env_name = 'SCRAPEKIT_%s' %... | [
"def",
"_get_env",
"(",
"self",
",",
"config",
")",
":",
"for",
"option",
",",
"value",
"in",
"config",
".",
"items",
"(",
")",
":",
"env_name",
"=",
"'SCRAPEKIT_%s'",
"%",
"option",
".",
"upper",
"(",
")",
"value",
"=",
"os",
".",
"environ",
".",
... | Read environment variables based on the settings defined in
the defaults. These are expected to be upper-case versions of
the actual setting names, prefixed by ``SCRAPEKIT_``. | [
"Read",
"environment",
"variables",
"based",
"on",
"the",
"settings",
"defined",
"in",
"the",
"defaults",
".",
"These",
"are",
"expected",
"to",
"be",
"upper",
"-",
"case",
"versions",
"of",
"the",
"actual",
"setting",
"names",
"prefixed",
"by",
"SCRAPEKIT_",
... | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/config.py#L31-L39 |
50,222 | pudo-attic/scrapekit | scrapekit/tasks.py | TaskManager._spawn | def _spawn(self):
""" Initialize the queue and the threads. """
self.queue = Queue(maxsize=self.num_threads * 10)
for i in range(self.num_threads):
t = Thread(target=self._consume)
t.daemon = True
t.start() | python | def _spawn(self):
""" Initialize the queue and the threads. """
self.queue = Queue(maxsize=self.num_threads * 10)
for i in range(self.num_threads):
t = Thread(target=self._consume)
t.daemon = True
t.start() | [
"def",
"_spawn",
"(",
"self",
")",
":",
"self",
".",
"queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"num_threads",
"*",
"10",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_threads",
")",
":",
"t",
"=",
"Thread",
"(",
"target",
... | Initialize the queue and the threads. | [
"Initialize",
"the",
"queue",
"and",
"the",
"threads",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L38-L44 |
50,223 | pudo-attic/scrapekit | scrapekit/tasks.py | TaskManager._consume | def _consume(self):
""" Main loop for each thread, handles picking a task off the
queue, processing it and notifying the queue that it is done.
"""
while True:
try:
task, args, kwargs = self.queue.get(True)
task(*args, **kwargs)
fin... | python | def _consume(self):
""" Main loop for each thread, handles picking a task off the
queue, processing it and notifying the queue that it is done.
"""
while True:
try:
task, args, kwargs = self.queue.get(True)
task(*args, **kwargs)
fin... | [
"def",
"_consume",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"task",
",",
"args",
",",
"kwargs",
"=",
"self",
".",
"queue",
".",
"get",
"(",
"True",
")",
"task",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"finally",
":",
"se... | Main loop for each thread, handles picking a task off the
queue, processing it and notifying the queue that it is done. | [
"Main",
"loop",
"for",
"each",
"thread",
"handles",
"picking",
"a",
"task",
"off",
"the",
"queue",
"processing",
"it",
"and",
"notifying",
"the",
"queue",
"that",
"it",
"is",
"done",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L46-L55 |
50,224 | pudo-attic/scrapekit | scrapekit/tasks.py | TaskManager.put | def put(self, task, args, kwargs):
""" Add a new item to the queue. An item is a task and the
arguments needed to call it.
Do not call this directly, use Task.queue/Task.run instead.
"""
if self.num_threads == 0:
return task(*args, **kwargs)
if self.queue is ... | python | def put(self, task, args, kwargs):
""" Add a new item to the queue. An item is a task and the
arguments needed to call it.
Do not call this directly, use Task.queue/Task.run instead.
"""
if self.num_threads == 0:
return task(*args, **kwargs)
if self.queue is ... | [
"def",
"put",
"(",
"self",
",",
"task",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"self",
".",
"num_threads",
"==",
"0",
":",
"return",
"task",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"queue",
"is",
"None",
":",
"se... | Add a new item to the queue. An item is a task and the
arguments needed to call it.
Do not call this directly, use Task.queue/Task.run instead. | [
"Add",
"a",
"new",
"item",
"to",
"the",
"queue",
".",
"An",
"item",
"is",
"a",
"task",
"and",
"the",
"arguments",
"needed",
"to",
"call",
"it",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L57-L67 |
50,225 | pudo-attic/scrapekit | scrapekit/tasks.py | Task.run | def run(self, *args, **kwargs):
""" Queue a first item to execute, then wait for the queue to
be empty before returning. This should be the default way of
starting any scraper.
"""
if self._source is not None:
return self._source.run(*args, **kwargs)
else:
... | python | def run(self, *args, **kwargs):
""" Queue a first item to execute, then wait for the queue to
be empty before returning. This should be the default way of
starting any scraper.
"""
if self._source is not None:
return self._source.run(*args, **kwargs)
else:
... | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_source",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_source",
".",
"run",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
... | Queue a first item to execute, then wait for the queue to
be empty before returning. This should be the default way of
starting any scraper. | [
"Queue",
"a",
"first",
"item",
"to",
"execute",
"then",
"wait",
"for",
"the",
"queue",
"to",
"be",
"empty",
"before",
"returning",
".",
"This",
"should",
"be",
"the",
"default",
"way",
"of",
"starting",
"any",
"scraper",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L152-L161 |
50,226 | pudo-attic/scrapekit | scrapekit/tasks.py | Task.chain | def chain(self, other_task):
""" Add a chain listener to the execution of this task. Whenever
an item has been processed by the task, the registered listener
task will be queued to be executed with the output of this task.
Can also be written as::
pipeline = task1 > task2
... | python | def chain(self, other_task):
""" Add a chain listener to the execution of this task. Whenever
an item has been processed by the task, the registered listener
task will be queued to be executed with the output of this task.
Can also be written as::
pipeline = task1 > task2
... | [
"def",
"chain",
"(",
"self",
",",
"other_task",
")",
":",
"other_task",
".",
"_source",
"=",
"self",
"self",
".",
"_listeners",
".",
"append",
"(",
"ChainListener",
"(",
"other_task",
")",
")",
"return",
"other_task"
] | Add a chain listener to the execution of this task. Whenever
an item has been processed by the task, the registered listener
task will be queued to be executed with the output of this task.
Can also be written as::
pipeline = task1 > task2 | [
"Add",
"a",
"chain",
"listener",
"to",
"the",
"execution",
"of",
"this",
"task",
".",
"Whenever",
"an",
"item",
"has",
"been",
"processed",
"by",
"the",
"task",
"the",
"registered",
"listener",
"task",
"will",
"be",
"queued",
"to",
"be",
"executed",
"with"... | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L163-L174 |
50,227 | pudo-attic/scrapekit | scrapekit/tasks.py | Task.pipe | def pipe(self, other_task):
""" Add a pipe listener to the execution of this task. The
output of this task is required to be an iterable. Each item in
the iterable will be queued as the sole argument to an execution
of the listener task.
Can also be written as::
pip... | python | def pipe(self, other_task):
""" Add a pipe listener to the execution of this task. The
output of this task is required to be an iterable. Each item in
the iterable will be queued as the sole argument to an execution
of the listener task.
Can also be written as::
pip... | [
"def",
"pipe",
"(",
"self",
",",
"other_task",
")",
":",
"other_task",
".",
"_source",
"=",
"self",
"self",
".",
"_listeners",
".",
"append",
"(",
"PipeListener",
"(",
"other_task",
")",
")",
"return",
"other_task"
] | Add a pipe listener to the execution of this task. The
output of this task is required to be an iterable. Each item in
the iterable will be queued as the sole argument to an execution
of the listener task.
Can also be written as::
pipeline = task1 | task2 | [
"Add",
"a",
"pipe",
"listener",
"to",
"the",
"execution",
"of",
"this",
"task",
".",
"The",
"output",
"of",
"this",
"task",
"is",
"required",
"to",
"be",
"an",
"iterable",
".",
"Each",
"item",
"in",
"the",
"iterable",
"will",
"be",
"queued",
"as",
"the... | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L176-L188 |
50,228 | vcatalano/py-authorize | authorize/apis/authorize_api.py | AuthorizeAPI.client_auth | def client_auth(self):
"""Generate an XML element with client auth data populated."""
if not self._client_auth:
self._client_auth = E.Element('merchantAuthentication')
E.SubElement(self._client_auth, 'name').text = self.config.login_id
E.SubElement(self._client_auth, ... | python | def client_auth(self):
"""Generate an XML element with client auth data populated."""
if not self._client_auth:
self._client_auth = E.Element('merchantAuthentication')
E.SubElement(self._client_auth, 'name').text = self.config.login_id
E.SubElement(self._client_auth, ... | [
"def",
"client_auth",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_client_auth",
":",
"self",
".",
"_client_auth",
"=",
"E",
".",
"Element",
"(",
"'merchantAuthentication'",
")",
"E",
".",
"SubElement",
"(",
"self",
".",
"_client_auth",
",",
"'name'"... | Generate an XML element with client auth data populated. | [
"Generate",
"an",
"XML",
"element",
"with",
"client",
"auth",
"data",
"populated",
"."
] | 4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851 | https://github.com/vcatalano/py-authorize/blob/4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851/authorize/apis/authorize_api.py#L38-L44 |
50,229 | vcatalano/py-authorize | authorize/apis/authorize_api.py | AuthorizeAPI._base_request | def _base_request(self, method):
"""Factory method for generating the base XML requests."""
request = E.Element(method)
request.set('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd')
request.append(self.client_auth)
return request | python | def _base_request(self, method):
"""Factory method for generating the base XML requests."""
request = E.Element(method)
request.set('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd')
request.append(self.client_auth)
return request | [
"def",
"_base_request",
"(",
"self",
",",
"method",
")",
":",
"request",
"=",
"E",
".",
"Element",
"(",
"method",
")",
"request",
".",
"set",
"(",
"'xmlns'",
",",
"'AnetApi/xml/v1/schema/AnetApiSchema.xsd'",
")",
"request",
".",
"append",
"(",
"self",
".",
... | Factory method for generating the base XML requests. | [
"Factory",
"method",
"for",
"generating",
"the",
"base",
"XML",
"requests",
"."
] | 4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851 | https://github.com/vcatalano/py-authorize/blob/4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851/authorize/apis/authorize_api.py#L46-L51 |
50,230 | vcatalano/py-authorize | authorize/apis/authorize_api.py | AuthorizeAPI._make_call | def _make_call(self, call):
"""Make a call to the Authorize.net server with the XML."""
try:
request = urllib2.Request(self.config.environment, E.tostring(call))
request.add_header('Content-Type', 'text/xml')
response = urllib2.urlopen(request).read()
resp... | python | def _make_call(self, call):
"""Make a call to the Authorize.net server with the XML."""
try:
request = urllib2.Request(self.config.environment, E.tostring(call))
request.add_header('Content-Type', 'text/xml')
response = urllib2.urlopen(request).read()
resp... | [
"def",
"_make_call",
"(",
"self",
",",
"call",
")",
":",
"try",
":",
"request",
"=",
"urllib2",
".",
"Request",
"(",
"self",
".",
"config",
".",
"environment",
",",
"E",
".",
"tostring",
"(",
"call",
")",
")",
"request",
".",
"add_header",
"(",
"'Con... | Make a call to the Authorize.net server with the XML. | [
"Make",
"a",
"call",
"to",
"the",
"Authorize",
".",
"net",
"server",
"with",
"the",
"XML",
"."
] | 4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851 | https://github.com/vcatalano/py-authorize/blob/4d000b5a1ff2d8e7e955b83dab9d6c6a495c2851/authorize/apis/authorize_api.py#L53-L76 |
50,231 | idlesign/django-sitegate | sitegate/templatetags/sitegate.py | tag_builder | def tag_builder(parser, token, cls, flow_type):
"""Helper function handling flow form tags."""
tokens = token.split_contents()
tokens_num = len(tokens)
if tokens_num == 1 or (tokens_num == 3 and tokens[1] == 'for'):
flow_name = None
if tokens_num == 3:
flow_name = tokens[2]
... | python | def tag_builder(parser, token, cls, flow_type):
"""Helper function handling flow form tags."""
tokens = token.split_contents()
tokens_num = len(tokens)
if tokens_num == 1 or (tokens_num == 3 and tokens[1] == 'for'):
flow_name = None
if tokens_num == 3:
flow_name = tokens[2]
... | [
"def",
"tag_builder",
"(",
"parser",
",",
"token",
",",
"cls",
",",
"flow_type",
")",
":",
"tokens",
"=",
"token",
".",
"split_contents",
"(",
")",
"tokens_num",
"=",
"len",
"(",
"tokens",
")",
"if",
"tokens_num",
"==",
"1",
"or",
"(",
"tokens_num",
"=... | Helper function handling flow form tags. | [
"Helper",
"function",
"handling",
"flow",
"form",
"tags",
"."
] | 0e58de91605071833d75a7c21f2d0de2f2e3c896 | https://github.com/idlesign/django-sitegate/blob/0e58de91605071833d75a7c21f2d0de2f2e3c896/sitegate/templatetags/sitegate.py#L47-L61 |
50,232 | idlesign/django-sitegate | sitegate/decorators.py | sitegate_view | def sitegate_view(*args_dec, **kwargs_dec):
"""Decorator to mark views used both for signup & sign in."""
if len(args_dec): # simple decoration w/o parameters
return signup_view(signin_view(redirect_signedin(*args_dec, **kwargs_dec)))
signin = signin_view(**kwargs_dec)
signup = signup_view(**k... | python | def sitegate_view(*args_dec, **kwargs_dec):
"""Decorator to mark views used both for signup & sign in."""
if len(args_dec): # simple decoration w/o parameters
return signup_view(signin_view(redirect_signedin(*args_dec, **kwargs_dec)))
signin = signin_view(**kwargs_dec)
signup = signup_view(**k... | [
"def",
"sitegate_view",
"(",
"*",
"args_dec",
",",
"*",
"*",
"kwargs_dec",
")",
":",
"if",
"len",
"(",
"args_dec",
")",
":",
"# simple decoration w/o parameters",
"return",
"signup_view",
"(",
"signin_view",
"(",
"redirect_signedin",
"(",
"*",
"args_dec",
",",
... | Decorator to mark views used both for signup & sign in. | [
"Decorator",
"to",
"mark",
"views",
"used",
"both",
"for",
"signup",
"&",
"sign",
"in",
"."
] | 0e58de91605071833d75a7c21f2d0de2f2e3c896 | https://github.com/idlesign/django-sitegate/blob/0e58de91605071833d75a7c21f2d0de2f2e3c896/sitegate/decorators.py#L59-L66 |
50,233 | valohai/ulid2 | ulid2.py | get_ulid_timestamp | def get_ulid_timestamp(ulid):
"""
Get the time from an ULID as an UNIX timestamp.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: UNIX timestamp
:rtype: float
"""
ts_bytes = ulid_to_binary(ulid)[:6]
ts_bytes = b'\0\0' + ts_bytes
assert len(ts_bytes) == 8
re... | python | def get_ulid_timestamp(ulid):
"""
Get the time from an ULID as an UNIX timestamp.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: UNIX timestamp
:rtype: float
"""
ts_bytes = ulid_to_binary(ulid)[:6]
ts_bytes = b'\0\0' + ts_bytes
assert len(ts_bytes) == 8
re... | [
"def",
"get_ulid_timestamp",
"(",
"ulid",
")",
":",
"ts_bytes",
"=",
"ulid_to_binary",
"(",
"ulid",
")",
"[",
":",
"6",
"]",
"ts_bytes",
"=",
"b'\\0\\0'",
"+",
"ts_bytes",
"assert",
"len",
"(",
"ts_bytes",
")",
"==",
"8",
"return",
"(",
"struct",
".",
... | Get the time from an ULID as an UNIX timestamp.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: UNIX timestamp
:rtype: float | [
"Get",
"the",
"time",
"from",
"an",
"ULID",
"as",
"an",
"UNIX",
"timestamp",
"."
] | cebc523ac70c5d5ca055c0c3de6318de617b07d7 | https://github.com/valohai/ulid2/blob/cebc523ac70c5d5ca055c0c3de6318de617b07d7/ulid2.py#L147-L158 |
50,234 | valohai/ulid2 | ulid2.py | generate_binary_ulid | def generate_binary_ulid(timestamp=None, monotonic=False):
"""
Generate the bytes for an ULID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ensure ULIDs are... | python | def generate_binary_ulid(timestamp=None, monotonic=False):
"""
Generate the bytes for an ULID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ensure ULIDs are... | [
"def",
"generate_binary_ulid",
"(",
"timestamp",
"=",
"None",
",",
"monotonic",
"=",
"False",
")",
":",
"global",
"_last_entropy",
",",
"_last_timestamp",
"if",
"timestamp",
"is",
"None",
":",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"elif",
"isinsta... | Generate the bytes for an ULID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ensure ULIDs are monotonically increasing.
Monotonic behavior is ... | [
"Generate",
"the",
"bytes",
"for",
"an",
"ULID",
"."
] | cebc523ac70c5d5ca055c0c3de6318de617b07d7 | https://github.com/valohai/ulid2/blob/cebc523ac70c5d5ca055c0c3de6318de617b07d7/ulid2.py#L176-L205 |
50,235 | valohai/ulid2 | ulid2.py | generate_ulid_as_uuid | def generate_ulid_as_uuid(timestamp=None, monotonic=False):
"""
Generate an ULID, but expressed as an UUID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ens... | python | def generate_ulid_as_uuid(timestamp=None, monotonic=False):
"""
Generate an ULID, but expressed as an UUID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ens... | [
"def",
"generate_ulid_as_uuid",
"(",
"timestamp",
"=",
"None",
",",
"monotonic",
"=",
"False",
")",
":",
"return",
"uuid",
".",
"UUID",
"(",
"bytes",
"=",
"generate_binary_ulid",
"(",
"timestamp",
",",
"monotonic",
"=",
"monotonic",
")",
")"
] | Generate an ULID, but expressed as an UUID.
:param timestamp: An optional timestamp override.
If `None`, the current time is used.
:type timestamp: int|float|datetime.datetime|None
:param monotonic: Attempt to ensure ULIDs are monotonically increasing.
Monotonic ... | [
"Generate",
"an",
"ULID",
"but",
"expressed",
"as",
"an",
"UUID",
"."
] | cebc523ac70c5d5ca055c0c3de6318de617b07d7 | https://github.com/valohai/ulid2/blob/cebc523ac70c5d5ca055c0c3de6318de617b07d7/ulid2.py#L208-L221 |
50,236 | valohai/ulid2 | ulid2.py | ulid_to_binary | def ulid_to_binary(ulid):
"""
Convert an ULID to its binary representation.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: Bytestring of length 16
:rtype: bytes
"""
if isinstance(ulid, uuid.UUID):
return ulid.bytes
if isinstance(ulid, (text_type, bytes)) a... | python | def ulid_to_binary(ulid):
"""
Convert an ULID to its binary representation.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: Bytestring of length 16
:rtype: bytes
"""
if isinstance(ulid, uuid.UUID):
return ulid.bytes
if isinstance(ulid, (text_type, bytes)) a... | [
"def",
"ulid_to_binary",
"(",
"ulid",
")",
":",
"if",
"isinstance",
"(",
"ulid",
",",
"uuid",
".",
"UUID",
")",
":",
"return",
"ulid",
".",
"bytes",
"if",
"isinstance",
"(",
"ulid",
",",
"(",
"text_type",
",",
"bytes",
")",
")",
"and",
"len",
"(",
... | Convert an ULID to its binary representation.
:param ulid: An ULID (either as UUID, base32 ULID or binary)
:return: Bytestring of length 16
:rtype: bytes | [
"Convert",
"an",
"ULID",
"to",
"its",
"binary",
"representation",
"."
] | cebc523ac70c5d5ca055c0c3de6318de617b07d7 | https://github.com/valohai/ulid2/blob/cebc523ac70c5d5ca055c0c3de6318de617b07d7/ulid2.py#L262-L276 |
50,237 | pudo-attic/scrapekit | scrapekit/http.py | make_session | def make_session(scraper):
""" Instantiate a session with the desired configuration parameters,
including the cache policy. """
cache_path = os.path.join(scraper.config.data_path, 'cache')
cache_policy = scraper.config.cache_policy
cache_policy = cache_policy.lower().strip()
session = ScraperSes... | python | def make_session(scraper):
""" Instantiate a session with the desired configuration parameters,
including the cache policy. """
cache_path = os.path.join(scraper.config.data_path, 'cache')
cache_policy = scraper.config.cache_policy
cache_policy = cache_policy.lower().strip()
session = ScraperSes... | [
"def",
"make_session",
"(",
"scraper",
")",
":",
"cache_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scraper",
".",
"config",
".",
"data_path",
",",
"'cache'",
")",
"cache_policy",
"=",
"scraper",
".",
"config",
".",
"cache_policy",
"cache_policy",
"=... | Instantiate a session with the desired configuration parameters,
including the cache policy. | [
"Instantiate",
"a",
"session",
"with",
"the",
"desired",
"configuration",
"parameters",
"including",
"the",
"cache",
"policy",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/http.py#L95-L112 |
50,238 | pudo-attic/scrapekit | scrapekit/http.py | ScraperResponse.json | def json(self, **kwargs):
""" Create JSON object out of the response. """
try:
return super(ScraperResponse, self).json(**kwargs)
except ValueError as ve:
raise ParseException(ve) | python | def json(self, **kwargs):
""" Create JSON object out of the response. """
try:
return super(ScraperResponse, self).json(**kwargs)
except ValueError as ve:
raise ParseException(ve) | [
"def",
"json",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"super",
"(",
"ScraperResponse",
",",
"self",
")",
".",
"json",
"(",
"*",
"*",
"kwargs",
")",
"except",
"ValueError",
"as",
"ve",
":",
"raise",
"ParseException",
"("... | Create JSON object out of the response. | [
"Create",
"JSON",
"object",
"out",
"of",
"the",
"response",
"."
] | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/http.py#L40-L45 |
50,239 | pudo-attic/scrapekit | scrapekit/util.py | collapse_whitespace | def collapse_whitespace(text):
""" Collapse all consecutive whitespace, newlines and tabs
in a string into single whitespaces, and strip the outer
whitespace. This will also accept an ``lxml`` element and
extract all text. """
if text is None:
return None
if hasattr(text, 'xpath'):
... | python | def collapse_whitespace(text):
""" Collapse all consecutive whitespace, newlines and tabs
in a string into single whitespaces, and strip the outer
whitespace. This will also accept an ``lxml`` element and
extract all text. """
if text is None:
return None
if hasattr(text, 'xpath'):
... | [
"def",
"collapse_whitespace",
"(",
"text",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"if",
"hasattr",
"(",
"text",
",",
"'xpath'",
")",
":",
"text",
"=",
"text",
".",
"xpath",
"(",
"'string()'",
")",
"text",
"=",
"re",
".",
"sub",
... | Collapse all consecutive whitespace, newlines and tabs
in a string into single whitespaces, and strip the outer
whitespace. This will also accept an ``lxml`` element and
extract all text. | [
"Collapse",
"all",
"consecutive",
"whitespace",
"newlines",
"and",
"tabs",
"in",
"a",
"string",
"into",
"single",
"whitespaces",
"and",
"strip",
"the",
"outer",
"whitespace",
".",
"This",
"will",
"also",
"accept",
"an",
"lxml",
"element",
"and",
"extract",
"al... | cfd258120922fcd571430cdf00ba50f3cf18dc15 | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/util.py#L4-L14 |
50,240 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser.setup_regex | def setup_regex(self):
"""Sets up the patterns and compiled regex objects for parsing types."""
#Regex for matching the entire body of the type and getting top-level modifiers.
self._RX_TYPE = r"\n\s*type(?P<modifiers>,\s+(public|private))?(\s*::)?\s+(?P<name>[A-Za-z0-9_]+)" + \
... | python | def setup_regex(self):
"""Sets up the patterns and compiled regex objects for parsing types."""
#Regex for matching the entire body of the type and getting top-level modifiers.
self._RX_TYPE = r"\n\s*type(?P<modifiers>,\s+(public|private))?(\s*::)?\s+(?P<name>[A-Za-z0-9_]+)" + \
... | [
"def",
"setup_regex",
"(",
"self",
")",
":",
"#Regex for matching the entire body of the type and getting top-level modifiers.",
"self",
".",
"_RX_TYPE",
"=",
"r\"\\n\\s*type(?P<modifiers>,\\s+(public|private))?(\\s*::)?\\s+(?P<name>[A-Za-z0-9_]+)\"",
"+",
"r\"(?P<contents>.+?)end\\s*type(... | Sets up the patterns and compiled regex objects for parsing types. | [
"Sets",
"up",
"the",
"patterns",
"and",
"compiled",
"regex",
"objects",
"for",
"parsing",
"types",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L11-L30 |
50,241 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser.parse_line | def parse_line(self, statement, element, mode):
"""As part of real-time update, parses the statement and adjusts the attributes
of the specified CustomType instance to reflect the changes.
:arg statement: the lines of code that was added/removed/changed on the
element after it had al... | python | def parse_line(self, statement, element, mode):
"""As part of real-time update, parses the statement and adjusts the attributes
of the specified CustomType instance to reflect the changes.
:arg statement: the lines of code that was added/removed/changed on the
element after it had al... | [
"def",
"parse_line",
"(",
"self",
",",
"statement",
",",
"element",
",",
"mode",
")",
":",
"if",
"element",
".",
"incomplete",
":",
"#We need to check for the end_token so we can close up the incomplete",
"#status for the instance.",
"if",
"element",
".",
"end_token",
"... | As part of real-time update, parses the statement and adjusts the attributes
of the specified CustomType instance to reflect the changes.
:arg statement: the lines of code that was added/removed/changed on the
element after it had alread been parsed. The lines together form a single
... | [
"As",
"part",
"of",
"real",
"-",
"time",
"update",
"parses",
"the",
"statement",
"and",
"adjusts",
"the",
"attributes",
"of",
"the",
"specified",
"CustomType",
"instance",
"to",
"reflect",
"the",
"changes",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L63-L84 |
50,242 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser._rt_members_add | def _rt_members_add(self, element, statement):
"""Finds all the member declarations in 'statement' and adds the
corresponding instances to element.members."""
members = self.vparser.parse(statement, None)
for member in members:
single = members[member]
single.pare... | python | def _rt_members_add(self, element, statement):
"""Finds all the member declarations in 'statement' and adds the
corresponding instances to element.members."""
members = self.vparser.parse(statement, None)
for member in members:
single = members[member]
single.pare... | [
"def",
"_rt_members_add",
"(",
"self",
",",
"element",
",",
"statement",
")",
":",
"members",
"=",
"self",
".",
"vparser",
".",
"parse",
"(",
"statement",
",",
"None",
")",
"for",
"member",
"in",
"members",
":",
"single",
"=",
"members",
"[",
"member",
... | Finds all the member declarations in 'statement' and adds the
corresponding instances to element.members. | [
"Finds",
"all",
"the",
"member",
"declarations",
"in",
"statement",
"and",
"adds",
"the",
"corresponding",
"instances",
"to",
"element",
".",
"members",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L93-L100 |
50,243 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser._rt_members_delete | def _rt_members_delete(self, element, statement):
"""Finds all the member declarations in 'statement' and removes the
corresponding instances from element.members."""
removals = self.vparser.parse(statement, None)
for member in removals:
if member in element.members:
... | python | def _rt_members_delete(self, element, statement):
"""Finds all the member declarations in 'statement' and removes the
corresponding instances from element.members."""
removals = self.vparser.parse(statement, None)
for member in removals:
if member in element.members:
... | [
"def",
"_rt_members_delete",
"(",
"self",
",",
"element",
",",
"statement",
")",
":",
"removals",
"=",
"self",
".",
"vparser",
".",
"parse",
"(",
"statement",
",",
"None",
")",
"for",
"member",
"in",
"removals",
":",
"if",
"member",
"in",
"element",
".",... | Finds all the member declarations in 'statement' and removes the
corresponding instances from element.members. | [
"Finds",
"all",
"the",
"member",
"declarations",
"in",
"statement",
"and",
"removes",
"the",
"corresponding",
"instances",
"from",
"element",
".",
"members",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L102-L108 |
50,244 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser.parse | def parse(self, module):
"""Extracts all the types from the specified module body."""
matches = self.RE_TYPE.finditer(module.contents)
result = {}
for match in matches:
name = match.group("name")
modifiers = match.group("modifiers")
if modifiers is no... | python | def parse(self, module):
"""Extracts all the types from the specified module body."""
matches = self.RE_TYPE.finditer(module.contents)
result = {}
for match in matches:
name = match.group("name")
modifiers = match.group("modifiers")
if modifiers is no... | [
"def",
"parse",
"(",
"self",
",",
"module",
")",
":",
"matches",
"=",
"self",
".",
"RE_TYPE",
".",
"finditer",
"(",
"module",
".",
"contents",
")",
"result",
"=",
"{",
"}",
"for",
"match",
"in",
"matches",
":",
"name",
"=",
"match",
".",
"group",
"... | Extracts all the types from the specified module body. | [
"Extracts",
"all",
"the",
"types",
"from",
"the",
"specified",
"module",
"body",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L110-L131 |
50,245 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser._process_type | def _process_type(self, name, modifiers, contents, module, match):
"""Processes a regex match of a type's contents."""
#First, we need to see if the types children are private.
if self.RE_PRIV.search(contents):
modifiers.append("private contents")
#Next, we need to parse out... | python | def _process_type(self, name, modifiers, contents, module, match):
"""Processes a regex match of a type's contents."""
#First, we need to see if the types children are private.
if self.RE_PRIV.search(contents):
modifiers.append("private contents")
#Next, we need to parse out... | [
"def",
"_process_type",
"(",
"self",
",",
"name",
",",
"modifiers",
",",
"contents",
",",
"module",
",",
"match",
")",
":",
"#First, we need to see if the types children are private.",
"if",
"self",
".",
"RE_PRIV",
".",
"search",
"(",
"contents",
")",
":",
"modi... | Processes a regex match of a type's contents. | [
"Processes",
"a",
"regex",
"match",
"of",
"a",
"type",
"s",
"contents",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L133-L163 |
50,246 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser.update_docs | def update_docs(self, t, module):
"""Updates the documentation for the specified type using the module predocs."""
#We need to look in the parent module docstrings for this types decorating tags.
key = "{}.{}".format(module.name, t.name)
if key in module.predocs:
t.do... | python | def update_docs(self, t, module):
"""Updates the documentation for the specified type using the module predocs."""
#We need to look in the parent module docstrings for this types decorating tags.
key = "{}.{}".format(module.name, t.name)
if key in module.predocs:
t.do... | [
"def",
"update_docs",
"(",
"self",
",",
"t",
",",
"module",
")",
":",
"#We need to look in the parent module docstrings for this types decorating tags.",
"key",
"=",
"\"{}.{}\"",
".",
"format",
"(",
"module",
".",
"name",
",",
"t",
".",
"name",
")",
"if",
"key",
... | Updates the documentation for the specified type using the module predocs. | [
"Updates",
"the",
"documentation",
"for",
"the",
"specified",
"type",
"using",
"the",
"module",
"predocs",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L165-L171 |
50,247 | rosenbrockc/fortpy | fortpy/parsers/types.py | TypeParser._process_execs | def _process_execs(self, contents, modulename, atype, mode="insert"):
"""Extracts all the executable methods that belong to the type."""
#We only want to look at text after the contains statement
match = self.RE_CONTAINS.search(contents)
#It is possible for the type to not have any exec... | python | def _process_execs(self, contents, modulename, atype, mode="insert"):
"""Extracts all the executable methods that belong to the type."""
#We only want to look at text after the contains statement
match = self.RE_CONTAINS.search(contents)
#It is possible for the type to not have any exec... | [
"def",
"_process_execs",
"(",
"self",
",",
"contents",
",",
"modulename",
",",
"atype",
",",
"mode",
"=",
"\"insert\"",
")",
":",
"#We only want to look at text after the contains statement",
"match",
"=",
"self",
".",
"RE_CONTAINS",
".",
"search",
"(",
"contents",
... | Extracts all the executable methods that belong to the type. | [
"Extracts",
"all",
"the",
"executable",
"methods",
"that",
"belong",
"to",
"the",
"type",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/types.py#L173-L181 |
50,248 | shaldengeki/python-mal | myanimelist/session.py | Session.login | def login(self):
"""Logs into MAL and sets cookies appropriately.
:rtype: :class:`.Session`
:return: The current session.
"""
# POSTS a login to mal.
mal_headers = {
'Host': 'myanimelist.net',
}
mal_payload = {
'username': self.username,
'password': self.password,
... | python | def login(self):
"""Logs into MAL and sets cookies appropriately.
:rtype: :class:`.Session`
:return: The current session.
"""
# POSTS a login to mal.
mal_headers = {
'Host': 'myanimelist.net',
}
mal_payload = {
'username': self.username,
'password': self.password,
... | [
"def",
"login",
"(",
"self",
")",
":",
"# POSTS a login to mal.",
"mal_headers",
"=",
"{",
"'Host'",
":",
"'myanimelist.net'",
",",
"}",
"mal_payload",
"=",
"{",
"'username'",
":",
"self",
".",
"username",
",",
"'password'",
":",
"self",
".",
"password",
","... | Logs into MAL and sets cookies appropriately.
:rtype: :class:`.Session`
:return: The current session. | [
"Logs",
"into",
"MAL",
"and",
"sets",
"cookies",
"appropriately",
"."
] | 2c3356411a74d88ba13f6b970388040d696f8392 | https://github.com/shaldengeki/python-mal/blob/2c3356411a74d88ba13f6b970388040d696f8392/myanimelist/session.py#L108-L127 |
50,249 | rosenbrockc/fortpy | fortpy/debug.py | increase_indent | def increase_indent(func):
"""Decorator for makin """
def wrapper(*args, **kwargs):
global _debug_indent
_debug_indent += 1
result = func(*args, **kwargs)
_debug_indent -= 1
return result
return wrapper | python | def increase_indent(func):
"""Decorator for makin """
def wrapper(*args, **kwargs):
global _debug_indent
_debug_indent += 1
result = func(*args, **kwargs)
_debug_indent -= 1
return result
return wrapper | [
"def",
"increase_indent",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"_debug_indent",
"_debug_indent",
"+=",
"1",
"result",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"_de... | Decorator for makin | [
"Decorator",
"for",
"makin"
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/debug.py#L43-L51 |
50,250 | rosenbrockc/fortpy | fortpy/debug.py | dbg | def dbg(message, *args):
""" Looks at the stack, to see if a debug message should be printed. """
if debug_function and enable_notice:
frm = inspect.stack()[1]
mod = inspect.getmodule(frm[0])
if not (mod.__name__ in ignored_modules):
i = ' ' * _debug_indent
debug_... | python | def dbg(message, *args):
""" Looks at the stack, to see if a debug message should be printed. """
if debug_function and enable_notice:
frm = inspect.stack()[1]
mod = inspect.getmodule(frm[0])
if not (mod.__name__ in ignored_modules):
i = ' ' * _debug_indent
debug_... | [
"def",
"dbg",
"(",
"message",
",",
"*",
"args",
")",
":",
"if",
"debug_function",
"and",
"enable_notice",
":",
"frm",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"1",
"]",
"mod",
"=",
"inspect",
".",
"getmodule",
"(",
"frm",
"[",
"0",
"]",
")",
... | Looks at the stack, to see if a debug message should be printed. | [
"Looks",
"at",
"the",
"stack",
"to",
"see",
"if",
"a",
"debug",
"message",
"should",
"be",
"printed",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/debug.py#L53-L60 |
50,251 | rosenbrockc/fortpy | fortpy/debug.py | print_to_stdout | def print_to_stdout(level, str_out):
""" The default debug function """
if level == NOTICE:
col = Fore.GREEN
elif level == WARNING:
col = Fore.RED
else:
col = Fore.YELLOW
if not is_py3:
str_out = str_out.encode(encoding, 'replace')
print((col + str_out + Fore.RESE... | python | def print_to_stdout(level, str_out):
""" The default debug function """
if level == NOTICE:
col = Fore.GREEN
elif level == WARNING:
col = Fore.RED
else:
col = Fore.YELLOW
if not is_py3:
str_out = str_out.encode(encoding, 'replace')
print((col + str_out + Fore.RESE... | [
"def",
"print_to_stdout",
"(",
"level",
",",
"str_out",
")",
":",
"if",
"level",
"==",
"NOTICE",
":",
"col",
"=",
"Fore",
".",
"GREEN",
"elif",
"level",
"==",
"WARNING",
":",
"col",
"=",
"Fore",
".",
"RED",
"else",
":",
"col",
"=",
"Fore",
".",
"YE... | The default debug function | [
"The",
"default",
"debug",
"function"
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/debug.py#L73-L83 |
50,252 | rosenbrockc/fortpy | fortpy/parsers/variable.py | count_dimensions | def count_dimensions(entry):
"""Counts the number of dimensions from a nested list of dimension assignments
that may include function calls.
"""
result = 0
for e in entry:
if isinstance(e, str):
sliced = e.strip(",").split(",")
result += 0 if len(sliced) == 1 and slic... | python | def count_dimensions(entry):
"""Counts the number of dimensions from a nested list of dimension assignments
that may include function calls.
"""
result = 0
for e in entry:
if isinstance(e, str):
sliced = e.strip(",").split(",")
result += 0 if len(sliced) == 1 and slic... | [
"def",
"count_dimensions",
"(",
"entry",
")",
":",
"result",
"=",
"0",
"for",
"e",
"in",
"entry",
":",
"if",
"isinstance",
"(",
"e",
",",
"str",
")",
":",
"sliced",
"=",
"e",
".",
"strip",
"(",
"\",\"",
")",
".",
"split",
"(",
"\",\"",
")",
"resu... | Counts the number of dimensions from a nested list of dimension assignments
that may include function calls. | [
"Counts",
"the",
"number",
"of",
"dimensions",
"from",
"a",
"nested",
"list",
"of",
"dimension",
"assignments",
"that",
"may",
"include",
"function",
"calls",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L223-L232 |
50,253 | rosenbrockc/fortpy | fortpy/parsers/variable.py | VariableParser.parse | def parse(self, string, parent):
"""Parses all the value code elements from the specified string."""
result = {}
for member in self.RE_MEMBERS.finditer(string):
mems = self._process_member(member, parent, string)
#The regex match could contain multiple members that were d... | python | def parse(self, string, parent):
"""Parses all the value code elements from the specified string."""
result = {}
for member in self.RE_MEMBERS.finditer(string):
mems = self._process_member(member, parent, string)
#The regex match could contain multiple members that were d... | [
"def",
"parse",
"(",
"self",
",",
"string",
",",
"parent",
")",
":",
"result",
"=",
"{",
"}",
"for",
"member",
"in",
"self",
".",
"RE_MEMBERS",
".",
"finditer",
"(",
"string",
")",
":",
"mems",
"=",
"self",
".",
"_process_member",
"(",
"member",
",",... | Parses all the value code elements from the specified string. | [
"Parses",
"all",
"the",
"value",
"code",
"elements",
"from",
"the",
"specified",
"string",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L20-L30 |
50,254 | rosenbrockc/fortpy | fortpy/parsers/variable.py | VariableParser._process_member | def _process_member(self, member, parent, string):
"""Extracts all the member info from the regex match; returns a ValueElements."""
#The modifiers regex is very greedy so we have some cleaning up to do
#to extract the mods.
modifiers = member.group("modifiers")
dimension = None
... | python | def _process_member(self, member, parent, string):
"""Extracts all the member info from the regex match; returns a ValueElements."""
#The modifiers regex is very greedy so we have some cleaning up to do
#to extract the mods.
modifiers = member.group("modifiers")
dimension = None
... | [
"def",
"_process_member",
"(",
"self",
",",
"member",
",",
"parent",
",",
"string",
")",
":",
"#The modifiers regex is very greedy so we have some cleaning up to do",
"#to extract the mods.",
"modifiers",
"=",
"member",
".",
"group",
"(",
"\"modifiers\"",
")",
"dimension"... | Extracts all the member info from the regex match; returns a ValueElements. | [
"Extracts",
"all",
"the",
"member",
"info",
"from",
"the",
"regex",
"match",
";",
"returns",
"a",
"ValueElements",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L32-L78 |
50,255 | rosenbrockc/fortpy | fortpy/parsers/variable.py | VariableParser._collapse_default | def _collapse_default(self, entry):
"""Collapses the list structure in entry to a single string representing the default
value assigned to a variable or its dimensions.
"""
if isinstance(entry, tuple) or isinstance(entry, list):
sets = []
i = 0
while i... | python | def _collapse_default(self, entry):
"""Collapses the list structure in entry to a single string representing the default
value assigned to a variable or its dimensions.
"""
if isinstance(entry, tuple) or isinstance(entry, list):
sets = []
i = 0
while i... | [
"def",
"_collapse_default",
"(",
"self",
",",
"entry",
")",
":",
"if",
"isinstance",
"(",
"entry",
",",
"tuple",
")",
"or",
"isinstance",
"(",
"entry",
",",
"list",
")",
":",
"sets",
"=",
"[",
"]",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"e... | Collapses the list structure in entry to a single string representing the default
value assigned to a variable or its dimensions. | [
"Collapses",
"the",
"list",
"structure",
"in",
"entry",
"to",
"a",
"single",
"string",
"representing",
"the",
"default",
"value",
"assigned",
"to",
"a",
"variable",
"or",
"its",
"dimensions",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L125-L163 |
50,256 | rosenbrockc/fortpy | fortpy/parsers/variable.py | VariableParser._clean_multiple_def | def _clean_multiple_def(self, ready):
"""Cleans the list of variable definitions extracted from the definition text to
get hold of the dimensions and default values.
"""
result = []
for entry in ready:
if isinstance(entry, list):
#This variable declara... | python | def _clean_multiple_def(self, ready):
"""Cleans the list of variable definitions extracted from the definition text to
get hold of the dimensions and default values.
"""
result = []
for entry in ready:
if isinstance(entry, list):
#This variable declara... | [
"def",
"_clean_multiple_def",
"(",
"self",
",",
"ready",
")",
":",
"result",
"=",
"[",
"]",
"for",
"entry",
"in",
"ready",
":",
"if",
"isinstance",
"(",
"entry",
",",
"list",
")",
":",
"#This variable declaration has a default value specified, which is in the",
"#... | Cleans the list of variable definitions extracted from the definition text to
get hold of the dimensions and default values. | [
"Cleans",
"the",
"list",
"of",
"variable",
"definitions",
"extracted",
"from",
"the",
"definition",
"text",
"to",
"get",
"hold",
"of",
"the",
"dimensions",
"and",
"default",
"values",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/variable.py#L165-L194 |
50,257 | rexos/wordlist | wordlist/_util.py | char_range | def char_range(starting_char, ending_char):
"""
Create a range generator for chars
"""
assert isinstance(starting_char, str), 'char_range: Wrong argument/s type'
assert isinstance(ending_char, str), 'char_range: Wrong argument/s type'
for char in range(ord(starting_char), ord(ending_char) + 1):... | python | def char_range(starting_char, ending_char):
"""
Create a range generator for chars
"""
assert isinstance(starting_char, str), 'char_range: Wrong argument/s type'
assert isinstance(ending_char, str), 'char_range: Wrong argument/s type'
for char in range(ord(starting_char), ord(ending_char) + 1):... | [
"def",
"char_range",
"(",
"starting_char",
",",
"ending_char",
")",
":",
"assert",
"isinstance",
"(",
"starting_char",
",",
"str",
")",
",",
"'char_range: Wrong argument/s type'",
"assert",
"isinstance",
"(",
"ending_char",
",",
"str",
")",
",",
"'char_range: Wrong ... | Create a range generator for chars | [
"Create",
"a",
"range",
"generator",
"for",
"chars"
] | 263504e31acebb5765517cf866ea7aa5bb66517a | https://github.com/rexos/wordlist/blob/263504e31acebb5765517cf866ea7aa5bb66517a/wordlist/_util.py#L10-L18 |
50,258 | rexos/wordlist | wordlist/_util.py | parse_charset | def parse_charset(charset):
"""
Finds out whether there are intervals to expand and
creates the charset
"""
import re
regex = r'(\w-\w)'
pat = re.compile(regex)
found = pat.findall(charset)
result = ''
if found:
for element in found:
for char in char_range(ele... | python | def parse_charset(charset):
"""
Finds out whether there are intervals to expand and
creates the charset
"""
import re
regex = r'(\w-\w)'
pat = re.compile(regex)
found = pat.findall(charset)
result = ''
if found:
for element in found:
for char in char_range(ele... | [
"def",
"parse_charset",
"(",
"charset",
")",
":",
"import",
"re",
"regex",
"=",
"r'(\\w-\\w)'",
"pat",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"found",
"=",
"pat",
".",
"findall",
"(",
"charset",
")",
"result",
"=",
"''",
"if",
"found",
":",
"f... | Finds out whether there are intervals to expand and
creates the charset | [
"Finds",
"out",
"whether",
"there",
"are",
"intervals",
"to",
"expand",
"and",
"creates",
"the",
"charset"
] | 263504e31acebb5765517cf866ea7aa5bb66517a | https://github.com/rexos/wordlist/blob/263504e31acebb5765517cf866ea7aa5bb66517a/wordlist/_util.py#L21-L36 |
50,259 | ronniedada/tabula | tabula/table.py | Table.size | def size(self):
"""Return the viewable size of the Table as @tuple (x,y)"""
width = max(
map(lambda x: x.size()[0], self.sections.itervalues()))
height = sum(
map(lambda x: x.size()[1], self.sections.itervalues()))
return width, height | python | def size(self):
"""Return the viewable size of the Table as @tuple (x,y)"""
width = max(
map(lambda x: x.size()[0], self.sections.itervalues()))
height = sum(
map(lambda x: x.size()[1], self.sections.itervalues()))
return width, height | [
"def",
"size",
"(",
"self",
")",
":",
"width",
"=",
"max",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"size",
"(",
")",
"[",
"0",
"]",
",",
"self",
".",
"sections",
".",
"itervalues",
"(",
")",
")",
")",
"height",
"=",
"sum",
"(",
"map",
... | Return the viewable size of the Table as @tuple (x,y) | [
"Return",
"the",
"viewable",
"size",
"of",
"the",
"Table",
"as"
] | ba18bb2f7db75972256b950711415031dc5421c7 | https://github.com/ronniedada/tabula/blob/ba18bb2f7db75972256b950711415031dc5421c7/tabula/table.py#L39-L47 |
50,260 | ronniedada/tabula | tabula/table.py | Table.get_ftr | def get_ftr(self):
"""
Process footer and return the processed string
"""
if not self.ftr:
return self.ftr
width = self.size()[0]
return re.sub(
"%time", "%s\n" % time.strftime("%H:%M:%S"), self.ftr).rjust(width) | python | def get_ftr(self):
"""
Process footer and return the processed string
"""
if not self.ftr:
return self.ftr
width = self.size()[0]
return re.sub(
"%time", "%s\n" % time.strftime("%H:%M:%S"), self.ftr).rjust(width) | [
"def",
"get_ftr",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"ftr",
":",
"return",
"self",
".",
"ftr",
"width",
"=",
"self",
".",
"size",
"(",
")",
"[",
"0",
"]",
"return",
"re",
".",
"sub",
"(",
"\"%time\"",
",",
"\"%s\\n\"",
"%",
"time",
... | Process footer and return the processed string | [
"Process",
"footer",
"and",
"return",
"the",
"processed",
"string"
] | ba18bb2f7db75972256b950711415031dc5421c7 | https://github.com/ronniedada/tabula/blob/ba18bb2f7db75972256b950711415031dc5421c7/tabula/table.py#L58-L67 |
50,261 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_help | def do_help(self, arg):
"""Sets up the header for the help command that explains the background on how to use
the script generally. Help for each command then stands alone in the context of this
documentation. Although we could have documented this on the wiki, it is better served
when s... | python | def do_help(self, arg):
"""Sets up the header for the help command that explains the background on how to use
the script generally. Help for each command then stands alone in the context of this
documentation. Although we could have documented this on the wiki, it is better served
when s... | [
"def",
"do_help",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
"==",
"\"\"",
":",
"lines",
"=",
"[",
"(",
"\"The fortpy unit testing analysis shell makes it easy to analyze the results \"",
"\"of multiple test cases, make plots of trends and tabulate values for use in \"",
"... | Sets up the header for the help command that explains the background on how to use
the script generally. Help for each command then stands alone in the context of this
documentation. Although we could have documented this on the wiki, it is better served
when shipped with the shell. | [
"Sets",
"up",
"the",
"header",
"for",
"the",
"help",
"command",
"that",
"explains",
"the",
"background",
"on",
"how",
"to",
"use",
"the",
"script",
"generally",
".",
"Help",
"for",
"each",
"command",
"then",
"stands",
"alone",
"in",
"the",
"context",
"of",... | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L108-L137 |
50,262 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._fixed_width_info | def _fixed_width_info(self, lines):
"""Prints the specified string as information with fixed width of 80 chars."""
for string in lines:
for line in [string[i:i+80] for i in range(0, len(string), 80)]:
msg.info(line)
msg.blank() | python | def _fixed_width_info(self, lines):
"""Prints the specified string as information with fixed width of 80 chars."""
for string in lines:
for line in [string[i:i+80] for i in range(0, len(string), 80)]:
msg.info(line)
msg.blank() | [
"def",
"_fixed_width_info",
"(",
"self",
",",
"lines",
")",
":",
"for",
"string",
"in",
"lines",
":",
"for",
"line",
"in",
"[",
"string",
"[",
"i",
":",
"i",
"+",
"80",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"string",
")",
"... | Prints the specified string as information with fixed width of 80 chars. | [
"Prints",
"the",
"specified",
"string",
"as",
"information",
"with",
"fixed",
"width",
"of",
"80",
"chars",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L139-L144 |
50,263 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._redirect_output | def _redirect_output(self, value, filename=None, append=None, printfun=None):
"""Outputs the specified value to the console or a file depending on the redirect
behavior specified.
:arg value: the string text to print or save.
:arg filename: the name of the file to save the text to.
... | python | def _redirect_output(self, value, filename=None, append=None, printfun=None):
"""Outputs the specified value to the console or a file depending on the redirect
behavior specified.
:arg value: the string text to print or save.
:arg filename: the name of the file to save the text to.
... | [
"def",
"_redirect_output",
"(",
"self",
",",
"value",
",",
"filename",
"=",
"None",
",",
"append",
"=",
"None",
",",
"printfun",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"printfun",
"is",
"None",
":",
"print",
"(",
"value",
"... | Outputs the specified value to the console or a file depending on the redirect
behavior specified.
:arg value: the string text to print or save.
:arg filename: the name of the file to save the text to.
:arg append: when true, the text is appended to the file if it exists. | [
"Outputs",
"the",
"specified",
"value",
"to",
"the",
"console",
"or",
"a",
"file",
"depending",
"on",
"the",
"redirect",
"behavior",
"specified",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L204-L226 |
50,264 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._complete_cases | def _complete_cases(self, text, line, istart, iend):
"""Returns the completion list of possible test cases for the active unit test."""
if text == "":
return list(self.live.keys())
else:
return [c for c in self.live if c.startswith(text)] | python | def _complete_cases(self, text, line, istart, iend):
"""Returns the completion list of possible test cases for the active unit test."""
if text == "":
return list(self.live.keys())
else:
return [c for c in self.live if c.startswith(text)] | [
"def",
"_complete_cases",
"(",
"self",
",",
"text",
",",
"line",
",",
"istart",
",",
"iend",
")",
":",
"if",
"text",
"==",
"\"\"",
":",
"return",
"list",
"(",
"self",
".",
"live",
".",
"keys",
"(",
")",
")",
"else",
":",
"return",
"[",
"c",
"for"... | Returns the completion list of possible test cases for the active unit test. | [
"Returns",
"the",
"completion",
"list",
"of",
"possible",
"test",
"cases",
"for",
"the",
"active",
"unit",
"test",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L246-L251 |
50,265 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._set_arg_generic | def _set_arg_generic(self, argid, arg, cast=str):
"""Sets the value of the argument with the specified id using the argument passed
in from the shell session.
"""
usable, filename, append = self._redirect_split(arg)
if usable != "":
self.curargs[argid] = cast(usable)
... | python | def _set_arg_generic(self, argid, arg, cast=str):
"""Sets the value of the argument with the specified id using the argument passed
in from the shell session.
"""
usable, filename, append = self._redirect_split(arg)
if usable != "":
self.curargs[argid] = cast(usable)
... | [
"def",
"_set_arg_generic",
"(",
"self",
",",
"argid",
",",
"arg",
",",
"cast",
"=",
"str",
")",
":",
"usable",
",",
"filename",
",",
"append",
"=",
"self",
".",
"_redirect_split",
"(",
"arg",
")",
"if",
"usable",
"!=",
"\"\"",
":",
"self",
".",
"cura... | Sets the value of the argument with the specified id using the argument passed
in from the shell session. | [
"Sets",
"the",
"value",
"of",
"the",
"argument",
"with",
"the",
"specified",
"id",
"using",
"the",
"argument",
"passed",
"in",
"from",
"the",
"shell",
"session",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L315-L324 |
50,266 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._print_map_dict | def _print_map_dict(self, argkey, filename, append):
"""Prints a dictionary that has variable => value mappings."""
result = []
skeys = list(sorted(self.curargs[argkey].keys()))
for key in skeys:
result.append("'{}' => {}".format(key, self.curargs[argkey][key]))
self.... | python | def _print_map_dict(self, argkey, filename, append):
"""Prints a dictionary that has variable => value mappings."""
result = []
skeys = list(sorted(self.curargs[argkey].keys()))
for key in skeys:
result.append("'{}' => {}".format(key, self.curargs[argkey][key]))
self.... | [
"def",
"_print_map_dict",
"(",
"self",
",",
"argkey",
",",
"filename",
",",
"append",
")",
":",
"result",
"=",
"[",
"]",
"skeys",
"=",
"list",
"(",
"sorted",
"(",
"self",
".",
"curargs",
"[",
"argkey",
"]",
".",
"keys",
"(",
")",
")",
")",
"for",
... | Prints a dictionary that has variable => value mappings. | [
"Prints",
"a",
"dictionary",
"that",
"has",
"variable",
"=",
">",
"value",
"mappings",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L645-L651 |
50,267 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_postfix | def do_postfix(self, arg):
"""Sets the function to apply to the values of a specific variable before plotting
or tabulating values.
"""
usable, filename, append = self._redirect_split(arg)
sargs = usable.split()
if len(sargs) == 1 and sargs[0] == "list":
self.... | python | def do_postfix(self, arg):
"""Sets the function to apply to the values of a specific variable before plotting
or tabulating values.
"""
usable, filename, append = self._redirect_split(arg)
sargs = usable.split()
if len(sargs) == 1 and sargs[0] == "list":
self.... | [
"def",
"do_postfix",
"(",
"self",
",",
"arg",
")",
":",
"usable",
",",
"filename",
",",
"append",
"=",
"self",
".",
"_redirect_split",
"(",
"arg",
")",
"sargs",
"=",
"usable",
".",
"split",
"(",
")",
"if",
"len",
"(",
"sargs",
")",
"==",
"1",
"and"... | Sets the function to apply to the values of a specific variable before plotting
or tabulating values. | [
"Sets",
"the",
"function",
"to",
"apply",
"to",
"the",
"values",
"of",
"a",
"specific",
"variable",
"before",
"plotting",
"or",
"tabulating",
"values",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L653-L682 |
50,268 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_rmpostfix | def do_rmpostfix(self, arg):
"""Removes a postfix function from a variable. See 'postfix'."""
altered = False
if arg in self.curargs["functions"]:
del self.curargs["functions"][arg]
altered = True
elif arg == "*":
for varname in list(self.curargs["func... | python | def do_rmpostfix(self, arg):
"""Removes a postfix function from a variable. See 'postfix'."""
altered = False
if arg in self.curargs["functions"]:
del self.curargs["functions"][arg]
altered = True
elif arg == "*":
for varname in list(self.curargs["func... | [
"def",
"do_rmpostfix",
"(",
"self",
",",
"arg",
")",
":",
"altered",
"=",
"False",
"if",
"arg",
"in",
"self",
".",
"curargs",
"[",
"\"functions\"",
"]",
":",
"del",
"self",
".",
"curargs",
"[",
"\"functions\"",
"]",
"[",
"arg",
"]",
"altered",
"=",
"... | Removes a postfix function from a variable. See 'postfix'. | [
"Removes",
"a",
"postfix",
"function",
"from",
"a",
"variable",
".",
"See",
"postfix",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L765-L776 |
50,269 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_rmfit | def do_rmfit(self, arg):
"""Removes a fit function from a variable. See 'fit'."""
if arg in self.curargs["fits"]:
del self.curargs["fits"][arg]
#We also need to remove the variable entry if it exists.
if "timing" in arg:
fitvar = "{}|fit".format(arg)
... | python | def do_rmfit(self, arg):
"""Removes a fit function from a variable. See 'fit'."""
if arg in self.curargs["fits"]:
del self.curargs["fits"][arg]
#We also need to remove the variable entry if it exists.
if "timing" in arg:
fitvar = "{}|fit".format(arg)
... | [
"def",
"do_rmfit",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
"in",
"self",
".",
"curargs",
"[",
"\"fits\"",
"]",
":",
"del",
"self",
".",
"curargs",
"[",
"\"fits\"",
"]",
"[",
"arg",
"]",
"#We also need to remove the variable entry if it exists.",
"if"... | Removes a fit function from a variable. See 'fit'. | [
"Removes",
"a",
"fit",
"function",
"from",
"a",
"variable",
".",
"See",
"fit",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L822-L832 |
50,270 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._get_matplot_dict | def _get_matplot_dict(self, option, prop, defdict):
"""Returns a copy of the settings dictionary for the specified option in
curargs with update values where the value is replaced by the key from
the relevant default dictionary.
:arg option: the key in self.curargs to update.
... | python | def _get_matplot_dict(self, option, prop, defdict):
"""Returns a copy of the settings dictionary for the specified option in
curargs with update values where the value is replaced by the key from
the relevant default dictionary.
:arg option: the key in self.curargs to update.
... | [
"def",
"_get_matplot_dict",
"(",
"self",
",",
"option",
",",
"prop",
",",
"defdict",
")",
":",
"cargs",
"=",
"self",
".",
"curargs",
"[",
"option",
"]",
"result",
"=",
"cargs",
".",
"copy",
"(",
")",
"for",
"varname",
"in",
"cargs",
":",
"if",
"prop"... | Returns a copy of the settings dictionary for the specified option in
curargs with update values where the value is replaced by the key from
the relevant default dictionary.
:arg option: the key in self.curargs to update.
:arg defdict: the default dictionary whose keys should be used ... | [
"Returns",
"a",
"copy",
"of",
"the",
"settings",
"dictionary",
"for",
"the",
"specified",
"option",
"in",
"curargs",
"with",
"update",
"values",
"where",
"the",
"value",
"is",
"replaced",
"by",
"the",
"key",
"from",
"the",
"relevant",
"default",
"dictionary",
... | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L934-L952 |
50,271 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._plot_generic | def _plot_generic(self, filename=None):
"""Plots the current state of the shell, saving the value to the specified file
if specified.
"""
#Since the filename is being passed directly from the argument, check its validity.
if filename == "":
filename = None
if... | python | def _plot_generic(self, filename=None):
"""Plots the current state of the shell, saving the value to the specified file
if specified.
"""
#Since the filename is being passed directly from the argument, check its validity.
if filename == "":
filename = None
if... | [
"def",
"_plot_generic",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"#Since the filename is being passed directly from the argument, check its validity.",
"if",
"filename",
"==",
"\"\"",
":",
"filename",
"=",
"None",
"if",
"\"x\"",
"not",
"in",
"self",
".",
... | Plots the current state of the shell, saving the value to the specified file
if specified. | [
"Plots",
"the",
"current",
"state",
"of",
"the",
"shell",
"saving",
"the",
"value",
"to",
"the",
"specified",
"file",
"if",
"specified",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L954-L979 |
50,272 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_plot | def do_plot(self, arg):
"""Plots the current state of the shell's independent vs. dependent variables on the
same set of axes. Give filename to save to as argument or leave blank to show.
"""
usable, filename, append = self._redirect_split(arg)
self.curargs["xscale"] = None
... | python | def do_plot(self, arg):
"""Plots the current state of the shell's independent vs. dependent variables on the
same set of axes. Give filename to save to as argument or leave blank to show.
"""
usable, filename, append = self._redirect_split(arg)
self.curargs["xscale"] = None
... | [
"def",
"do_plot",
"(",
"self",
",",
"arg",
")",
":",
"usable",
",",
"filename",
",",
"append",
"=",
"self",
".",
"_redirect_split",
"(",
"arg",
")",
"self",
".",
"curargs",
"[",
"\"xscale\"",
"]",
"=",
"None",
"self",
".",
"curargs",
"[",
"\"yscale\"",... | Plots the current state of the shell's independent vs. dependent variables on the
same set of axes. Give filename to save to as argument or leave blank to show. | [
"Plots",
"the",
"current",
"state",
"of",
"the",
"shell",
"s",
"independent",
"vs",
".",
"dependent",
"variables",
"on",
"the",
"same",
"set",
"of",
"axes",
".",
"Give",
"filename",
"to",
"save",
"to",
"as",
"argument",
"or",
"leave",
"blank",
"to",
"sho... | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1051-L1058 |
50,273 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._set_def_prompt | def _set_def_prompt(self):
"""Sets the default prompt to match the currently active unit test."""
if len(self.active) > 15:
ids = self.active.split(".")
if len(ids) > 2:
module, executable, compiler = ids
else:
module, executable = ids
... | python | def _set_def_prompt(self):
"""Sets the default prompt to match the currently active unit test."""
if len(self.active) > 15:
ids = self.active.split(".")
if len(ids) > 2:
module, executable, compiler = ids
else:
module, executable = ids
... | [
"def",
"_set_def_prompt",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"active",
")",
">",
"15",
":",
"ids",
"=",
"self",
".",
"active",
".",
"split",
"(",
"\".\"",
")",
"if",
"len",
"(",
"ids",
")",
">",
"2",
":",
"module",
",",
"exec... | Sets the default prompt to match the currently active unit test. | [
"Sets",
"the",
"default",
"prompt",
"to",
"match",
"the",
"currently",
"active",
"unit",
"test",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1073-L1084 |
50,274 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_set | def do_set(self, arg):
"""Sets the specified 'module.executable' to be the active test result to interact with.
"""
if arg in self.tests:
self.active = arg
#Create a default argument set and analysis group for the current plotting
if arg not in self.args:
... | python | def do_set(self, arg):
"""Sets the specified 'module.executable' to be the active test result to interact with.
"""
if arg in self.tests:
self.active = arg
#Create a default argument set and analysis group for the current plotting
if arg not in self.args:
... | [
"def",
"do_set",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
"in",
"self",
".",
"tests",
":",
"self",
".",
"active",
"=",
"arg",
"#Create a default argument set and analysis group for the current plotting",
"if",
"arg",
"not",
"in",
"self",
".",
"args",
":... | Sets the specified 'module.executable' to be the active test result to interact with. | [
"Sets",
"the",
"specified",
"module",
".",
"executable",
"to",
"be",
"the",
"active",
"test",
"result",
"to",
"interact",
"with",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1086-L1101 |
50,275 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_load | def do_load(self, arg):
"""Loads a saved session variables, settings and test results to the shell."""
from os import path
import json
fullpath = path.expanduser(arg)
if path.isfile(fullpath):
with open(fullpath) as f:
data = json.load(f)
... | python | def do_load(self, arg):
"""Loads a saved session variables, settings and test results to the shell."""
from os import path
import json
fullpath = path.expanduser(arg)
if path.isfile(fullpath):
with open(fullpath) as f:
data = json.load(f)
... | [
"def",
"do_load",
"(",
"self",
",",
"arg",
")",
":",
"from",
"os",
"import",
"path",
"import",
"json",
"fullpath",
"=",
"path",
".",
"expanduser",
"(",
"arg",
")",
"if",
"path",
".",
"isfile",
"(",
"fullpath",
")",
":",
"with",
"open",
"(",
"fullpath... | Loads a saved session variables, settings and test results to the shell. | [
"Loads",
"a",
"saved",
"session",
"variables",
"settings",
"and",
"test",
"results",
"to",
"the",
"shell",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1145-L1157 |
50,276 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_reparse | def do_reparse(self, arg):
"""Reparses the currently active unit test to get the latest test results loaded
to the console.
"""
#We just get the full path of the currently active test and hit reparse.
full = arg == "full"
from os import path
fullpath = path.abspat... | python | def do_reparse(self, arg):
"""Reparses the currently active unit test to get the latest test results loaded
to the console.
"""
#We just get the full path of the currently active test and hit reparse.
full = arg == "full"
from os import path
fullpath = path.abspat... | [
"def",
"do_reparse",
"(",
"self",
",",
"arg",
")",
":",
"#We just get the full path of the currently active test and hit reparse.",
"full",
"=",
"arg",
"==",
"\"full\"",
"from",
"os",
"import",
"path",
"fullpath",
"=",
"path",
".",
"abspath",
"(",
"self",
".",
"te... | Reparses the currently active unit test to get the latest test results loaded
to the console. | [
"Reparses",
"the",
"currently",
"active",
"unit",
"test",
"to",
"get",
"the",
"latest",
"test",
"results",
"loaded",
"to",
"the",
"console",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1237-L1245 |
50,277 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._make_fits | def _make_fits(self):
"""Generates the data fits for any variables set for fitting in the shell."""
a = self.tests[self.active]
args = self.curargs
#We need to generate a fit for the data if there are any fits specified.
if len(args["fits"]) > 0:
for fit in list(args[... | python | def _make_fits(self):
"""Generates the data fits for any variables set for fitting in the shell."""
a = self.tests[self.active]
args = self.curargs
#We need to generate a fit for the data if there are any fits specified.
if len(args["fits"]) > 0:
for fit in list(args[... | [
"def",
"_make_fits",
"(",
"self",
")",
":",
"a",
"=",
"self",
".",
"tests",
"[",
"self",
".",
"active",
"]",
"args",
"=",
"self",
".",
"curargs",
"#We need to generate a fit for the data if there are any fits specified.",
"if",
"len",
"(",
"args",
"[",
"\"fits\"... | Generates the data fits for any variables set for fitting in the shell. | [
"Generates",
"the",
"data",
"fits",
"for",
"any",
"variables",
"set",
"for",
"fitting",
"in",
"the",
"shell",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1323-L1330 |
50,278 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_table | def do_table(self, arg):
"""Prints the set of values for the independent vs. dependent variables in the
active unit test and analysis group as a table.
"""
usable, filename, append = self._redirect_split(arg)
a = self.tests[self.active]
args = self.curargs
self._m... | python | def do_table(self, arg):
"""Prints the set of values for the independent vs. dependent variables in the
active unit test and analysis group as a table.
"""
usable, filename, append = self._redirect_split(arg)
a = self.tests[self.active]
args = self.curargs
self._m... | [
"def",
"do_table",
"(",
"self",
",",
"arg",
")",
":",
"usable",
",",
"filename",
",",
"append",
"=",
"self",
".",
"_redirect_split",
"(",
"arg",
")",
"a",
"=",
"self",
".",
"tests",
"[",
"self",
".",
"active",
"]",
"args",
"=",
"self",
".",
"curarg... | Prints the set of values for the independent vs. dependent variables in the
active unit test and analysis group as a table. | [
"Prints",
"the",
"set",
"of",
"values",
"for",
"the",
"independent",
"vs",
".",
"dependent",
"variables",
"in",
"the",
"active",
"unit",
"test",
"and",
"analysis",
"group",
"as",
"a",
"table",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1332-L1343 |
50,279 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_failures | def do_failures(self, arg):
"""Prints a list of test cases that failed for the current unit test and analysis
group settings. To only check failure on specific output files, set the list of
files to check as arguments.
"""
usable, filename, append = self._redirect_split(arg)
... | python | def do_failures(self, arg):
"""Prints a list of test cases that failed for the current unit test and analysis
group settings. To only check failure on specific output files, set the list of
files to check as arguments.
"""
usable, filename, append = self._redirect_split(arg)
... | [
"def",
"do_failures",
"(",
"self",
",",
"arg",
")",
":",
"usable",
",",
"filename",
",",
"append",
"=",
"self",
".",
"_redirect_split",
"(",
"arg",
")",
"a",
"=",
"self",
".",
"tests",
"[",
"self",
".",
"active",
"]",
"args",
"=",
"self",
".",
"cur... | Prints a list of test cases that failed for the current unit test and analysis
group settings. To only check failure on specific output files, set the list of
files to check as arguments. | [
"Prints",
"a",
"list",
"of",
"test",
"cases",
"that",
"failed",
"for",
"the",
"current",
"unit",
"test",
"and",
"analysis",
"group",
"settings",
".",
"To",
"only",
"check",
"failure",
"on",
"specific",
"output",
"files",
"set",
"the",
"list",
"of",
"files"... | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1356-L1375 |
50,280 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.histpath | def histpath(self):
"""Returns the full path to the console history file."""
from os import path
from fortpy import settings
return path.join(settings.cache_directory, "history") | python | def histpath(self):
"""Returns the full path to the console history file."""
from os import path
from fortpy import settings
return path.join(settings.cache_directory, "history") | [
"def",
"histpath",
"(",
"self",
")",
":",
"from",
"os",
"import",
"path",
"from",
"fortpy",
"import",
"settings",
"return",
"path",
".",
"join",
"(",
"settings",
".",
"cache_directory",
",",
"\"history\"",
")"
] | Returns the full path to the console history file. | [
"Returns",
"the",
"full",
"path",
"to",
"the",
"console",
"history",
"file",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1493-L1497 |
50,281 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell._store_lasterr | def _store_lasterr(self):
"""Stores the information about the last unhandled exception."""
from sys import exc_info
from traceback import format_exception
e = exc_info()
self.lasterr = '\n'.join(format_exception(e[0], e[1], e[2])) | python | def _store_lasterr(self):
"""Stores the information about the last unhandled exception."""
from sys import exc_info
from traceback import format_exception
e = exc_info()
self.lasterr = '\n'.join(format_exception(e[0], e[1], e[2])) | [
"def",
"_store_lasterr",
"(",
"self",
")",
":",
"from",
"sys",
"import",
"exc_info",
"from",
"traceback",
"import",
"format_exception",
"e",
"=",
"exc_info",
"(",
")",
"self",
".",
"lasterr",
"=",
"'\\n'",
".",
"join",
"(",
"format_exception",
"(",
"e",
"[... | Stores the information about the last unhandled exception. | [
"Stores",
"the",
"information",
"about",
"the",
"last",
"unhandled",
"exception",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1514-L1519 |
50,282 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.precmd | def precmd(self, line):
"""Makes sure that the command specified in the line is valid given the current
status of loaded unit tests and analysis group.
"""
if line == "":
return ""
command = line.split()[0]
if "!" in command:
value = command.split(... | python | def precmd(self, line):
"""Makes sure that the command specified in the line is valid given the current
status of loaded unit tests and analysis group.
"""
if line == "":
return ""
command = line.split()[0]
if "!" in command:
value = command.split(... | [
"def",
"precmd",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
"==",
"\"\"",
":",
"return",
"\"\"",
"command",
"=",
"line",
".",
"split",
"(",
")",
"[",
"0",
"]",
"if",
"\"!\"",
"in",
"command",
":",
"value",
"=",
"command",
".",
"split",
"("... | Makes sure that the command specified in the line is valid given the current
status of loaded unit tests and analysis group. | [
"Makes",
"sure",
"that",
"the",
"command",
"specified",
"in",
"the",
"line",
"is",
"valid",
"given",
"the",
"current",
"status",
"of",
"loaded",
"unit",
"tests",
"and",
"analysis",
"group",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1539-L1586 |
50,283 | rosenbrockc/fortpy | fortpy/scripts/analyze.py | FortpyShell.do_cd | def do_cd(self, arg):
"""Imitates the bash shell 'cd' command."""
from os import chdir, path
fullpath = path.abspath(path.expanduser(arg))
if path.isdir(fullpath):
chdir(fullpath)
else:
msg.err("'{}' is not a valid directory.".format(arg)) | python | def do_cd(self, arg):
"""Imitates the bash shell 'cd' command."""
from os import chdir, path
fullpath = path.abspath(path.expanduser(arg))
if path.isdir(fullpath):
chdir(fullpath)
else:
msg.err("'{}' is not a valid directory.".format(arg)) | [
"def",
"do_cd",
"(",
"self",
",",
"arg",
")",
":",
"from",
"os",
"import",
"chdir",
",",
"path",
"fullpath",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"expanduser",
"(",
"arg",
")",
")",
"if",
"path",
".",
"isdir",
"(",
"fullpath",
")",
":",
... | Imitates the bash shell 'cd' command. | [
"Imitates",
"the",
"bash",
"shell",
"cd",
"command",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L1602-L1609 |
50,284 | PixelwarStudio/PyTree | Tree/core.py | generate_branches | def generate_branches(scales=None, angles=None, shift_angle=0):
"""Generates branches with alternative system.
Args:
scales (tuple/array): Indicating how the branch/es length/es develop/s from age to age.
angles (tuple/array): Holding the branch and shift angle in radians.
shift_angle (... | python | def generate_branches(scales=None, angles=None, shift_angle=0):
"""Generates branches with alternative system.
Args:
scales (tuple/array): Indicating how the branch/es length/es develop/s from age to age.
angles (tuple/array): Holding the branch and shift angle in radians.
shift_angle (... | [
"def",
"generate_branches",
"(",
"scales",
"=",
"None",
",",
"angles",
"=",
"None",
",",
"shift_angle",
"=",
"0",
")",
":",
"branches",
"=",
"[",
"]",
"for",
"pos",
",",
"scale",
"in",
"enumerate",
"(",
"scales",
")",
":",
"angle",
"=",
"-",
"sum",
... | Generates branches with alternative system.
Args:
scales (tuple/array): Indicating how the branch/es length/es develop/s from age to age.
angles (tuple/array): Holding the branch and shift angle in radians.
shift_angle (float): Holding the rotation angle for all branches.
Returns:
... | [
"Generates",
"branches",
"with",
"alternative",
"system",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L225-L240 |
50,285 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_rectangle | def get_rectangle(self):
"""Gets the coordinates of the rectangle, in which the tree can be put.
Returns:
tupel: (x1, y1, x2, y2)
"""
rec = [self.pos[0], self.pos[1]]*2
for age in self.nodes:
for node in age:
# Check max/min for x/y coords... | python | def get_rectangle(self):
"""Gets the coordinates of the rectangle, in which the tree can be put.
Returns:
tupel: (x1, y1, x2, y2)
"""
rec = [self.pos[0], self.pos[1]]*2
for age in self.nodes:
for node in age:
# Check max/min for x/y coords... | [
"def",
"get_rectangle",
"(",
"self",
")",
":",
"rec",
"=",
"[",
"self",
".",
"pos",
"[",
"0",
"]",
",",
"self",
".",
"pos",
"[",
"1",
"]",
"]",
"*",
"2",
"for",
"age",
"in",
"self",
".",
"nodes",
":",
"for",
"node",
"in",
"age",
":",
"# Check... | Gets the coordinates of the rectangle, in which the tree can be put.
Returns:
tupel: (x1, y1, x2, y2) | [
"Gets",
"the",
"coordinates",
"of",
"the",
"rectangle",
"in",
"which",
"the",
"tree",
"can",
"be",
"put",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L31-L46 |
50,286 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_size | def get_size(self):
"""Get the size of the tree.
Returns:
tupel: (width, height)
"""
rec = self.get_rectangle()
return (int(rec[2]-rec[0]), int(rec[3]-rec[1])) | python | def get_size(self):
"""Get the size of the tree.
Returns:
tupel: (width, height)
"""
rec = self.get_rectangle()
return (int(rec[2]-rec[0]), int(rec[3]-rec[1])) | [
"def",
"get_size",
"(",
"self",
")",
":",
"rec",
"=",
"self",
".",
"get_rectangle",
"(",
")",
"return",
"(",
"int",
"(",
"rec",
"[",
"2",
"]",
"-",
"rec",
"[",
"0",
"]",
")",
",",
"int",
"(",
"rec",
"[",
"3",
"]",
"-",
"rec",
"[",
"1",
"]",... | Get the size of the tree.
Returns:
tupel: (width, height) | [
"Get",
"the",
"size",
"of",
"the",
"tree",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L48-L55 |
50,287 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_branch_length | def get_branch_length(self, age=None, pos=0):
"""Get the length of a branch.
This method calculates the length of a branch in specific age.
The used formula: length * scale^age.
Args:
age (int): The age, for which you want to know the branch length.
Returns:
... | python | def get_branch_length(self, age=None, pos=0):
"""Get the length of a branch.
This method calculates the length of a branch in specific age.
The used formula: length * scale^age.
Args:
age (int): The age, for which you want to know the branch length.
Returns:
... | [
"def",
"get_branch_length",
"(",
"self",
",",
"age",
"=",
"None",
",",
"pos",
"=",
"0",
")",
":",
"if",
"age",
"is",
"None",
":",
"age",
"=",
"self",
".",
"age",
"return",
"self",
".",
"length",
"*",
"pow",
"(",
"self",
".",
"branches",
"[",
"pos... | Get the length of a branch.
This method calculates the length of a branch in specific age.
The used formula: length * scale^age.
Args:
age (int): The age, for which you want to know the branch length.
Returns:
float: The length of the branch | [
"Get",
"the",
"length",
"of",
"a",
"branch",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L57-L71 |
50,288 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_steps_branch_len | def get_steps_branch_len(self, length):
"""Get, how much steps will needed for a given branch length.
Returns:
float: The age the tree must achieve to reach the given branch length.
"""
return log(length/self.length, min(self.branches[0][0])) | python | def get_steps_branch_len(self, length):
"""Get, how much steps will needed for a given branch length.
Returns:
float: The age the tree must achieve to reach the given branch length.
"""
return log(length/self.length, min(self.branches[0][0])) | [
"def",
"get_steps_branch_len",
"(",
"self",
",",
"length",
")",
":",
"return",
"log",
"(",
"length",
"/",
"self",
".",
"length",
",",
"min",
"(",
"self",
".",
"branches",
"[",
"0",
"]",
"[",
"0",
"]",
")",
")"
] | Get, how much steps will needed for a given branch length.
Returns:
float: The age the tree must achieve to reach the given branch length. | [
"Get",
"how",
"much",
"steps",
"will",
"needed",
"for",
"a",
"given",
"branch",
"length",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L73-L79 |
50,289 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_node_sum | def get_node_sum(self, age=None):
"""Get sum of all branches in the tree.
Returns:
int: The sum of all nodes grown until the age.
"""
if age is None:
age = self.age
return age if self.comp == 1 else int((pow(self.comp, age+1) - 1) / (self.comp - 1)) | python | def get_node_sum(self, age=None):
"""Get sum of all branches in the tree.
Returns:
int: The sum of all nodes grown until the age.
"""
if age is None:
age = self.age
return age if self.comp == 1 else int((pow(self.comp, age+1) - 1) / (self.comp - 1)) | [
"def",
"get_node_sum",
"(",
"self",
",",
"age",
"=",
"None",
")",
":",
"if",
"age",
"is",
"None",
":",
"age",
"=",
"self",
".",
"age",
"return",
"age",
"if",
"self",
".",
"comp",
"==",
"1",
"else",
"int",
"(",
"(",
"pow",
"(",
"self",
".",
"com... | Get sum of all branches in the tree.
Returns:
int: The sum of all nodes grown until the age. | [
"Get",
"sum",
"of",
"all",
"branches",
"in",
"the",
"tree",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L81-L90 |
50,290 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_node_age_sum | def get_node_age_sum(self, age=None):
"""Get the sum of branches grown in an specific age.
Returns:
int: The sum of all nodes grown in an age.
"""
if age is None:
age = self.age
return pow(self.comp, age) | python | def get_node_age_sum(self, age=None):
"""Get the sum of branches grown in an specific age.
Returns:
int: The sum of all nodes grown in an age.
"""
if age is None:
age = self.age
return pow(self.comp, age) | [
"def",
"get_node_age_sum",
"(",
"self",
",",
"age",
"=",
"None",
")",
":",
"if",
"age",
"is",
"None",
":",
"age",
"=",
"self",
".",
"age",
"return",
"pow",
"(",
"self",
".",
"comp",
",",
"age",
")"
] | Get the sum of branches grown in an specific age.
Returns:
int: The sum of all nodes grown in an age. | [
"Get",
"the",
"sum",
"of",
"branches",
"grown",
"in",
"an",
"specific",
"age",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L92-L101 |
50,291 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_nodes | def get_nodes(self):
"""Get the tree nodes as list.
Returns:
list: A 2d-list holding the grown nodes coordinates as tupel for every age.
Example:
[
[(10, 40)],
[(20, 80), (100, 30)],
[(100, 90), (120, 40), ...],... | python | def get_nodes(self):
"""Get the tree nodes as list.
Returns:
list: A 2d-list holding the grown nodes coordinates as tupel for every age.
Example:
[
[(10, 40)],
[(20, 80), (100, 30)],
[(100, 90), (120, 40), ...],... | [
"def",
"get_nodes",
"(",
"self",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"age",
",",
"level",
"in",
"enumerate",
"(",
"self",
".",
"nodes",
")",
":",
"nodes",
".",
"append",
"(",
"[",
"]",
")",
"for",
"node",
"in",
"level",
":",
"nodes",
"[",
... | Get the tree nodes as list.
Returns:
list: A 2d-list holding the grown nodes coordinates as tupel for every age.
Example:
[
[(10, 40)],
[(20, 80), (100, 30)],
[(100, 90), (120, 40), ...],
...
... | [
"Get",
"the",
"tree",
"nodes",
"as",
"list",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L103-L121 |
50,292 | PixelwarStudio/PyTree | Tree/core.py | Tree.get_branches | def get_branches(self):
"""Get the tree branches as list.
Returns:
list: A 2d-list holding the grown branches coordinates as tupel for every age.
Example:
[
[(10, 40, 90, 30)],
[(90, 30, 100, 40), (90, 30, 300, 60)],
... | python | def get_branches(self):
"""Get the tree branches as list.
Returns:
list: A 2d-list holding the grown branches coordinates as tupel for every age.
Example:
[
[(10, 40, 90, 30)],
[(90, 30, 100, 40), (90, 30, 300, 60)],
... | [
"def",
"get_branches",
"(",
"self",
")",
":",
"branches",
"=",
"[",
"]",
"for",
"age",
",",
"level",
"in",
"enumerate",
"(",
"self",
".",
"nodes",
")",
":",
"branches",
".",
"append",
"(",
"[",
"]",
")",
"for",
"n",
",",
"node",
"in",
"enumerate",
... | Get the tree branches as list.
Returns:
list: A 2d-list holding the grown branches coordinates as tupel for every age.
Example:
[
[(10, 40, 90, 30)],
[(90, 30, 100, 40), (90, 30, 300, 60)],
[(100, 40, 120, 70), (100, 40... | [
"Get",
"the",
"tree",
"branches",
"as",
"list",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L123-L146 |
50,293 | PixelwarStudio/PyTree | Tree/core.py | Tree.move | def move(self, delta):
"""Move the tree.
Args:
delta (tupel): The adjustment of the position.
"""
pos = self.pos
self.pos = (pos[0]+delta[0], pos[1]+delta[1], pos[2]+delta[0], pos[3]+delta[1])
# Move all nodes
for age in self.nodes:
for n... | python | def move(self, delta):
"""Move the tree.
Args:
delta (tupel): The adjustment of the position.
"""
pos = self.pos
self.pos = (pos[0]+delta[0], pos[1]+delta[1], pos[2]+delta[0], pos[3]+delta[1])
# Move all nodes
for age in self.nodes:
for n... | [
"def",
"move",
"(",
"self",
",",
"delta",
")",
":",
"pos",
"=",
"self",
".",
"pos",
"self",
".",
"pos",
"=",
"(",
"pos",
"[",
"0",
"]",
"+",
"delta",
"[",
"0",
"]",
",",
"pos",
"[",
"1",
"]",
"+",
"delta",
"[",
"1",
"]",
",",
"pos",
"[",
... | Move the tree.
Args:
delta (tupel): The adjustment of the position. | [
"Move",
"the",
"tree",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L148-L160 |
50,294 | PixelwarStudio/PyTree | Tree/core.py | Tree.grow | def grow(self, times=1):
"""Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow.
"""
self.nodes.append([])
for n, node in enumerate(self.nodes[self.age]):
if self.age == 0:
p_node = Node(self.pos[:2])
... | python | def grow(self, times=1):
"""Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow.
"""
self.nodes.append([])
for n, node in enumerate(self.nodes[self.age]):
if self.age == 0:
p_node = Node(self.pos[:2])
... | [
"def",
"grow",
"(",
"self",
",",
"times",
"=",
"1",
")",
":",
"self",
".",
"nodes",
".",
"append",
"(",
"[",
"]",
")",
"for",
"n",
",",
"node",
"in",
"enumerate",
"(",
"self",
".",
"nodes",
"[",
"self",
".",
"age",
"]",
")",
":",
"if",
"self"... | Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow. | [
"Let",
"the",
"tree",
"grow",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L167-L189 |
50,295 | PixelwarStudio/PyTree | Tree/core.py | Tree.draw_on | def draw_on(self, canvas, stem_color, leaf_color, thickness, ages=None):
"""Draw the tree on a canvas.
Args:
canvas (object): The canvas, you want to draw the tree on. Supported canvases: svgwrite.Drawing and PIL.Image (You can also add your custom libraries.)
stem_color (tupel)... | python | def draw_on(self, canvas, stem_color, leaf_color, thickness, ages=None):
"""Draw the tree on a canvas.
Args:
canvas (object): The canvas, you want to draw the tree on. Supported canvases: svgwrite.Drawing and PIL.Image (You can also add your custom libraries.)
stem_color (tupel)... | [
"def",
"draw_on",
"(",
"self",
",",
"canvas",
",",
"stem_color",
",",
"leaf_color",
",",
"thickness",
",",
"ages",
"=",
"None",
")",
":",
"if",
"canvas",
".",
"__module__",
"in",
"SUPPORTED_CANVAS",
":",
"drawer",
"=",
"SUPPORTED_CANVAS",
"[",
"canvas",
".... | Draw the tree on a canvas.
Args:
canvas (object): The canvas, you want to draw the tree on. Supported canvases: svgwrite.Drawing and PIL.Image (You can also add your custom libraries.)
stem_color (tupel): Color or gradient for the stem of the tree.
leaf_color (tupel): Color ... | [
"Draw",
"the",
"tree",
"on",
"a",
"canvas",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L191-L202 |
50,296 | PixelwarStudio/PyTree | Tree/core.py | Tree.__get_total_angle | def __get_total_angle(self, angle, pos):
"""Get the total angle."""
tot_angle = angle - self.branches[pos][1]
if self.sigma[1] != 0:
tot_angle += gauss(0, self.sigma[1]) * pi
return tot_angle | python | def __get_total_angle(self, angle, pos):
"""Get the total angle."""
tot_angle = angle - self.branches[pos][1]
if self.sigma[1] != 0:
tot_angle += gauss(0, self.sigma[1]) * pi
return tot_angle | [
"def",
"__get_total_angle",
"(",
"self",
",",
"angle",
",",
"pos",
")",
":",
"tot_angle",
"=",
"angle",
"-",
"self",
".",
"branches",
"[",
"pos",
"]",
"[",
"1",
"]",
"if",
"self",
".",
"sigma",
"[",
"1",
"]",
"!=",
"0",
":",
"tot_angle",
"+=",
"g... | Get the total angle. | [
"Get",
"the",
"total",
"angle",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L204-L209 |
50,297 | PixelwarStudio/PyTree | Tree/core.py | Tree._get_node_parent | def _get_node_parent(self, age, pos):
"""Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node.
"""
return self.nodes[age][int(pos / self.comp)] | python | def _get_node_parent(self, age, pos):
"""Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node.
"""
return self.nodes[age][int(pos / self.comp)] | [
"def",
"_get_node_parent",
"(",
"self",
",",
"age",
",",
"pos",
")",
":",
"return",
"self",
".",
"nodes",
"[",
"age",
"]",
"[",
"int",
"(",
"pos",
"/",
"self",
".",
"comp",
")",
"]"
] | Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node. | [
"Get",
"the",
"parent",
"node",
"of",
"node",
"whch",
"is",
"located",
"in",
"tree",
"s",
"node",
"list",
"."
] | f14b25ea145da6b00d836e34251d2a4c823766dc | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L217-L223 |
50,298 | benspaulding/django-faq | faq/models.py | _field_lookups | def _field_lookups(model, status=None):
"""
Abstraction of field lookups for managers.
Returns a dictionary of field lookups for a queryset. The lookups
will always filter by site. Optionally, if ``status`` is passed to
the function the objects will also be filtered by the given status.
This f... | python | def _field_lookups(model, status=None):
"""
Abstraction of field lookups for managers.
Returns a dictionary of field lookups for a queryset. The lookups
will always filter by site. Optionally, if ``status`` is passed to
the function the objects will also be filtered by the given status.
This f... | [
"def",
"_field_lookups",
"(",
"model",
",",
"status",
"=",
"None",
")",
":",
"# Import models here to avoid circular import fail.",
"from",
"faq",
".",
"models",
"import",
"Topic",
",",
"Question",
"field_lookups",
"=",
"{",
"}",
"if",
"model",
"==",
"Topic",
":... | Abstraction of field lookups for managers.
Returns a dictionary of field lookups for a queryset. The lookups
will always filter by site. Optionally, if ``status`` is passed to
the function the objects will also be filtered by the given status.
This function saves from having to make two different on-s... | [
"Abstraction",
"of",
"field",
"lookups",
"for",
"managers",
"."
] | 9a744e7c1943fd05bfa42c84b2ce003367c58e6e | https://github.com/benspaulding/django-faq/blob/9a744e7c1943fd05bfa42c84b2ce003367c58e6e/faq/models.py#L14-L45 |
50,299 | rosenbrockc/fortpy | fortpy/templates/ftypes.py | detect_compiler | def detect_compiler(libpath):
"""Determines the compiler used to compile the specified shared library by
using the system utilities.
:arg libpath: the full path to the shared library *.so file.
"""
from os import waitpid, path
from subprocess import Popen, PIPE
command = "nm {0}".format(pat... | python | def detect_compiler(libpath):
"""Determines the compiler used to compile the specified shared library by
using the system utilities.
:arg libpath: the full path to the shared library *.so file.
"""
from os import waitpid, path
from subprocess import Popen, PIPE
command = "nm {0}".format(pat... | [
"def",
"detect_compiler",
"(",
"libpath",
")",
":",
"from",
"os",
"import",
"waitpid",
",",
"path",
"from",
"subprocess",
"import",
"Popen",
",",
"PIPE",
"command",
"=",
"\"nm {0}\"",
".",
"format",
"(",
"path",
".",
"abspath",
"(",
"libpath",
")",
")",
... | Determines the compiler used to compile the specified shared library by
using the system utilities.
:arg libpath: the full path to the shared library *.so file. | [
"Determines",
"the",
"compiler",
"used",
"to",
"compile",
"the",
"specified",
"shared",
"library",
"by",
"using",
"the",
"system",
"utilities",
"."
] | 1ed0757c52d549e41d9d44bdea68cb89529293a5 | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/templates/ftypes.py#L76-L98 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.