partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | write_temporal_network | Parameters
----------
gtfs : gtfspy.GTFS
output_filename : str
path to the directory where to store the extracts
start_time_ut: int | None
start time of the extract in unixtime (seconds after epoch)
end_time_ut: int | None
end time of the extract in unixtime (seconds after ep... | gtfspy/exports.py | def write_temporal_network(gtfs, output_filename, start_time_ut=None, end_time_ut=None):
"""
Parameters
----------
gtfs : gtfspy.GTFS
output_filename : str
path to the directory where to store the extracts
start_time_ut: int | None
start time of the extract in unixtime (seconds a... | def write_temporal_network(gtfs, output_filename, start_time_ut=None, end_time_ut=None):
"""
Parameters
----------
gtfs : gtfspy.GTFS
output_filename : str
path to the directory where to store the extracts
start_time_ut: int | None
start time of the extract in unixtime (seconds a... | [
"Parameters",
"----------",
"gtfs",
":",
"gtfspy",
".",
"GTFS",
"output_filename",
":",
"str",
"path",
"to",
"the",
"directory",
"where",
"to",
"store",
"the",
"extracts",
"start_time_ut",
":",
"int",
"|",
"None",
"start",
"time",
"of",
"the",
"extract",
"in... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/exports.py#L155-L169 | [
"def",
"write_temporal_network",
"(",
"gtfs",
",",
"output_filename",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
")",
":",
"util",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | _write_stop_to_stop_network_edges | Write out a network
Parameters
----------
net: networkx.DiGraph
base_name: str
path to the filename (without extension)
data: bool, optional
whether or not to write out any edge data present
fmt: str, optional
If "csv" write out the network in csv format. | gtfspy/exports.py | def _write_stop_to_stop_network_edges(net, file_name, data=True, fmt=None):
"""
Write out a network
Parameters
----------
net: networkx.DiGraph
base_name: str
path to the filename (without extension)
data: bool, optional
whether or not to write out any edge data present
... | def _write_stop_to_stop_network_edges(net, file_name, data=True, fmt=None):
"""
Write out a network
Parameters
----------
net: networkx.DiGraph
base_name: str
path to the filename (without extension)
data: bool, optional
whether or not to write out any edge data present
... | [
"Write",
"out",
"a",
"network"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/exports.py#L172-L213 | [
"def",
"_write_stop_to_stop_network_edges",
"(",
"net",
",",
"file_name",
",",
"data",
"=",
"True",
",",
"fmt",
"=",
"None",
")",
":",
"if",
"fmt",
"is",
"None",
":",
"fmt",
"=",
"\"edg\"",
"if",
"fmt",
"==",
"\"edg\"",
":",
"if",
"data",
":",
"network... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | write_gtfs | Write out the database according to the GTFS format.
Parameters
----------
gtfs: gtfspy.GTFS
output: str
Path where to put the GTFS files
if output ends with ".zip" a ZIP-file is created instead.
Returns
-------
None | gtfspy/exports.py | def write_gtfs(gtfs, output):
"""
Write out the database according to the GTFS format.
Parameters
----------
gtfs: gtfspy.GTFS
output: str
Path where to put the GTFS files
if output ends with ".zip" a ZIP-file is created instead.
Returns
-------
None
"""
out... | def write_gtfs(gtfs, output):
"""
Write out the database according to the GTFS format.
Parameters
----------
gtfs: gtfspy.GTFS
output: str
Path where to put the GTFS files
if output ends with ".zip" a ZIP-file is created instead.
Returns
-------
None
"""
out... | [
"Write",
"out",
"the",
"database",
"according",
"to",
"the",
"GTFS",
"format",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/exports.py#L280-L337 | [
"def",
"write_gtfs",
"(",
"gtfs",
",",
"output",
")",
":",
"output",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"output",
")",
"uuid_str",
"=",
"\"tmp_\"",
"+",
"str",
"(",
"uuid",
".",
"uuid1",
"(",
")",
")",
"if",
"output",
"[",
"-",
"4",
":"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | _remove_I_columns | Remove columns ending with I from a pandas.DataFrame
Parameters
----------
df: dataFrame
Returns
-------
None | gtfspy/exports.py | def _remove_I_columns(df):
"""
Remove columns ending with I from a pandas.DataFrame
Parameters
----------
df: dataFrame
Returns
-------
None
"""
all_columns = list(filter(lambda el: el[-2:] == "_I", df.columns))
for column in all_columns:
del df[column] | def _remove_I_columns(df):
"""
Remove columns ending with I from a pandas.DataFrame
Parameters
----------
df: dataFrame
Returns
-------
None
"""
all_columns = list(filter(lambda el: el[-2:] == "_I", df.columns))
for column in all_columns:
del df[column] | [
"Remove",
"columns",
"ending",
"with",
"I",
"from",
"a",
"pandas",
".",
"DataFrame"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/exports.py#L341-L355 | [
"def",
"_remove_I_columns",
"(",
"df",
")",
":",
"all_columns",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"el",
":",
"el",
"[",
"-",
"2",
":",
"]",
"==",
"\"_I\"",
",",
"df",
".",
"columns",
")",
")",
"for",
"column",
"in",
"all_columns",
":",
"de... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ConnectionScanProfiler._scan_footpaths_to_departure_stop | A helper method for scanning the footpaths. Updates self._stop_profiles accordingly | gtfspy/routing/connection_scan_profile.py | def _scan_footpaths_to_departure_stop(self, connection_dep_stop, connection_dep_time, arrival_time_target):
""" A helper method for scanning the footpaths. Updates self._stop_profiles accordingly"""
for _, neighbor, data in self._walk_network.edges_iter(nbunch=[connection_dep_stop],
... | def _scan_footpaths_to_departure_stop(self, connection_dep_stop, connection_dep_time, arrival_time_target):
""" A helper method for scanning the footpaths. Updates self._stop_profiles accordingly"""
for _, neighbor, data in self._walk_network.edges_iter(nbunch=[connection_dep_stop],
... | [
"A",
"helper",
"method",
"for",
"scanning",
"the",
"footpaths",
".",
"Updates",
"self",
".",
"_stop_profiles",
"accordingly"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/connection_scan_profile.py#L157-L164 | [
"def",
"_scan_footpaths_to_departure_stop",
"(",
"self",
",",
"connection_dep_stop",
",",
"connection_dep_time",
",",
"arrival_time_target",
")",
":",
"for",
"_",
",",
"neighbor",
",",
"data",
"in",
"self",
".",
"_walk_network",
".",
"edges_iter",
"(",
"nbunch",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | plot_route_network_from_gtfs | Parameters
----------
g: A gtfspy.gtfs.GTFS object
Where to get the data from?
ax: matplotlib.Axes object, optional
If None, a new figure and an axis is created
spatial_bounds: dict, optional
with str keys: lon_min, lon_max, lat_min, lat_max
return_smopy_map: bool, optional
... | gtfspy/mapviz.py | def plot_route_network_from_gtfs(g, ax=None, spatial_bounds=None, map_alpha=0.8, scalebar=True, legend=True,
return_smopy_map=False, map_style=None):
"""
Parameters
----------
g: A gtfspy.gtfs.GTFS object
Where to get the data from?
ax: matplotlib.Axes object... | def plot_route_network_from_gtfs(g, ax=None, spatial_bounds=None, map_alpha=0.8, scalebar=True, legend=True,
return_smopy_map=False, map_style=None):
"""
Parameters
----------
g: A gtfspy.gtfs.GTFS object
Where to get the data from?
ax: matplotlib.Axes object... | [
"Parameters",
"----------",
"g",
":",
"A",
"gtfspy",
".",
"gtfs",
".",
"GTFS",
"object",
"Where",
"to",
"get",
"the",
"data",
"from?",
"ax",
":",
"matplotlib",
".",
"Axes",
"object",
"optional",
"If",
"None",
"a",
"new",
"figure",
"and",
"an",
"axis",
... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/mapviz.py#L46-L81 | [
"def",
"plot_route_network_from_gtfs",
"(",
"g",
",",
"ax",
"=",
"None",
",",
"spatial_bounds",
"=",
"None",
",",
"map_alpha",
"=",
"0.8",
",",
"scalebar",
"=",
"True",
",",
"legend",
"=",
"True",
",",
"return_smopy_map",
"=",
"False",
",",
"map_style",
"=... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | plot_as_routes | Parameters
----------
route_shapes: list of dicts that should have the following keys
name, type, agency, lats, lons
with types
list, list, str, list, list
ax: axis object
spatial_bounds: dict
map_alpha:
plot_scalebar: bool
legend:
return_smopy_map:
... | gtfspy/mapviz.py | def plot_as_routes(route_shapes, ax=None, spatial_bounds=None, map_alpha=0.8, plot_scalebar=True, legend=True,
return_smopy_map=False, line_width_attribute=None, line_width_scale=1.0, map_style=None):
"""
Parameters
----------
route_shapes: list of dicts that should have the following... | def plot_as_routes(route_shapes, ax=None, spatial_bounds=None, map_alpha=0.8, plot_scalebar=True, legend=True,
return_smopy_map=False, line_width_attribute=None, line_width_scale=1.0, map_style=None):
"""
Parameters
----------
route_shapes: list of dicts that should have the following... | [
"Parameters",
"----------",
"route_shapes",
":",
"list",
"of",
"dicts",
"that",
"should",
"have",
"the",
"following",
"keys",
"name",
"type",
"agency",
"lats",
"lons",
"with",
"types",
"list",
"list",
"str",
"list",
"list",
"ax",
":",
"axis",
"object",
"spat... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/mapviz.py#L84-L148 | [
"def",
"plot_as_routes",
"(",
"route_shapes",
",",
"ax",
"=",
"None",
",",
"spatial_bounds",
"=",
"None",
",",
"map_alpha",
"=",
"0.8",
",",
"plot_scalebar",
"=",
"True",
",",
"legend",
"=",
"True",
",",
"return_smopy_map",
"=",
"False",
",",
"line_width_att... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | _expand_spatial_bounds_to_fit_axes | Parameters
----------
bounds: dict
ax_width: float
ax_height: float
Returns
-------
spatial_bounds | gtfspy/mapviz.py | def _expand_spatial_bounds_to_fit_axes(bounds, ax_width, ax_height):
"""
Parameters
----------
bounds: dict
ax_width: float
ax_height: float
Returns
-------
spatial_bounds
"""
b = bounds
height_meters = util.wgs84_distance(b['lat_min'], b['lon_min'], b['lat_max'], b['lon... | def _expand_spatial_bounds_to_fit_axes(bounds, ax_width, ax_height):
"""
Parameters
----------
bounds: dict
ax_width: float
ax_height: float
Returns
-------
spatial_bounds
"""
b = bounds
height_meters = util.wgs84_distance(b['lat_min'], b['lon_min'], b['lat_max'], b['lon... | [
"Parameters",
"----------",
"bounds",
":",
"dict",
"ax_width",
":",
"float",
"ax_height",
":",
"float"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/mapviz.py#L262-L305 | [
"def",
"_expand_spatial_bounds_to_fit_axes",
"(",
"bounds",
",",
"ax_width",
",",
"ax_height",
")",
":",
"b",
"=",
"bounds",
"height_meters",
"=",
"util",
".",
"wgs84_distance",
"(",
"b",
"[",
"'lat_min'",
"]",
",",
"b",
"[",
"'lon_min'",
"]",
",",
"b",
"[... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | plot_all_stops | Parameters
----------
g: A gtfspy.gtfs.GTFS object
ax: matplotlib.Axes object, optional
If None, a new figure and an axis is created, otherwise results are plotted on the axis.
scalebar: bool, optional
Whether to include a scalebar to the plot.
Returns
-------
ax: matplotlib... | gtfspy/mapviz.py | def plot_all_stops(g, ax=None, scalebar=False):
"""
Parameters
----------
g: A gtfspy.gtfs.GTFS object
ax: matplotlib.Axes object, optional
If None, a new figure and an axis is created, otherwise results are plotted on the axis.
scalebar: bool, optional
Whether to include a scale... | def plot_all_stops(g, ax=None, scalebar=False):
"""
Parameters
----------
g: A gtfspy.gtfs.GTFS object
ax: matplotlib.Axes object, optional
If None, a new figure and an axis is created, otherwise results are plotted on the axis.
scalebar: bool, optional
Whether to include a scale... | [
"Parameters",
"----------",
"g",
":",
"A",
"gtfspy",
".",
"gtfs",
".",
"GTFS",
"object",
"ax",
":",
"matplotlib",
".",
"Axes",
"object",
"optional",
"If",
"None",
"a",
"new",
"figure",
"and",
"an",
"axis",
"is",
"created",
"otherwise",
"results",
"are",
... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/mapviz.py#L403-L435 | [
"def",
"plot_all_stops",
"(",
"g",
",",
"ax",
"=",
"None",
",",
"scalebar",
"=",
"False",
")",
":",
"assert",
"(",
"isinstance",
"(",
"g",
",",
"GTFS",
")",
")",
"lon_min",
",",
"lon_max",
",",
"lat_min",
",",
"lat_max",
"=",
"get_spatial_bounds",
"(",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | set_process_timezone | Parameters
----------
TZ: string | gtfspy/util.py | def set_process_timezone(TZ):
"""
Parameters
----------
TZ: string
"""
try:
prev_timezone = os.environ['TZ']
except KeyError:
prev_timezone = None
os.environ['TZ'] = TZ
time.tzset() # Cause C-library functions to notice the update.
return prev_timezone | def set_process_timezone(TZ):
"""
Parameters
----------
TZ: string
"""
try:
prev_timezone = os.environ['TZ']
except KeyError:
prev_timezone = None
os.environ['TZ'] = TZ
time.tzset() # Cause C-library functions to notice the update.
return prev_timezone | [
"Parameters",
"----------",
"TZ",
":",
"string"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L31-L43 | [
"def",
"set_process_timezone",
"(",
"TZ",
")",
":",
"try",
":",
"prev_timezone",
"=",
"os",
".",
"environ",
"[",
"'TZ'",
"]",
"except",
"KeyError",
":",
"prev_timezone",
"=",
"None",
"os",
".",
"environ",
"[",
"'TZ'",
"]",
"=",
"TZ",
"time",
".",
"tzse... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | wgs84_distance | Distance (in meters) between two points in WGS84 coord system. | gtfspy/util.py | def wgs84_distance(lat1, lon1, lat2, lon2):
"""Distance (in meters) between two points in WGS84 coord system."""
dLat = math.radians(lat2 - lat1)
dLon = math.radians(lon2 - lon1)
a = (math.sin(dLat / 2) * math.sin(dLat / 2) +
math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) *
... | def wgs84_distance(lat1, lon1, lat2, lon2):
"""Distance (in meters) between two points in WGS84 coord system."""
dLat = math.radians(lat2 - lat1)
dLon = math.radians(lon2 - lon1)
a = (math.sin(dLat / 2) * math.sin(dLat / 2) +
math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) *
... | [
"Distance",
"(",
"in",
"meters",
")",
"between",
"two",
"points",
"in",
"WGS84",
"coord",
"system",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L46-L55 | [
"def",
"wgs84_distance",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"dLat",
"=",
"math",
".",
"radians",
"(",
"lat2",
"-",
"lat1",
")",
"dLon",
"=",
"math",
".",
"radians",
"(",
"lon2",
"-",
"lon1",
")",
"a",
"=",
"(",
"math",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | create_file | Context manager for making files with possibility of failure.
If you are creating a file, it is possible that the code will fail
and leave a corrupt intermediate file. This is especially damaging
if this is used as automatic input to another process. This context
manager helps by creating a temporary... | gtfspy/util.py | def create_file(fname=None, fname_tmp=None, tmpdir=None,
save_tmpfile=False, keepext=False):
"""Context manager for making files with possibility of failure.
If you are creating a file, it is possible that the code will fail
and leave a corrupt intermediate file. This is especially damagin... | def create_file(fname=None, fname_tmp=None, tmpdir=None,
save_tmpfile=False, keepext=False):
"""Context manager for making files with possibility of failure.
If you are creating a file, it is possible that the code will fail
and leave a corrupt intermediate file. This is especially damagin... | [
"Context",
"manager",
"for",
"making",
"files",
"with",
"possibility",
"of",
"failure",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L80-L173 | [
"def",
"create_file",
"(",
"fname",
"=",
"None",
",",
"fname_tmp",
"=",
"None",
",",
"tmpdir",
"=",
"None",
",",
"save_tmpfile",
"=",
"False",
",",
"keepext",
"=",
"False",
")",
":",
"# Do nothing if requesting sqlite memory DB.",
"if",
"fname",
"==",
"':memor... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | execute | Utility function to print sqlite queries before executing.
Use instead of cur.execute(). First argument is cursor.
cur.execute(stmt)
becomes
util.execute(cur, stmt) | gtfspy/util.py | def execute(cur, *args):
"""Utility function to print sqlite queries before executing.
Use instead of cur.execute(). First argument is cursor.
cur.execute(stmt)
becomes
util.execute(cur, stmt)
"""
stmt = args[0]
if len(args) > 1:
stmt = stmt.replace('%', '%%').replace('?', '%r... | def execute(cur, *args):
"""Utility function to print sqlite queries before executing.
Use instead of cur.execute(). First argument is cursor.
cur.execute(stmt)
becomes
util.execute(cur, stmt)
"""
stmt = args[0]
if len(args) > 1:
stmt = stmt.replace('%', '%%').replace('?', '%r... | [
"Utility",
"function",
"to",
"print",
"sqlite",
"queries",
"before",
"executing",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L176-L189 | [
"def",
"execute",
"(",
"cur",
",",
"*",
"args",
")",
":",
"stmt",
"=",
"args",
"[",
"0",
"]",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"stmt",
"=",
"stmt",
".",
"replace",
"(",
"'%'",
",",
"'%%'",
")",
".",
"replace",
"(",
"'?'",
",",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | str_time_to_day_seconds | Converts time strings to integer seconds
:param time: %H:%M:%S string
:return: integer seconds | gtfspy/util.py | def str_time_to_day_seconds(time):
"""
Converts time strings to integer seconds
:param time: %H:%M:%S string
:return: integer seconds
"""
t = str(time).split(':')
seconds = int(t[0]) * 3600 + int(t[1]) * 60 + int(t[2])
return seconds | def str_time_to_day_seconds(time):
"""
Converts time strings to integer seconds
:param time: %H:%M:%S string
:return: integer seconds
"""
t = str(time).split(':')
seconds = int(t[0]) * 3600 + int(t[1]) * 60 + int(t[2])
return seconds | [
"Converts",
"time",
"strings",
"to",
"integer",
"seconds",
":",
"param",
"time",
":",
"%H",
":",
"%M",
":",
"%S",
"string",
":",
"return",
":",
"integer",
"seconds"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L204-L212 | [
"def",
"str_time_to_day_seconds",
"(",
"time",
")",
":",
"t",
"=",
"str",
"(",
"time",
")",
".",
"split",
"(",
"':'",
")",
"seconds",
"=",
"int",
"(",
"t",
"[",
"0",
"]",
")",
"*",
"3600",
"+",
"int",
"(",
"t",
"[",
"1",
"]",
")",
"*",
"60",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | makedirs | Create directories if they do not exist, otherwise do nothing.
Return path for convenience | gtfspy/util.py | def makedirs(path):
"""
Create directories if they do not exist, otherwise do nothing.
Return path for convenience
"""
if not os.path.isdir(path):
os.makedirs(path)
return path | def makedirs(path):
"""
Create directories if they do not exist, otherwise do nothing.
Return path for convenience
"""
if not os.path.isdir(path):
os.makedirs(path)
return path | [
"Create",
"directories",
"if",
"they",
"do",
"not",
"exist",
"otherwise",
"do",
"nothing",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L223-L231 | [
"def",
"makedirs",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"return",
"path"
] | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | source_csv_to_pandas | Parameters
----------
path: str
path to directory or zipfile
table: str
name of table
read_csv_args:
string arguments passed to the read_csv function
Returns
-------
df: pandas:DataFrame | gtfspy/util.py | def source_csv_to_pandas(path, table, read_csv_args=None):
"""
Parameters
----------
path: str
path to directory or zipfile
table: str
name of table
read_csv_args:
string arguments passed to the read_csv function
Returns
-------
df: pandas:DataFrame
"""
... | def source_csv_to_pandas(path, table, read_csv_args=None):
"""
Parameters
----------
path: str
path to directory or zipfile
table: str
name of table
read_csv_args:
string arguments passed to the read_csv function
Returns
-------
df: pandas:DataFrame
"""
... | [
"Parameters",
"----------",
"path",
":",
"str",
"path",
"to",
"directory",
"or",
"zipfile",
"table",
":",
"str",
"name",
"of",
"table",
"read_csv_args",
":",
"string",
"arguments",
"passed",
"to",
"the",
"read_csv",
"function"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L265-L306 | [
"def",
"source_csv_to_pandas",
"(",
"path",
",",
"table",
",",
"read_csv_args",
"=",
"None",
")",
":",
"if",
"'.txt'",
"not",
"in",
"table",
":",
"table",
"+=",
"'.txt'",
"if",
"isinstance",
"(",
"path",
",",
"dict",
")",
":",
"data_obj",
"=",
"path",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | write_shapefile | :param data: list of dicts where dictionary contains the keys lons and lats
:param shapefile_path: path where shapefile is saved
:return: | gtfspy/util.py | def write_shapefile(data, shapefile_path):
from numpy import int64
"""
:param data: list of dicts where dictionary contains the keys lons and lats
:param shapefile_path: path where shapefile is saved
:return:
"""
w = shp.Writer(shp.POLYLINE) # shapeType=3)
fields = []
encode_strin... | def write_shapefile(data, shapefile_path):
from numpy import int64
"""
:param data: list of dicts where dictionary contains the keys lons and lats
:param shapefile_path: path where shapefile is saved
:return:
"""
w = shp.Writer(shp.POLYLINE) # shapeType=3)
fields = []
encode_strin... | [
":",
"param",
"data",
":",
"list",
"of",
"dicts",
"where",
"dictionary",
"contains",
"the",
"keys",
"lons",
"and",
"lats",
":",
"param",
"shapefile_path",
":",
"path",
"where",
"shapefile",
"is",
"saved",
":",
"return",
":"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L309-L365 | [
"def",
"write_shapefile",
"(",
"data",
",",
"shapefile_path",
")",
":",
"from",
"numpy",
"import",
"int64",
"w",
"=",
"shp",
".",
"Writer",
"(",
"shp",
".",
"POLYLINE",
")",
"# shapeType=3)",
"fields",
"=",
"[",
"]",
"encode_strings",
"=",
"[",
"]",
"# T... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | draw_net_using_node_coords | Plot a networkx.Graph by using the lat and lon attributes of nodes.
Parameters
----------
net : networkx.Graph
Returns
-------
fig : matplotlib.figure
the figure object where the network is plotted | gtfspy/util.py | def draw_net_using_node_coords(net):
"""
Plot a networkx.Graph by using the lat and lon attributes of nodes.
Parameters
----------
net : networkx.Graph
Returns
-------
fig : matplotlib.figure
the figure object where the network is plotted
"""
import matplotlib.pyplot as p... | def draw_net_using_node_coords(net):
"""
Plot a networkx.Graph by using the lat and lon attributes of nodes.
Parameters
----------
net : networkx.Graph
Returns
-------
fig : matplotlib.figure
the figure object where the network is plotted
"""
import matplotlib.pyplot as p... | [
"Plot",
"a",
"networkx",
".",
"Graph",
"by",
"using",
"the",
"lat",
"and",
"lon",
"attributes",
"of",
"nodes",
".",
"Parameters",
"----------",
"net",
":",
"networkx",
".",
"Graph",
"Returns",
"-------",
"fig",
":",
"matplotlib",
".",
"figure",
"the",
"fig... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L376-L394 | [
"def",
"draw_net_using_node_coords",
"(",
"net",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"node_coords",
"=",
"{",
"}",
"for",
"node",
",",
"data",
"in",
"net",
".",
"nodes",
"(",
"data",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | difference_of_pandas_dfs | Returns a dataframe with all of df_other that are not in df_self, when considering the columns specified in col_names
:param df_self: pandas Dataframe
:param df_other: pandas Dataframe
:param col_names: list of column names
:return: | gtfspy/util.py | def difference_of_pandas_dfs(df_self, df_other, col_names=None):
"""
Returns a dataframe with all of df_other that are not in df_self, when considering the columns specified in col_names
:param df_self: pandas Dataframe
:param df_other: pandas Dataframe
:param col_names: list of column names
:re... | def difference_of_pandas_dfs(df_self, df_other, col_names=None):
"""
Returns a dataframe with all of df_other that are not in df_self, when considering the columns specified in col_names
:param df_self: pandas Dataframe
:param df_other: pandas Dataframe
:param col_names: list of column names
:re... | [
"Returns",
"a",
"dataframe",
"with",
"all",
"of",
"df_other",
"that",
"are",
"not",
"in",
"df_self",
"when",
"considering",
"the",
"columns",
"specified",
"in",
"col_names",
":",
"param",
"df_self",
":",
"pandas",
"Dataframe",
":",
"param",
"df_other",
":",
... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/util.py#L406-L424 | [
"def",
"difference_of_pandas_dfs",
"(",
"df_self",
",",
"df_other",
",",
"col_names",
"=",
"None",
")",
":",
"df",
"=",
"pd",
".",
"concat",
"(",
"[",
"df_self",
",",
"df_other",
"]",
")",
"df",
"=",
"df",
".",
"reset_index",
"(",
"drop",
"=",
"True",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | MultiObjectivePseudoCSAProfiler._finalize_profiles | Deal with the first walks by joining profiles to other stops within walking distance. | gtfspy/routing/multi_objective_pseudo_connection_scan_profiler.py | def _finalize_profiles(self):
"""
Deal with the first walks by joining profiles to other stops within walking distance.
"""
for stop, stop_profile in self._stop_profiles.items():
assert (isinstance(stop_profile, NodeProfileMultiObjective))
neighbor_label_bags = []... | def _finalize_profiles(self):
"""
Deal with the first walks by joining profiles to other stops within walking distance.
"""
for stop, stop_profile in self._stop_profiles.items():
assert (isinstance(stop_profile, NodeProfileMultiObjective))
neighbor_label_bags = []... | [
"Deal",
"with",
"the",
"first",
"walks",
"by",
"joining",
"profiles",
"to",
"other",
"stops",
"within",
"walking",
"distance",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/multi_objective_pseudo_connection_scan_profiler.py#L288-L307 | [
"def",
"_finalize_profiles",
"(",
"self",
")",
":",
"for",
"stop",
",",
"stop_profile",
"in",
"self",
".",
"_stop_profiles",
".",
"items",
"(",
")",
":",
"assert",
"(",
"isinstance",
"(",
"stop_profile",
",",
"NodeProfileMultiObjective",
")",
")",
"neighbor_la... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | import_gtfs | Import a GTFS database
gtfs_sources: str, dict, list
Paths to the gtfs zip file or to the directory containing the GTFS data.
Alternatively, a dict can be provide that maps gtfs filenames
(like 'stops.txt' and 'agencies.txt') to their string presentations.
output: str or sqlite3.Connec... | gtfspy/import_gtfs.py | def import_gtfs(gtfs_sources, output, preserve_connection=False,
print_progress=True, location_name=None, **kwargs):
"""Import a GTFS database
gtfs_sources: str, dict, list
Paths to the gtfs zip file or to the directory containing the GTFS data.
Alternatively, a dict can be prov... | def import_gtfs(gtfs_sources, output, preserve_connection=False,
print_progress=True, location_name=None, **kwargs):
"""Import a GTFS database
gtfs_sources: str, dict, list
Paths to the gtfs zip file or to the directory containing the GTFS data.
Alternatively, a dict can be prov... | [
"Import",
"a",
"GTFS",
"database"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_gtfs.py#L49-L175 | [
"def",
"import_gtfs",
"(",
"gtfs_sources",
",",
"output",
",",
"preserve_connection",
"=",
"False",
",",
"print_progress",
"=",
"True",
",",
"location_name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"output",
",",
"sqlite3",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | validate_day_start_ut | This validates the day_start_ut of the days table. | gtfspy/import_gtfs.py | def validate_day_start_ut(conn):
"""This validates the day_start_ut of the days table."""
G = GTFS(conn)
cur = conn.execute('SELECT date, day_start_ut FROM days')
for date, day_start_ut in cur:
#print date, day_start_ut
assert day_start_ut == G.get_day_start_ut(date) | def validate_day_start_ut(conn):
"""This validates the day_start_ut of the days table."""
G = GTFS(conn)
cur = conn.execute('SELECT date, day_start_ut FROM days')
for date, day_start_ut in cur:
#print date, day_start_ut
assert day_start_ut == G.get_day_start_ut(date) | [
"This",
"validates",
"the",
"day_start_ut",
"of",
"the",
"days",
"table",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_gtfs.py#L177-L183 | [
"def",
"validate_day_start_ut",
"(",
"conn",
")",
":",
"G",
"=",
"GTFS",
"(",
"conn",
")",
"cur",
"=",
"conn",
".",
"execute",
"(",
"'SELECT date, day_start_ut FROM days'",
")",
"for",
"date",
",",
"day_start_ut",
"in",
"cur",
":",
"#print date, day_start_ut",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | main_make_views | Re-create all views. | gtfspy/import_gtfs.py | def main_make_views(gtfs_fname):
"""Re-create all views.
"""
print("creating views")
conn = GTFS(fname_or_conn=gtfs_fname).conn
for L in Loaders:
L(None).make_views(conn)
conn.commit() | def main_make_views(gtfs_fname):
"""Re-create all views.
"""
print("creating views")
conn = GTFS(fname_or_conn=gtfs_fname).conn
for L in Loaders:
L(None).make_views(conn)
conn.commit() | [
"Re",
"-",
"create",
"all",
"views",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_gtfs.py#L186-L193 | [
"def",
"main_make_views",
"(",
"gtfs_fname",
")",
":",
"print",
"(",
"\"creating views\"",
")",
"conn",
"=",
"GTFS",
"(",
"fname_or_conn",
"=",
"gtfs_fname",
")",
".",
"conn",
"for",
"L",
"in",
"Loaders",
":",
"L",
"(",
"None",
")",
".",
"make_views",
"(... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ImportValidator._validate_table_row_counts | Imports source .txt files, checks row counts and then compares the rowcounts with the gtfsobject
:return: | gtfspy/import_validator.py | def _validate_table_row_counts(self):
"""
Imports source .txt files, checks row counts and then compares the rowcounts with the gtfsobject
:return:
"""
for db_table_name in DB_TABLE_NAME_TO_SOURCE_FILE.keys():
table_name_source_file = DB_TABLE_NAME_TO_SOURCE_FILE[db_t... | def _validate_table_row_counts(self):
"""
Imports source .txt files, checks row counts and then compares the rowcounts with the gtfsobject
:return:
"""
for db_table_name in DB_TABLE_NAME_TO_SOURCE_FILE.keys():
table_name_source_file = DB_TABLE_NAME_TO_SOURCE_FILE[db_t... | [
"Imports",
"source",
".",
"txt",
"files",
"checks",
"row",
"counts",
"and",
"then",
"compares",
"the",
"rowcounts",
"with",
"the",
"gtfsobject",
":",
"return",
":"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L151-L204 | [
"def",
"_validate_table_row_counts",
"(",
"self",
")",
":",
"for",
"db_table_name",
"in",
"DB_TABLE_NAME_TO_SOURCE_FILE",
".",
"keys",
"(",
")",
":",
"table_name_source_file",
"=",
"DB_TABLE_NAME_TO_SOURCE_FILE",
"[",
"db_table_name",
"]",
"row_warning_str",
"=",
"DB_TA... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ImportValidator._validate_no_null_values | Loads the tables from the gtfs object and counts the number of rows that have null values in
fields that should not be null. Stores the number of null rows in warnings_container | gtfspy/import_validator.py | def _validate_no_null_values(self):
"""
Loads the tables from the gtfs object and counts the number of rows that have null values in
fields that should not be null. Stores the number of null rows in warnings_container
"""
for table in DB_TABLE_NAMES:
null_not_ok_warni... | def _validate_no_null_values(self):
"""
Loads the tables from the gtfs object and counts the number of rows that have null values in
fields that should not be null. Stores the number of null rows in warnings_container
"""
for table in DB_TABLE_NAMES:
null_not_ok_warni... | [
"Loads",
"the",
"tables",
"from",
"the",
"gtfs",
"object",
"and",
"counts",
"the",
"number",
"of",
"rows",
"that",
"have",
"null",
"values",
"in",
"fields",
"that",
"should",
"not",
"be",
"null",
".",
"Stores",
"the",
"number",
"of",
"null",
"rows",
"in"... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L207-L226 | [
"def",
"_validate_no_null_values",
"(",
"self",
")",
":",
"for",
"table",
"in",
"DB_TABLE_NAMES",
":",
"null_not_ok_warning",
"=",
"\"Null values in must-have columns in table {table}\"",
".",
"format",
"(",
"table",
"=",
"table",
")",
"null_warn_warning",
"=",
"\"Null ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ImportValidator._validate_danglers | Checks for rows that are not referenced in the the tables that should be linked
stops <> stop_times using stop_I
stop_times <> trips <> days, using trip_I
trips <> routes, using route_I
:return: | gtfspy/import_validator.py | def _validate_danglers(self):
"""
Checks for rows that are not referenced in the the tables that should be linked
stops <> stop_times using stop_I
stop_times <> trips <> days, using trip_I
trips <> routes, using route_I
:return:
"""
for query, warning in ... | def _validate_danglers(self):
"""
Checks for rows that are not referenced in the the tables that should be linked
stops <> stop_times using stop_I
stop_times <> trips <> days, using trip_I
trips <> routes, using route_I
:return:
"""
for query, warning in ... | [
"Checks",
"for",
"rows",
"that",
"are",
"not",
"referenced",
"in",
"the",
"the",
"tables",
"that",
"should",
"be",
"linked"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L229-L243 | [
"def",
"_validate_danglers",
"(",
"self",
")",
":",
"for",
"query",
",",
"warning",
"in",
"zip",
"(",
"DANGLER_QUERIES",
",",
"DANGLER_WARNINGS",
")",
":",
"dangler_count",
"=",
"self",
".",
"gtfs",
".",
"execute_custom_query",
"(",
"query",
")",
".",
"fetch... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ImportValidator._frequency_generated_trips_rows | This function calculates the equivalent rowcounts for trips when
taking into account the generated rows in the gtfs object
Parameters
----------
gtfs_soure_path: path to the source file
param txt: txt file in question
:return: sum of all trips | gtfspy/import_validator.py | def _frequency_generated_trips_rows(self, gtfs_soure_path, return_df_freq=False):
"""
This function calculates the equivalent rowcounts for trips when
taking into account the generated rows in the gtfs object
Parameters
----------
gtfs_soure_path: path to the source file
... | def _frequency_generated_trips_rows(self, gtfs_soure_path, return_df_freq=False):
"""
This function calculates the equivalent rowcounts for trips when
taking into account the generated rows in the gtfs object
Parameters
----------
gtfs_soure_path: path to the source file
... | [
"This",
"function",
"calculates",
"the",
"equivalent",
"rowcounts",
"for",
"trips",
"when",
"taking",
"into",
"account",
"the",
"generated",
"rows",
"in",
"the",
"gtfs",
"object",
"Parameters",
"----------",
"gtfs_soure_path",
":",
"path",
"to",
"the",
"source",
... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L245-L265 | [
"def",
"_frequency_generated_trips_rows",
"(",
"self",
",",
"gtfs_soure_path",
",",
"return_df_freq",
"=",
"False",
")",
":",
"df_freq",
"=",
"source_csv_to_pandas",
"(",
"gtfs_soure_path",
",",
"'frequencies'",
")",
"df_trips",
"=",
"source_csv_to_pandas",
"(",
"gtfs... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ImportValidator._compute_number_of_frequency_generated_stop_times | Parameters
----------
Same as for "_frequency_generated_trips_rows" but for stop times table
gtfs_source_path:
table_name:
Return
------ | gtfspy/import_validator.py | def _compute_number_of_frequency_generated_stop_times(self, gtfs_source_path):
"""
Parameters
----------
Same as for "_frequency_generated_trips_rows" but for stop times table
gtfs_source_path:
table_name:
Return
------
"""
df_freq = self.... | def _compute_number_of_frequency_generated_stop_times(self, gtfs_source_path):
"""
Parameters
----------
Same as for "_frequency_generated_trips_rows" but for stop times table
gtfs_source_path:
table_name:
Return
------
"""
df_freq = self.... | [
"Parameters",
"----------",
"Same",
"as",
"for",
"_frequency_generated_trips_rows",
"but",
"for",
"stop",
"times",
"table",
"gtfs_source_path",
":",
"table_name",
":"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L267-L281 | [
"def",
"_compute_number_of_frequency_generated_stop_times",
"(",
"self",
",",
"gtfs_source_path",
")",
":",
"df_freq",
"=",
"self",
".",
"_frequency_generated_trips_rows",
"(",
"gtfs_source_path",
",",
"return_df_freq",
"=",
"True",
")",
"df_stop_times",
"=",
"source_csv_... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileC.update_pareto_optimal_tuples | Parameters
----------
new_label: LabelTime
Returns
-------
updated: bool | gtfspy/routing/node_profile_c.py | def update_pareto_optimal_tuples(self, new_label):
"""
Parameters
----------
new_label: LabelTime
Returns
-------
updated: bool
"""
assert (isinstance(new_label, LabelTime))
if self._labels:
assert (new_label.departure_time <= ... | def update_pareto_optimal_tuples(self, new_label):
"""
Parameters
----------
new_label: LabelTime
Returns
-------
updated: bool
"""
assert (isinstance(new_label, LabelTime))
if self._labels:
assert (new_label.departure_time <= ... | [
"Parameters",
"----------",
"new_label",
":",
"LabelTime"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_c.py#L19-L48 | [
"def",
"update_pareto_optimal_tuples",
"(",
"self",
",",
"new_label",
")",
":",
"assert",
"(",
"isinstance",
"(",
"new_label",
",",
"LabelTime",
")",
")",
"if",
"self",
".",
"_labels",
":",
"assert",
"(",
"new_label",
".",
"departure_time",
"<=",
"self",
"."... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | print_coords | Print coordinates within a sequence.
This is only used for debugging. Printed in a form that can be
pasted into Python for visualization. | gtfspy/shapes.py | def print_coords(rows, prefix=''):
"""Print coordinates within a sequence.
This is only used for debugging. Printed in a form that can be
pasted into Python for visualization."""
lat = [row['lat'] for row in rows]
lon = [row['lon'] for row in rows]
print('COORDS'+'-' * 5)
print("%slat, %sl... | def print_coords(rows, prefix=''):
"""Print coordinates within a sequence.
This is only used for debugging. Printed in a form that can be
pasted into Python for visualization."""
lat = [row['lat'] for row in rows]
lon = [row['lon'] for row in rows]
print('COORDS'+'-' * 5)
print("%slat, %sl... | [
"Print",
"coordinates",
"within",
"a",
"sequence",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L37-L46 | [
"def",
"print_coords",
"(",
"rows",
",",
"prefix",
"=",
"''",
")",
":",
"lat",
"=",
"[",
"row",
"[",
"'lat'",
"]",
"for",
"row",
"in",
"rows",
"]",
"lon",
"=",
"[",
"row",
"[",
"'lon'",
"]",
"for",
"row",
"in",
"rows",
"]",
"print",
"(",
"'COOR... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | find_segments | Find corresponding shape points for a list of stops and create shape break points.
Parameters
----------
stops: stop-sequence (list)
List of stop points
shape: list of shape points
shape-sequence of shape points
Returns
-------
break_points: list[int]
stops[i] corre... | gtfspy/shapes.py | def find_segments(stops, shape):
"""Find corresponding shape points for a list of stops and create shape break points.
Parameters
----------
stops: stop-sequence (list)
List of stop points
shape: list of shape points
shape-sequence of shape points
Returns
-------
break_... | def find_segments(stops, shape):
"""Find corresponding shape points for a list of stops and create shape break points.
Parameters
----------
stops: stop-sequence (list)
List of stop points
shape: list of shape points
shape-sequence of shape points
Returns
-------
break_... | [
"Find",
"corresponding",
"shape",
"points",
"for",
"a",
"list",
"of",
"stops",
"and",
"create",
"shape",
"break",
"points",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L49-L123 | [
"def",
"find_segments",
"(",
"stops",
",",
"shape",
")",
":",
"if",
"not",
"shape",
":",
"return",
"[",
"]",
",",
"0",
"break_points",
"=",
"[",
"]",
"last_i",
"=",
"0",
"cumul_d",
"=",
"0",
"badness",
"=",
"0",
"d_last_stop",
"=",
"float",
"(",
"'... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | find_best_segments | Finds the best shape_id for a stop-sequence.
This is used in cases like when you have GPS data with a route
name, but you don't know the route direction. It tries shapes
going both directions and returns the shape that best matches.
Could be used in other cases as well.
Parameters
----------
... | gtfspy/shapes.py | def find_best_segments(cur, stops, shape_ids, route_id=None,
breakpoints_cache=None):
"""Finds the best shape_id for a stop-sequence.
This is used in cases like when you have GPS data with a route
name, but you don't know the route direction. It tries shapes
going both direction... | def find_best_segments(cur, stops, shape_ids, route_id=None,
breakpoints_cache=None):
"""Finds the best shape_id for a stop-sequence.
This is used in cases like when you have GPS data with a route
name, but you don't know the route direction. It tries shapes
going both direction... | [
"Finds",
"the",
"best",
"shape_id",
"for",
"a",
"stop",
"-",
"sequence",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L126-L188 | [
"def",
"find_best_segments",
"(",
"cur",
",",
"stops",
",",
"shape_ids",
",",
"route_id",
"=",
"None",
",",
"breakpoints_cache",
"=",
"None",
")",
":",
"cache_key",
"=",
"None",
"if",
"breakpoints_cache",
"is",
"not",
"None",
":",
"# Calculate a cache key for th... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | return_segments | Break a shape into segments between stops using break_points.
This function can use the `break_points` outputs from
`find_segments`, and cuts the shape-sequence into pieces
corresponding to each stop. | gtfspy/shapes.py | def return_segments(shape, break_points):
"""Break a shape into segments between stops using break_points.
This function can use the `break_points` outputs from
`find_segments`, and cuts the shape-sequence into pieces
corresponding to each stop.
"""
# print 'xxx'
# print stops
# print s... | def return_segments(shape, break_points):
"""Break a shape into segments between stops using break_points.
This function can use the `break_points` outputs from
`find_segments`, and cuts the shape-sequence into pieces
corresponding to each stop.
"""
# print 'xxx'
# print stops
# print s... | [
"Break",
"a",
"shape",
"into",
"segments",
"between",
"stops",
"using",
"break_points",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L191-L211 | [
"def",
"return_segments",
"(",
"shape",
",",
"break_points",
")",
":",
"# print 'xxx'",
"# print stops",
"# print shape",
"# print break_points",
"# assert len(stops) == len(break_points)",
"segs",
"=",
"[",
"]",
"bp",
"=",
"0",
"# not used",
"bp2",
"=",
"0",
"for",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | gen_cumulative_distances | Add a 'd' key for distances to a stop/shape-sequence.
This takes a shape-sequence or stop-sequence, and adds an extra
'd' key that is cumulative, geographic distances between each
point. This uses `wgs84_distance` from the util module. The
distances are in meters. Distances are rounded to the nearest... | gtfspy/shapes.py | def gen_cumulative_distances(stops):
"""
Add a 'd' key for distances to a stop/shape-sequence.
This takes a shape-sequence or stop-sequence, and adds an extra
'd' key that is cumulative, geographic distances between each
point. This uses `wgs84_distance` from the util module. The
distances are... | def gen_cumulative_distances(stops):
"""
Add a 'd' key for distances to a stop/shape-sequence.
This takes a shape-sequence or stop-sequence, and adds an extra
'd' key that is cumulative, geographic distances between each
point. This uses `wgs84_distance` from the util module. The
distances are... | [
"Add",
"a",
"d",
"key",
"for",
"distances",
"to",
"a",
"stop",
"/",
"shape",
"-",
"sequence",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L214-L238 | [
"def",
"gen_cumulative_distances",
"(",
"stops",
")",
":",
"stops",
"[",
"0",
"]",
"[",
"'d'",
"]",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"stops",
")",
")",
":",
"stops",
"[",
"i",
"]",
"[",
"'d'",
"]",
"=",
"stops",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | get_shape_points | Given a shape_id, return its shape-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries containing the 'seq', 'lat', and 'lon' of the shape | gtfspy/shapes.py | def get_shape_points(cur, shape_id):
"""
Given a shape_id, return its shape-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries containing th... | def get_shape_points(cur, shape_id):
"""
Given a shape_id, return its shape-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries containing th... | [
"Given",
"a",
"shape_id",
"return",
"its",
"shape",
"-",
"sequence",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L242-L262 | [
"def",
"get_shape_points",
"(",
"cur",
",",
"shape_id",
")",
":",
"cur",
".",
"execute",
"(",
"'''SELECT seq, lat, lon, d FROM shapes where shape_id=?\n ORDER BY seq'''",
",",
"(",
"shape_id",
",",
")",
")",
"shape_points",
"=",
"[",
"dict",
"(",
"s... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | get_shape_points2 | Given a shape_id, return its shape-sequence (as a dict of lists).
get_shape_points function returns them as a list of dicts
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Returns
-------
shape_points: dict of lists
... | gtfspy/shapes.py | def get_shape_points2(cur, shape_id):
"""
Given a shape_id, return its shape-sequence (as a dict of lists).
get_shape_points function returns them as a list of dicts
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Return... | def get_shape_points2(cur, shape_id):
"""
Given a shape_id, return its shape-sequence (as a dict of lists).
get_shape_points function returns them as a list of dicts
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
shape_id: str
id of the route
Return... | [
"Given",
"a",
"shape_id",
"return",
"its",
"shape",
"-",
"sequence",
"(",
"as",
"a",
"dict",
"of",
"lists",
")",
".",
"get_shape_points",
"function",
"returns",
"them",
"as",
"a",
"list",
"of",
"dicts"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L265-L290 | [
"def",
"get_shape_points2",
"(",
"cur",
",",
"shape_id",
")",
":",
"cur",
".",
"execute",
"(",
"'''SELECT seq, lat, lon, d FROM shapes where shape_id=?\n ORDER BY seq'''",
",",
"(",
"shape_id",
",",
")",
")",
"shape_points",
"=",
"{",
"'seqs'",
":",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | get_route_shape_segments | Given a route_id, return its stop-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
route_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries containing the 'seq', 'lat', and 'lon' of the shape | gtfspy/shapes.py | def get_route_shape_segments(cur, route_id):
"""
Given a route_id, return its stop-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
route_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries contai... | def get_route_shape_segments(cur, route_id):
"""
Given a route_id, return its stop-sequence.
Parameters
----------
cur: sqlite3.Cursor
cursor to a GTFS database
route_id: str
id of the route
Returns
-------
shape_points: list
elements are dictionaries contai... | [
"Given",
"a",
"route_id",
"return",
"its",
"stop",
"-",
"sequence",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L293-L321 | [
"def",
"get_route_shape_segments",
"(",
"cur",
",",
"route_id",
")",
":",
"cur",
".",
"execute",
"(",
"'''SELECT seq, lat, lon\n FROM (\n SELECT shape_id\n FROM route\n LEFT JOIN trips\n ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | get_shape_between_stops | Given a trip_I (shortened id), return shape points between two stops
(seq_stop1 and seq_stop2).
Trip_I is used for matching obtaining the full shape of one trip (route).
From the resulting shape we then obtain only shape points between
stop_seq1 and stop_seq2
trip_I---(trips)--->shape_id
trip_I... | gtfspy/shapes.py | def get_shape_between_stops(cur, trip_I, seq_stop1=None, seq_stop2=None, shape_breaks=None):
"""
Given a trip_I (shortened id), return shape points between two stops
(seq_stop1 and seq_stop2).
Trip_I is used for matching obtaining the full shape of one trip (route).
From the resulting shape we then... | def get_shape_between_stops(cur, trip_I, seq_stop1=None, seq_stop2=None, shape_breaks=None):
"""
Given a trip_I (shortened id), return shape points between two stops
(seq_stop1 and seq_stop2).
Trip_I is used for matching obtaining the full shape of one trip (route).
From the resulting shape we then... | [
"Given",
"a",
"trip_I",
"(",
"shortened",
"id",
")",
"return",
"shape",
"points",
"between",
"two",
"stops",
"(",
"seq_stop1",
"and",
"seq_stop2",
")",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L324-L381 | [
"def",
"get_shape_between_stops",
"(",
"cur",
",",
"trip_I",
",",
"seq_stop1",
"=",
"None",
",",
"seq_stop2",
"=",
"None",
",",
"shape_breaks",
"=",
"None",
")",
":",
"assert",
"(",
"seq_stop1",
"and",
"seq_stop2",
")",
"or",
"shape_breaks",
"if",
"not",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | get_trip_points | Get all scheduled stops on a particular route_id.
Given a route_id, return the trip-stop-list with
latitude/longitudes. This is a bit more tricky than it seems,
because we have to go from table route->trips->stop_times. This
functions finds an arbitrary trip (in trip table) with this route ID
and... | gtfspy/shapes.py | def get_trip_points(cur, route_id, offset=0, tripid_glob=''):
"""Get all scheduled stops on a particular route_id.
Given a route_id, return the trip-stop-list with
latitude/longitudes. This is a bit more tricky than it seems,
because we have to go from table route->trips->stop_times. This
functio... | def get_trip_points(cur, route_id, offset=0, tripid_glob=''):
"""Get all scheduled stops on a particular route_id.
Given a route_id, return the trip-stop-list with
latitude/longitudes. This is a bit more tricky than it seems,
because we have to go from table route->trips->stop_times. This
functio... | [
"Get",
"all",
"scheduled",
"stops",
"on",
"a",
"particular",
"route_id",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L384-L421 | [
"def",
"get_trip_points",
"(",
"cur",
",",
"route_id",
",",
"offset",
"=",
"0",
",",
"tripid_glob",
"=",
"''",
")",
":",
"extra_where",
"=",
"''",
"if",
"tripid_glob",
":",
"extra_where",
"=",
"\"AND trip_id GLOB '%s'\"",
"%",
"tripid_glob",
"cur",
".",
"exe... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | interpolate_shape_times | Interpolate passage times for shape points.
Parameters
----------
shape_distances: list
list of cumulative distances along the shape
shape_breaks: list
list of shape_breaks
stop_times: list
list of stop_times
Returns
-------
shape_times: list of ints (seconds) /... | gtfspy/shapes.py | def interpolate_shape_times(shape_distances, shape_breaks, stop_times):
"""
Interpolate passage times for shape points.
Parameters
----------
shape_distances: list
list of cumulative distances along the shape
shape_breaks: list
list of shape_breaks
stop_times: list
l... | def interpolate_shape_times(shape_distances, shape_breaks, stop_times):
"""
Interpolate passage times for shape points.
Parameters
----------
shape_distances: list
list of cumulative distances along the shape
shape_breaks: list
list of shape_breaks
stop_times: list
l... | [
"Interpolate",
"passage",
"times",
"for",
"shape",
"points",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L424-L463 | [
"def",
"interpolate_shape_times",
"(",
"shape_distances",
",",
"shape_breaks",
",",
"stop_times",
")",
":",
"shape_times",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"shape_distances",
")",
")",
"shape_times",
"[",
":",
"shape_breaks",
"[",
"0",
"]",
"]",
"="... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileSimple.update_pareto_optimal_tuples | # this function should be optimized
Parameters
----------
new_pareto_tuple: LabelTimeSimple
Returns
-------
added: bool
whether new_pareto_tuple was added to the set of pareto-optimal tuples | gtfspy/routing/node_profile_simple.py | def update_pareto_optimal_tuples(self, new_pareto_tuple):
"""
# this function should be optimized
Parameters
----------
new_pareto_tuple: LabelTimeSimple
Returns
-------
added: bool
whether new_pareto_tuple was added to the set of pareto-opti... | def update_pareto_optimal_tuples(self, new_pareto_tuple):
"""
# this function should be optimized
Parameters
----------
new_pareto_tuple: LabelTimeSimple
Returns
-------
added: bool
whether new_pareto_tuple was added to the set of pareto-opti... | [
"#",
"this",
"function",
"should",
"be",
"optimized"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_simple.py#L18-L44 | [
"def",
"update_pareto_optimal_tuples",
"(",
"self",
",",
"new_pareto_tuple",
")",
":",
"if",
"new_pareto_tuple",
".",
"duration",
"(",
")",
">",
"self",
".",
"_walk_to_target_duration",
":",
"direct_walk_label",
"=",
"self",
".",
"_label_class",
".",
"direct_walk_la... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileSimple.evaluate_earliest_arrival_time_at_target | Get the earliest arrival time at the target, given a departure time.
Parameters
----------
dep_time : float, int
time in unix seconds
transfer_margin: float, int
transfer margin in seconds
Returns
-------
arrival_time : float
... | gtfspy/routing/node_profile_simple.py | def evaluate_earliest_arrival_time_at_target(self, dep_time, transfer_margin):
"""
Get the earliest arrival time at the target, given a departure time.
Parameters
----------
dep_time : float, int
time in unix seconds
transfer_margin: float, int
tr... | def evaluate_earliest_arrival_time_at_target(self, dep_time, transfer_margin):
"""
Get the earliest arrival time at the target, given a departure time.
Parameters
----------
dep_time : float, int
time in unix seconds
transfer_margin: float, int
tr... | [
"Get",
"the",
"earliest",
"arrival",
"time",
"at",
"the",
"target",
"given",
"a",
"departure",
"time",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_simple.py#L76-L97 | [
"def",
"evaluate_earliest_arrival_time_at_target",
"(",
"self",
",",
"dep_time",
",",
"transfer_margin",
")",
":",
"minimum",
"=",
"dep_time",
"+",
"self",
".",
"_walk_to_target_duration",
"dep_time_plus_transfer_margin",
"=",
"dep_time",
"+",
"transfer_margin",
"for",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | Spreader._run | Run the actual simulation. | gtfspy/spreading/spreader.py | def _run(self):
"""
Run the actual simulation.
"""
if self._has_run:
raise RuntimeError("This spreader instance has already been run: "
"create a new Spreader object for a new run.")
i = 1
while self.event_heap.size() > 0 and len... | def _run(self):
"""
Run the actual simulation.
"""
if self._has_run:
raise RuntimeError("This spreader instance has already been run: "
"create a new Spreader object for a new run.")
i = 1
while self.event_heap.size() > 0 and len... | [
"Run",
"the",
"actual",
"simulation",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/spreading/spreader.py#L107-L136 | [
"def",
"_run",
"(",
"self",
")",
":",
"if",
"self",
".",
"_has_run",
":",
"raise",
"RuntimeError",
"(",
"\"This spreader instance has already been run: \"",
"\"create a new Spreader object for a new run.\"",
")",
"i",
"=",
"1",
"while",
"self",
".",
"event_heap",
".",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | add_walk_distances_to_db_python | Computes the walk paths between stops, and updates these to the gtfs database.
Parameters
----------
gtfs: gtfspy.GTFS or str
A GTFS object or a string representation.
osm_path: str
path to the OpenStreetMap file
cutoff_distance_m: number
maximum allowed distance in meters
... | gtfspy/osm_transfers.py | def add_walk_distances_to_db_python(gtfs, osm_path, cutoff_distance_m=1000):
"""
Computes the walk paths between stops, and updates these to the gtfs database.
Parameters
----------
gtfs: gtfspy.GTFS or str
A GTFS object or a string representation.
osm_path: str
path to the Open... | def add_walk_distances_to_db_python(gtfs, osm_path, cutoff_distance_m=1000):
"""
Computes the walk paths between stops, and updates these to the gtfs database.
Parameters
----------
gtfs: gtfspy.GTFS or str
A GTFS object or a string representation.
osm_path: str
path to the Open... | [
"Computes",
"the",
"walk",
"paths",
"between",
"stops",
"and",
"updates",
"these",
"to",
"the",
"gtfs",
"database",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/osm_transfers.py#L15-L74 | [
"def",
"add_walk_distances_to_db_python",
"(",
"gtfs",
",",
"osm_path",
",",
"cutoff_distance_m",
"=",
"1000",
")",
":",
"if",
"isinstance",
"(",
"gtfs",
",",
"str",
")",
":",
"gtfs",
"=",
"GTFS",
"(",
"gtfs",
")",
"assert",
"(",
"isinstance",
"(",
"gtfs",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | match_stops_to_nodes | Parameters
----------
gtfs : a GTFS object
walk_network : networkx.Graph
Returns
-------
stop_I_to_node: dict
maps stop_I to closest walk_network node
stop_I_to_dist: dict
maps stop_I to the distance to the closest walk_network node | gtfspy/osm_transfers.py | def match_stops_to_nodes(gtfs, walk_network):
"""
Parameters
----------
gtfs : a GTFS object
walk_network : networkx.Graph
Returns
-------
stop_I_to_node: dict
maps stop_I to closest walk_network node
stop_I_to_dist: dict
maps stop_I to the distance to the closest wa... | def match_stops_to_nodes(gtfs, walk_network):
"""
Parameters
----------
gtfs : a GTFS object
walk_network : networkx.Graph
Returns
-------
stop_I_to_node: dict
maps stop_I to closest walk_network node
stop_I_to_dist: dict
maps stop_I to the distance to the closest wa... | [
"Parameters",
"----------",
"gtfs",
":",
"a",
"GTFS",
"object",
"walk_network",
":",
"networkx",
".",
"Graph"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/osm_transfers.py#L77-L119 | [
"def",
"match_stops_to_nodes",
"(",
"gtfs",
",",
"walk_network",
")",
":",
"network_nodes",
"=",
"walk_network",
".",
"nodes",
"(",
"data",
"=",
"\"true\"",
")",
"stop_Is",
"=",
"set",
"(",
"gtfs",
".",
"get_straight_line_transfer_distances",
"(",
")",
"[",
"'... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | walk_transfer_stop_to_stop_network | Construct the walk network.
If OpenStreetMap-based walking distances have been computed, then those are used as the distance.
Otherwise, the great circle distances ("d") is used.
Parameters
----------
gtfs: gtfspy.GTFS
max_link_distance: int, optional
If given, all walking transfers wit... | gtfspy/networks.py | def walk_transfer_stop_to_stop_network(gtfs, max_link_distance=None):
"""
Construct the walk network.
If OpenStreetMap-based walking distances have been computed, then those are used as the distance.
Otherwise, the great circle distances ("d") is used.
Parameters
----------
gtfs: gtfspy.GTF... | def walk_transfer_stop_to_stop_network(gtfs, max_link_distance=None):
"""
Construct the walk network.
If OpenStreetMap-based walking distances have been computed, then those are used as the distance.
Otherwise, the great circle distances ("d") is used.
Parameters
----------
gtfs: gtfspy.GTF... | [
"Construct",
"the",
"walk",
"network",
".",
"If",
"OpenStreetMap",
"-",
"based",
"walking",
"distances",
"have",
"been",
"computed",
"then",
"those",
"are",
"used",
"as",
"the",
"distance",
".",
"Otherwise",
"the",
"great",
"circle",
"distances",
"(",
"d",
"... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L20-L67 | [
"def",
"walk_transfer_stop_to_stop_network",
"(",
"gtfs",
",",
"max_link_distance",
"=",
"None",
")",
":",
"if",
"max_link_distance",
"is",
"None",
":",
"max_link_distance",
"=",
"1000",
"net",
"=",
"networkx",
".",
"Graph",
"(",
")",
"_add_stops_to_net",
"(",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | stop_to_stop_network_for_route_type | Get a stop-to-stop network describing a single mode of travel.
Parameters
----------
gtfs : gtfspy.GTFS
route_type : int
See gtfspy.route_types.TRANSIT_ROUTE_TYPES for the list of possible types.
link_attributes: list[str], optional
defaulting to use the following link attributes:
... | gtfspy/networks.py | def stop_to_stop_network_for_route_type(gtfs,
route_type,
link_attributes=None,
start_time_ut=None,
end_time_ut=None):
"""
Get a stop-to-stop network de... | def stop_to_stop_network_for_route_type(gtfs,
route_type,
link_attributes=None,
start_time_ut=None,
end_time_ut=None):
"""
Get a stop-to-stop network de... | [
"Get",
"a",
"stop",
"-",
"to",
"-",
"stop",
"network",
"describing",
"a",
"single",
"mode",
"of",
"travel",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L70-L169 | [
"def",
"stop_to_stop_network_for_route_type",
"(",
"gtfs",
",",
"route_type",
",",
"link_attributes",
"=",
"None",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
")",
":",
"if",
"link_attributes",
"is",
"None",
":",
"link_attributes",
"=",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | stop_to_stop_networks_by_type | Compute stop-to-stop networks for all travel modes (route_types).
Parameters
----------
gtfs: gtfspy.GTFS
Returns
-------
dict: dict[int, networkx.DiGraph]
keys should be one of route_types.ALL_ROUTE_TYPES (i.e. GTFS route_types) | gtfspy/networks.py | def stop_to_stop_networks_by_type(gtfs):
"""
Compute stop-to-stop networks for all travel modes (route_types).
Parameters
----------
gtfs: gtfspy.GTFS
Returns
-------
dict: dict[int, networkx.DiGraph]
keys should be one of route_types.ALL_ROUTE_TYPES (i.e. GTFS route_types)
... | def stop_to_stop_networks_by_type(gtfs):
"""
Compute stop-to-stop networks for all travel modes (route_types).
Parameters
----------
gtfs: gtfspy.GTFS
Returns
-------
dict: dict[int, networkx.DiGraph]
keys should be one of route_types.ALL_ROUTE_TYPES (i.e. GTFS route_types)
... | [
"Compute",
"stop",
"-",
"to",
"-",
"stop",
"networks",
"for",
"all",
"travel",
"modes",
"(",
"route_types",
")",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L172-L193 | [
"def",
"stop_to_stop_networks_by_type",
"(",
"gtfs",
")",
":",
"route_type_to_network",
"=",
"dict",
"(",
")",
"for",
"route_type",
"in",
"route_types",
".",
"ALL_ROUTE_TYPES",
":",
"if",
"route_type",
"==",
"route_types",
".",
"WALK",
":",
"net",
"=",
"walk_tra... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | combined_stop_to_stop_transit_network | Compute stop-to-stop networks for all travel modes and combine them into a single network.
The modes of transport are encoded to a single network.
The network consists of multiple links corresponding to each travel mode.
Walk mode is not included.
Parameters
----------
gtfs: gtfspy.GTFS
Re... | gtfspy/networks.py | def combined_stop_to_stop_transit_network(gtfs, start_time_ut=None, end_time_ut=None):
"""
Compute stop-to-stop networks for all travel modes and combine them into a single network.
The modes of transport are encoded to a single network.
The network consists of multiple links corresponding to each trave... | def combined_stop_to_stop_transit_network(gtfs, start_time_ut=None, end_time_ut=None):
"""
Compute stop-to-stop networks for all travel modes and combine them into a single network.
The modes of transport are encoded to a single network.
The network consists of multiple links corresponding to each trave... | [
"Compute",
"stop",
"-",
"to",
"-",
"stop",
"networks",
"for",
"all",
"travel",
"modes",
"and",
"combine",
"them",
"into",
"a",
"single",
"network",
".",
"The",
"modes",
"of",
"transport",
"are",
"encoded",
"to",
"a",
"single",
"network",
".",
"The",
"net... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L195-L219 | [
"def",
"combined_stop_to_stop_transit_network",
"(",
"gtfs",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
")",
":",
"multi_di_graph",
"=",
"networkx",
".",
"MultiDiGraph",
"(",
")",
"for",
"route_type",
"in",
"route_types",
".",
"TRANSIT_ROU... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | _add_stops_to_net | Add nodes to the network from the pandas dataframe describing (a part of the) stops table in the GTFS database.
Parameters
----------
net: networkx.Graph
stops: pandas.DataFrame | gtfspy/networks.py | def _add_stops_to_net(net, stops):
"""
Add nodes to the network from the pandas dataframe describing (a part of the) stops table in the GTFS database.
Parameters
----------
net: networkx.Graph
stops: pandas.DataFrame
"""
for stop in stops.itertuples():
data = {
"lat"... | def _add_stops_to_net(net, stops):
"""
Add nodes to the network from the pandas dataframe describing (a part of the) stops table in the GTFS database.
Parameters
----------
net: networkx.Graph
stops: pandas.DataFrame
"""
for stop in stops.itertuples():
data = {
"lat"... | [
"Add",
"nodes",
"to",
"the",
"network",
"from",
"the",
"pandas",
"dataframe",
"describing",
"(",
"a",
"part",
"of",
"the",
")",
"stops",
"table",
"in",
"the",
"GTFS",
"database",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L221-L236 | [
"def",
"_add_stops_to_net",
"(",
"net",
",",
"stops",
")",
":",
"for",
"stop",
"in",
"stops",
".",
"itertuples",
"(",
")",
":",
"data",
"=",
"{",
"\"lat\"",
":",
"stop",
".",
"lat",
",",
"\"lon\"",
":",
"stop",
".",
"lon",
",",
"\"name\"",
":",
"st... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | temporal_network | Compute the temporal network of the data, and return it as a pandas.DataFrame
Parameters
----------
gtfs : gtfspy.GTFS
start_time_ut: int | None
start time of the time span (in unix time)
end_time_ut: int | None
end time of the time span (in unix time)
route_type: int | None
... | gtfspy/networks.py | def temporal_network(gtfs,
start_time_ut=None,
end_time_ut=None,
route_type=None):
"""
Compute the temporal network of the data, and return it as a pandas.DataFrame
Parameters
----------
gtfs : gtfspy.GTFS
start_time_ut: int | None
... | def temporal_network(gtfs,
start_time_ut=None,
end_time_ut=None,
route_type=None):
"""
Compute the temporal network of the data, and return it as a pandas.DataFrame
Parameters
----------
gtfs : gtfspy.GTFS
start_time_ut: int | None
... | [
"Compute",
"the",
"temporal",
"network",
"of",
"the",
"data",
"and",
"return",
"it",
"as",
"a",
"pandas",
".",
"DataFrame"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L239-L277 | [
"def",
"temporal_network",
"(",
"gtfs",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
",",
"route_type",
"=",
"None",
")",
":",
"events_df",
"=",
"gtfs",
".",
"get_transit_events",
"(",
"start_time_ut",
"=",
"start_time_ut",
",",
"end_tim... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | route_to_route_network | Creates networkx graph where the nodes are bus routes and a edge indicates that there is a possibility to transfer
between the routes
:param gtfs:
:param walking_threshold:
:param start_time:
:param end_time:
:return: | gtfspy/networks.py | def route_to_route_network(gtfs, walking_threshold, start_time, end_time):
"""
Creates networkx graph where the nodes are bus routes and a edge indicates that there is a possibility to transfer
between the routes
:param gtfs:
:param walking_threshold:
:param start_time:
:param end_time:
... | def route_to_route_network(gtfs, walking_threshold, start_time, end_time):
"""
Creates networkx graph where the nodes are bus routes and a edge indicates that there is a possibility to transfer
between the routes
:param gtfs:
:param walking_threshold:
:param start_time:
:param end_time:
... | [
"Creates",
"networkx",
"graph",
"where",
"the",
"nodes",
"are",
"bus",
"routes",
"and",
"a",
"edge",
"indicates",
"that",
"there",
"is",
"a",
"possibility",
"to",
"transfer",
"between",
"the",
"routes",
":",
"param",
"gtfs",
":",
":",
"param",
"walking_thres... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/networks.py#L280-L313 | [
"def",
"route_to_route_network",
"(",
"gtfs",
",",
"walking_threshold",
",",
"start_time",
",",
"end_time",
")",
":",
"graph",
"=",
"networkx",
".",
"Graph",
"(",
")",
"routes",
"=",
"gtfs",
".",
"get_table",
"(",
"\"routes\"",
")",
"for",
"i",
"in",
"rout... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTime.mean_temporal_distance | Get mean temporal distance (in seconds) to the target.
Returns
-------
mean_temporal_distance : float | gtfspy/routing/node_profile_analyzer_time.py | def mean_temporal_distance(self):
"""
Get mean temporal distance (in seconds) to the target.
Returns
-------
mean_temporal_distance : float
"""
total_width = self.end_time_dep - self.start_time_dep
total_area = sum([block.area() for block in self._profile... | def mean_temporal_distance(self):
"""
Get mean temporal distance (in seconds) to the target.
Returns
-------
mean_temporal_distance : float
"""
total_width = self.end_time_dep - self.start_time_dep
total_area = sum([block.area() for block in self._profile... | [
"Get",
"mean",
"temporal",
"distance",
"(",
"in",
"seconds",
")",
"to",
"the",
"target",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L196-L206 | [
"def",
"mean_temporal_distance",
"(",
"self",
")",
":",
"total_width",
"=",
"self",
".",
"end_time_dep",
"-",
"self",
".",
"start_time_dep",
"total_area",
"=",
"sum",
"(",
"[",
"block",
".",
"area",
"(",
")",
"for",
"block",
"in",
"self",
".",
"_profile_bl... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTime.plot_temporal_distance_cdf | Plot the temporal distance cumulative density function.
Returns
-------
fig: matplotlib.Figure | gtfspy/routing/node_profile_analyzer_time.py | def plot_temporal_distance_cdf(self):
"""
Plot the temporal distance cumulative density function.
Returns
-------
fig: matplotlib.Figure
"""
xvalues, cdf = self.profile_block_analyzer._temporal_distance_cdf()
fig = plt.figure()
ax = fig.add_subplo... | def plot_temporal_distance_cdf(self):
"""
Plot the temporal distance cumulative density function.
Returns
-------
fig: matplotlib.Figure
"""
xvalues, cdf = self.profile_block_analyzer._temporal_distance_cdf()
fig = plt.figure()
ax = fig.add_subplo... | [
"Plot",
"the",
"temporal",
"distance",
"cumulative",
"density",
"function",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L246-L262 | [
"def",
"plot_temporal_distance_cdf",
"(",
"self",
")",
":",
"xvalues",
",",
"cdf",
"=",
"self",
".",
"profile_block_analyzer",
".",
"_temporal_distance_cdf",
"(",
")",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"ax",
"=",
"fig",
".",
"add_subplot",
"(",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTime.plot_temporal_distance_pdf | Plot the temporal distance probability density function.
Returns
-------
fig: matplotlib.Figure | gtfspy/routing/node_profile_analyzer_time.py | def plot_temporal_distance_pdf(self, use_minutes=True, color="green", ax=None):
"""
Plot the temporal distance probability density function.
Returns
-------
fig: matplotlib.Figure
"""
from matplotlib import pyplot as plt
plt.rc('text', usetex=True)
... | def plot_temporal_distance_pdf(self, use_minutes=True, color="green", ax=None):
"""
Plot the temporal distance probability density function.
Returns
-------
fig: matplotlib.Figure
"""
from matplotlib import pyplot as plt
plt.rc('text', usetex=True)
... | [
"Plot",
"the",
"temporal",
"distance",
"probability",
"density",
"function",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L264-L328 | [
"def",
"plot_temporal_distance_pdf",
"(",
"self",
",",
"use_minutes",
"=",
"True",
",",
"color",
"=",
"\"green\"",
",",
"ax",
"=",
"None",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"plt",
".",
"rc",
"(",
"'text'",
",",
"usetex",
"=... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTime.plot_temporal_distance_pdf_horizontal | Plot the temporal distance probability density function.
Returns
-------
fig: matplotlib.Figure | gtfspy/routing/node_profile_analyzer_time.py | def plot_temporal_distance_pdf_horizontal(self, use_minutes=True,
color="green",
ax=None,
duration_divider=60.0,
legend_font_size=None,
... | def plot_temporal_distance_pdf_horizontal(self, use_minutes=True,
color="green",
ax=None,
duration_divider=60.0,
legend_font_size=None,
... | [
"Plot",
"the",
"temporal",
"distance",
"probability",
"density",
"function",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L330-L414 | [
"def",
"plot_temporal_distance_pdf_horizontal",
"(",
"self",
",",
"use_minutes",
"=",
"True",
",",
"color",
"=",
"\"green\"",
",",
"ax",
"=",
"None",
",",
"duration_divider",
"=",
"60.0",
",",
"legend_font_size",
"=",
"None",
",",
"legend_loc",
"=",
"None",
")... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTime.plot_temporal_distance_profile | Parameters
----------
timezone: str
color: color
format_string: str, None
if None, the original values are used
plot_journeys: bool, optional
if True, small dots are plotted at the departure times | gtfspy/routing/node_profile_analyzer_time.py | def plot_temporal_distance_profile(self,
timezone=None,
color="black",
alpha=0.15,
ax=None,
lw=2,
... | def plot_temporal_distance_profile(self,
timezone=None,
color="black",
alpha=0.15,
ax=None,
lw=2,
... | [
"Parameters",
"----------",
"timezone",
":",
"str",
"color",
":",
"color",
"format_string",
":",
"str",
"None",
"if",
"None",
"the",
"original",
"values",
"are",
"used",
"plot_journeys",
":",
"bool",
"optional",
"if",
"True",
"small",
"dots",
"are",
"plotted",... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time.py#L416-L559 | [
"def",
"plot_temporal_distance_profile",
"(",
"self",
",",
"timezone",
"=",
"None",
",",
"color",
"=",
"\"black\"",
",",
"alpha",
"=",
"0.15",
",",
"ax",
"=",
"None",
",",
"lw",
"=",
"2",
",",
"label",
"=",
"\"\"",
",",
"plot_tdist_stats",
"=",
"False",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ForwardJourney.add_leg | Parameters
----------
leg: Connection | gtfspy/routing/forwardjourney.py | def add_leg(self, leg):
"""
Parameters
----------
leg: Connection
"""
assert(isinstance(leg, Connection))
if not self.legs:
self.departure_time = leg.departure_time
self.arrival_time = leg.arrival_time
if leg.trip_id and (not self.legs ... | def add_leg(self, leg):
"""
Parameters
----------
leg: Connection
"""
assert(isinstance(leg, Connection))
if not self.legs:
self.departure_time = leg.departure_time
self.arrival_time = leg.arrival_time
if leg.trip_id and (not self.legs ... | [
"Parameters",
"----------",
"leg",
":",
"Connection"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/forwardjourney.py#L27-L40 | [
"def",
"add_leg",
"(",
"self",
",",
"leg",
")",
":",
"assert",
"(",
"isinstance",
"(",
"leg",
",",
"Connection",
")",
")",
"if",
"not",
"self",
".",
"legs",
":",
"self",
".",
"departure_time",
"=",
"leg",
".",
"departure_time",
"self",
".",
"arrival_ti... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | ForwardJourney.get_transfer_stop_pairs | Get stop pairs through which transfers take place
Returns
-------
transfer_stop_pairs: list | gtfspy/routing/forwardjourney.py | def get_transfer_stop_pairs(self):
"""
Get stop pairs through which transfers take place
Returns
-------
transfer_stop_pairs: list
"""
transfer_stop_pairs = []
previous_arrival_stop = None
current_trip_id = None
for leg in self.legs:
... | def get_transfer_stop_pairs(self):
"""
Get stop pairs through which transfers take place
Returns
-------
transfer_stop_pairs: list
"""
transfer_stop_pairs = []
previous_arrival_stop = None
current_trip_id = None
for leg in self.legs:
... | [
"Get",
"stop",
"pairs",
"through",
"which",
"transfers",
"take",
"place"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/forwardjourney.py#L59-L76 | [
"def",
"get_transfer_stop_pairs",
"(",
"self",
")",
":",
"transfer_stop_pairs",
"=",
"[",
"]",
"previous_arrival_stop",
"=",
"None",
"current_trip_id",
"=",
"None",
"for",
"leg",
"in",
"self",
".",
"legs",
":",
"if",
"leg",
".",
"trip_id",
"is",
"not",
"None... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | _truncate_colormap | Truncates a colormap to use.
Code originall from http://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib | gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py | def _truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
"""
Truncates a colormap to use.
Code originall from http://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib
"""
new_cmap = LinearSegmentedColormap.from_list(
'trunc({n},{a:... | def _truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
"""
Truncates a colormap to use.
Code originall from http://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib
"""
new_cmap = LinearSegmentedColormap.from_list(
'trunc({n},{a:... | [
"Truncates",
"a",
"colormap",
"to",
"use",
".",
"Code",
"originall",
"from",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"18926031",
"/",
"how",
"-",
"to",
"-",
"extract",
"-",
"a",
"-",
"subset",
"-",
"of",
"-",
"a",
"-",
... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py#L47-L56 | [
"def",
"_truncate_colormap",
"(",
"cmap",
",",
"minval",
"=",
"0.0",
",",
"maxval",
"=",
"1.0",
",",
"n",
"=",
"100",
")",
":",
"new_cmap",
"=",
"LinearSegmentedColormap",
".",
"from_list",
"(",
"'trunc({n},{a:.2f},{b:.2f})'",
".",
"format",
"(",
"n",
"=",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTimeAndVehLegs.get_time_profile_analyzer | Parameters
----------
max_n_boardings: int
The maximum number of boardings allowed for the labels used to construct the "temporal distance profile"
Returns
-------
analyzer: NodeProfileAnalyzerTime | gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py | def get_time_profile_analyzer(self, max_n_boardings=None):
"""
Parameters
----------
max_n_boardings: int
The maximum number of boardings allowed for the labels used to construct the "temporal distance profile"
Returns
-------
analyzer: NodeProfileAna... | def get_time_profile_analyzer(self, max_n_boardings=None):
"""
Parameters
----------
max_n_boardings: int
The maximum number of boardings allowed for the labels used to construct the "temporal distance profile"
Returns
-------
analyzer: NodeProfileAna... | [
"Parameters",
"----------",
"max_n_boardings",
":",
"int",
"The",
"maximum",
"number",
"of",
"boardings",
"allowed",
"for",
"the",
"labels",
"used",
"to",
"construct",
"the",
"temporal",
"distance",
"profile"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py#L145-L174 | [
"def",
"get_time_profile_analyzer",
"(",
"self",
",",
"max_n_boardings",
"=",
"None",
")",
":",
"if",
"max_n_boardings",
"is",
"None",
":",
"max_n_boardings",
"=",
"self",
".",
"max_trip_n_boardings",
"(",
")",
"# compute only if not yet computed",
"if",
"not",
"max... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | NodeProfileAnalyzerTimeAndVehLegs.median_temporal_distances | Returns
-------
mean_temporal_distances: list
list indices encode the number of vehicle legs each element
in the list tells gets the mean temporal distance | gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py | def median_temporal_distances(self, min_n_boardings=None, max_n_boardings=None):
"""
Returns
-------
mean_temporal_distances: list
list indices encode the number of vehicle legs each element
in the list tells gets the mean temporal distance
"""
if ... | def median_temporal_distances(self, min_n_boardings=None, max_n_boardings=None):
"""
Returns
-------
mean_temporal_distances: list
list indices encode the number of vehicle legs each element
in the list tells gets the mean temporal distance
"""
if ... | [
"Returns",
"-------",
"mean_temporal_distances",
":",
"list",
"list",
"indices",
"encode",
"the",
"number",
"of",
"vehicle",
"legs",
"each",
"element",
"in",
"the",
"list",
"tells",
"gets",
"the",
"mean",
"temporal",
"distance"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py#L242-L262 | [
"def",
"median_temporal_distances",
"(",
"self",
",",
"min_n_boardings",
"=",
"None",
",",
"max_n_boardings",
"=",
"None",
")",
":",
"if",
"min_n_boardings",
"is",
"None",
":",
"min_n_boardings",
"=",
"0",
"if",
"max_n_boardings",
"is",
"None",
":",
"max_n_board... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.from_directory_as_inmemory_db | Instantiate a GTFS object by computing
Parameters
----------
gtfs_directory: str
path to the directory for importing the database | gtfspy/gtfs.py | def from_directory_as_inmemory_db(cls, gtfs_directory):
"""
Instantiate a GTFS object by computing
Parameters
----------
gtfs_directory: str
path to the directory for importing the database
"""
# this import is here to avoid circular imports (which tu... | def from_directory_as_inmemory_db(cls, gtfs_directory):
"""
Instantiate a GTFS object by computing
Parameters
----------
gtfs_directory: str
path to the directory for importing the database
"""
# this import is here to avoid circular imports (which tu... | [
"Instantiate",
"a",
"GTFS",
"object",
"by",
"computing"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L64-L80 | [
"def",
"from_directory_as_inmemory_db",
"(",
"cls",
",",
"gtfs_directory",
")",
":",
"# this import is here to avoid circular imports (which turned out to be a problem)",
"from",
"gtfspy",
".",
"import_gtfs",
"import",
"import_gtfs",
"conn",
"=",
"sqlite3",
".",
"connect",
"(... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_main_database_path | Should return the path to the database
Returns
-------
path : unicode
path to the database, empty string for in-memory databases | gtfspy/gtfs.py | def get_main_database_path(self):
"""
Should return the path to the database
Returns
-------
path : unicode
path to the database, empty string for in-memory databases
"""
cur = self.conn.cursor()
cur.execute("PRAGMA database_list")
row... | def get_main_database_path(self):
"""
Should return the path to the database
Returns
-------
path : unicode
path to the database, empty string for in-memory databases
"""
cur = self.conn.cursor()
cur.execute("PRAGMA database_list")
row... | [
"Should",
"return",
"the",
"path",
"to",
"the",
"database"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L82-L96 | [
"def",
"get_main_database_path",
"(",
"self",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"\"PRAGMA database_list\"",
")",
"rows",
"=",
"cur",
".",
"fetchall",
"(",
")",
"for",
"row",
"in",
"rows",
":... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_shape_distance_between_stops | Get the distance along a shape between stops
Parameters
----------
trip_I : int
trip_ID along which we travel
from_stop_seq : int
the sequence number of the 'origin' stop
to_stop_seq : int
the sequence number of the 'destination' stop
... | gtfspy/gtfs.py | def get_shape_distance_between_stops(self, trip_I, from_stop_seq, to_stop_seq):
"""
Get the distance along a shape between stops
Parameters
----------
trip_I : int
trip_ID along which we travel
from_stop_seq : int
the sequence number of the 'origi... | def get_shape_distance_between_stops(self, trip_I, from_stop_seq, to_stop_seq):
"""
Get the distance along a shape between stops
Parameters
----------
trip_I : int
trip_ID along which we travel
from_stop_seq : int
the sequence number of the 'origi... | [
"Get",
"the",
"distance",
"along",
"a",
"shape",
"between",
"stops"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L101-L131 | [
"def",
"get_shape_distance_between_stops",
"(",
"self",
",",
"trip_I",
",",
"from_stop_seq",
",",
"to_stop_seq",
")",
":",
"query_template",
"=",
"\"SELECT shape_break FROM stop_times WHERE trip_I={trip_I} AND seq={seq} \"",
"stop_seqs",
"=",
"[",
"from_stop_seq",
",",
"to_st... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_directly_accessible_stops_within_distance | Returns stops that are accessible without transfer from the stops that are within a specific walking distance
:param stop: int
:param distance: int
:return: | gtfspy/gtfs.py | def get_directly_accessible_stops_within_distance(self, stop, distance):
"""
Returns stops that are accessible without transfer from the stops that are within a specific walking distance
:param stop: int
:param distance: int
:return:
"""
query = """SELECT stop.* F... | def get_directly_accessible_stops_within_distance(self, stop, distance):
"""
Returns stops that are accessible without transfer from the stops that are within a specific walking distance
:param stop: int
:param distance: int
:return:
"""
query = """SELECT stop.* F... | [
"Returns",
"stops",
"that",
"are",
"accessible",
"without",
"transfer",
"from",
"the",
"stops",
"that",
"are",
"within",
"a",
"specific",
"walking",
"distance",
":",
"param",
"stop",
":",
"int",
":",
"param",
"distance",
":",
"int",
":",
"return",
":"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L147-L164 | [
"def",
"get_directly_accessible_stops_within_distance",
"(",
"self",
",",
"stop",
",",
"distance",
")",
":",
"query",
"=",
"\"\"\"SELECT stop.* FROM\n (SELECT st2.* FROM \n (SELECT * FROM stop_distances\n WHERE from_stop_I = %s) sd,\n ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_timezone_name | Get name of the GTFS timezone
Returns
-------
timezone_name : str
name of the time zone, e.g. "Europe/Helsinki" | gtfspy/gtfs.py | def get_timezone_name(self):
"""
Get name of the GTFS timezone
Returns
-------
timezone_name : str
name of the time zone, e.g. "Europe/Helsinki"
"""
tz_name = self.conn.execute('SELECT timezone FROM agencies LIMIT 1').fetchone()
if tz_name is ... | def get_timezone_name(self):
"""
Get name of the GTFS timezone
Returns
-------
timezone_name : str
name of the time zone, e.g. "Europe/Helsinki"
"""
tz_name = self.conn.execute('SELECT timezone FROM agencies LIMIT 1').fetchone()
if tz_name is ... | [
"Get",
"name",
"of",
"the",
"GTFS",
"timezone"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L223-L235 | [
"def",
"get_timezone_name",
"(",
"self",
")",
":",
"tz_name",
"=",
"self",
".",
"conn",
".",
"execute",
"(",
"'SELECT timezone FROM agencies LIMIT 1'",
")",
".",
"fetchone",
"(",
")",
"if",
"tz_name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"This data... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_timezone_string | Return the timezone of the GTFS database object as a string.
The assumed time when the timezone (difference) is computed
is the download date of the file.
This might not be optimal in all cases.
So this function should return values like:
"+0200" or "-1100"
Paramete... | gtfspy/gtfs.py | def get_timezone_string(self, dt=None):
"""
Return the timezone of the GTFS database object as a string.
The assumed time when the timezone (difference) is computed
is the download date of the file.
This might not be optimal in all cases.
So this function should return v... | def get_timezone_string(self, dt=None):
"""
Return the timezone of the GTFS database object as a string.
The assumed time when the timezone (difference) is computed
is the download date of the file.
This might not be optimal in all cases.
So this function should return v... | [
"Return",
"the",
"timezone",
"of",
"the",
"GTFS",
"database",
"object",
"as",
"a",
"string",
".",
"The",
"assumed",
"time",
"when",
"the",
"timezone",
"(",
"difference",
")",
"is",
"computed",
"is",
"the",
"download",
"date",
"of",
"the",
"file",
".",
"T... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L237-L266 | [
"def",
"get_timezone_string",
"(",
"self",
",",
"dt",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"download_date",
"=",
"self",
".",
"meta",
".",
"get",
"(",
"'download_date'",
")",
"if",
"download_date",
":",
"dt",
"=",
"datetime",
".",
"dat... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.unlocalized_datetime_to_ut_seconds | Convert datetime (in GTFS timezone) to unixtime
Parameters
----------
unlocalized_datetime : datetime.datetime
(tz coerced to GTFS timezone, should NOT be UTC.)
Returns
-------
output : int (unixtime) | gtfspy/gtfs.py | def unlocalized_datetime_to_ut_seconds(self, unlocalized_datetime):
"""
Convert datetime (in GTFS timezone) to unixtime
Parameters
----------
unlocalized_datetime : datetime.datetime
(tz coerced to GTFS timezone, should NOT be UTC.)
Returns
-------
... | def unlocalized_datetime_to_ut_seconds(self, unlocalized_datetime):
"""
Convert datetime (in GTFS timezone) to unixtime
Parameters
----------
unlocalized_datetime : datetime.datetime
(tz coerced to GTFS timezone, should NOT be UTC.)
Returns
-------
... | [
"Convert",
"datetime",
"(",
"in",
"GTFS",
"timezone",
")",
"to",
"unixtime"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L283-L298 | [
"def",
"unlocalized_datetime_to_ut_seconds",
"(",
"self",
",",
"unlocalized_datetime",
")",
":",
"loc_dt",
"=",
"self",
".",
"_timezone",
".",
"localize",
"(",
"unlocalized_datetime",
")",
"unixtime_seconds",
"=",
"calendar",
".",
"timegm",
"(",
"loc_dt",
".",
"ut... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_day_start_ut | Get day start time (as specified by GTFS) as unix time in seconds
Parameters
----------
date : str | unicode | datetime.datetime
something describing the date
Returns
-------
day_start_ut : int
start time of the day in unixtime | gtfspy/gtfs.py | def get_day_start_ut(self, date):
"""
Get day start time (as specified by GTFS) as unix time in seconds
Parameters
----------
date : str | unicode | datetime.datetime
something describing the date
Returns
-------
day_start_ut : int
... | def get_day_start_ut(self, date):
"""
Get day start time (as specified by GTFS) as unix time in seconds
Parameters
----------
date : str | unicode | datetime.datetime
something describing the date
Returns
-------
day_start_ut : int
... | [
"Get",
"day",
"start",
"time",
"(",
"as",
"specified",
"by",
"GTFS",
")",
"as",
"unix",
"time",
"in",
"seconds"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L300-L319 | [
"def",
"get_day_start_ut",
"(",
"self",
",",
"date",
")",
":",
"if",
"isinstance",
"(",
"date",
",",
"string_types",
")",
":",
"date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"date",
",",
"'%Y-%m-%d'",
")",
"date_noon",
"=",
"datetime",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_trip_trajectories_within_timespan | Get complete trip data for visualizing public transport operation based on gtfs.
Parameters
----------
start: number
Earliest position data to return (in unix time)
end: number
Latest position data to return (in unix time)
use_shapes: bool, optional
... | gtfspy/gtfs.py | def get_trip_trajectories_within_timespan(self, start, end, use_shapes=True, filter_name=None):
"""
Get complete trip data for visualizing public transport operation based on gtfs.
Parameters
----------
start: number
Earliest position data to return (in unix time)
... | def get_trip_trajectories_within_timespan(self, start, end, use_shapes=True, filter_name=None):
"""
Get complete trip data for visualizing public transport operation based on gtfs.
Parameters
----------
start: number
Earliest position data to return (in unix time)
... | [
"Get",
"complete",
"trip",
"data",
"for",
"visualizing",
"public",
"transport",
"operation",
"based",
"on",
"gtfs",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L321-L414 | [
"def",
"get_trip_trajectories_within_timespan",
"(",
"self",
",",
"start",
",",
"end",
",",
"use_shapes",
"=",
"True",
",",
"filter_name",
"=",
"None",
")",
":",
"trips",
"=",
"[",
"]",
"trip_df",
"=",
"self",
".",
"get_tripIs_active_in_range",
"(",
"start",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_stop_count_data | Get stop count data.
Parameters
----------
start_ut : int
start time in unixtime
end_ut : int
end time in unixtime
Returns
-------
stopData : pandas.DataFrame
each row in the stopData dataFrame is a dictionary with the followi... | gtfspy/gtfs.py | def get_stop_count_data(self, start_ut, end_ut):
"""
Get stop count data.
Parameters
----------
start_ut : int
start time in unixtime
end_ut : int
end time in unixtime
Returns
-------
stopData : pandas.DataFrame
... | def get_stop_count_data(self, start_ut, end_ut):
"""
Get stop count data.
Parameters
----------
start_ut : int
start time in unixtime
end_ut : int
end time in unixtime
Returns
-------
stopData : pandas.DataFrame
... | [
"Get",
"stop",
"count",
"data",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L416-L452 | [
"def",
"get_stop_count_data",
"(",
"self",
",",
"start_ut",
",",
"end_ut",
")",
":",
"# TODO! this function could perhaps be made a single sql query now with the new tables?",
"trips_df",
"=",
"self",
".",
"get_tripIs_active_in_range",
"(",
"start_ut",
",",
"end_ut",
")",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_segment_count_data | Get segment data including PTN vehicle counts per segment that are
fully _contained_ within the interval (start, end)
Parameters
----------
start : int
start time of the simulation in unix time
end : int
end time of the simulation in unix time
use... | gtfspy/gtfs.py | def get_segment_count_data(self, start, end, use_shapes=True):
"""
Get segment data including PTN vehicle counts per segment that are
fully _contained_ within the interval (start, end)
Parameters
----------
start : int
start time of the simulation in unix tim... | def get_segment_count_data(self, start, end, use_shapes=True):
"""
Get segment data including PTN vehicle counts per segment that are
fully _contained_ within the interval (start, end)
Parameters
----------
start : int
start time of the simulation in unix tim... | [
"Get",
"segment",
"data",
"including",
"PTN",
"vehicle",
"counts",
"per",
"segment",
"that",
"are",
"fully",
"_contained_",
"within",
"the",
"interval",
"(",
"start",
"end",
")"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L454-L532 | [
"def",
"get_segment_count_data",
"(",
"self",
",",
"start",
",",
"end",
",",
"use_shapes",
"=",
"True",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"# get all possible trip_ids that take place between start and end",
"trips_df",
"=",
"self"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_all_route_shapes | Get the shapes of all routes.
Parameters
----------
use_shapes : bool, optional
by default True (i.e. use shapes as the name of the function indicates)
if False (fall back to lats and longitudes)
Returns
-------
routeShapes: list of dicts that sh... | gtfspy/gtfs.py | def get_all_route_shapes(self, use_shapes=True):
"""
Get the shapes of all routes.
Parameters
----------
use_shapes : bool, optional
by default True (i.e. use shapes as the name of the function indicates)
if False (fall back to lats and longitudes)
... | def get_all_route_shapes(self, use_shapes=True):
"""
Get the shapes of all routes.
Parameters
----------
use_shapes : bool, optional
by default True (i.e. use shapes as the name of the function indicates)
if False (fall back to lats and longitudes)
... | [
"Get",
"the",
"shapes",
"of",
"all",
"routes",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L535-L585 | [
"def",
"get_all_route_shapes",
"(",
"self",
",",
"use_shapes",
"=",
"True",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"# all shape_id:s corresponding to a route_I:",
"# query = \"SELECT DISTINCT name, shape_id, trips.route_I, route_type",
"# ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_tripIs_active_in_range | Obtain from the (standard) GTFS database, list of trip_IDs (and other trip_related info)
that are active between given 'start' and 'end' times.
The start time of a trip is determined by the departure time at the last stop of the trip.
The end time of a trip is determined by the arrival time at ... | gtfspy/gtfs.py | def get_tripIs_active_in_range(self, start, end):
"""
Obtain from the (standard) GTFS database, list of trip_IDs (and other trip_related info)
that are active between given 'start' and 'end' times.
The start time of a trip is determined by the departure time at the last stop of the trip... | def get_tripIs_active_in_range(self, start, end):
"""
Obtain from the (standard) GTFS database, list of trip_IDs (and other trip_related info)
that are active between given 'start' and 'end' times.
The start time of a trip is determined by the departure time at the last stop of the trip... | [
"Obtain",
"from",
"the",
"(",
"standard",
")",
"GTFS",
"database",
"list",
"of",
"trip_IDs",
"(",
"and",
"other",
"trip_related",
"info",
")",
"that",
"are",
"active",
"between",
"given",
"start",
"and",
"end",
"times",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L587-L610 | [
"def",
"get_tripIs_active_in_range",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"to_select",
"=",
"\"trip_I, day_start_ut, start_time_ut, end_time_ut, shape_id \"",
"query",
"=",
"\"SELECT \"",
"+",
"to_select",
"+",
"\"FROM day_trips \"",
"\"WHERE \"",
"\"(end_time_u... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_trip_counts_per_day | Get trip counts per day between the start and end day of the feed.
Returns
-------
trip_counts : pandas.DataFrame
Has columns "date_str" (dtype str) "trip_counts" (dtype int) | gtfspy/gtfs.py | def get_trip_counts_per_day(self):
"""
Get trip counts per day between the start and end day of the feed.
Returns
-------
trip_counts : pandas.DataFrame
Has columns "date_str" (dtype str) "trip_counts" (dtype int)
"""
query = "SELECT date, count(*) AS... | def get_trip_counts_per_day(self):
"""
Get trip counts per day between the start and end day of the feed.
Returns
-------
trip_counts : pandas.DataFrame
Has columns "date_str" (dtype str) "trip_counts" (dtype int)
"""
query = "SELECT date, count(*) AS... | [
"Get",
"trip",
"counts",
"per",
"day",
"between",
"the",
"start",
"and",
"end",
"day",
"of",
"the",
"feed",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L612-L648 | [
"def",
"get_trip_counts_per_day",
"(",
"self",
")",
":",
"query",
"=",
"\"SELECT date, count(*) AS number_of_trips FROM day_trips GROUP BY date\"",
"# this yields the actual data",
"trip_counts_per_day",
"=",
"pd",
".",
"read_sql_query",
"(",
"query",
",",
"self",
".",
"conn"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_suitable_date_for_daily_extract | Parameters
----------
date : str
ut : bool
Whether to return the date as a string or as a an int (seconds after epoch).
Returns
-------
Selects suitable date for daily extract
Iterates trough the available dates forward and backward from the download ... | gtfspy/gtfs.py | def get_suitable_date_for_daily_extract(self, date=None, ut=False):
"""
Parameters
----------
date : str
ut : bool
Whether to return the date as a string or as a an int (seconds after epoch).
Returns
-------
Selects suitable date for daily ext... | def get_suitable_date_for_daily_extract(self, date=None, ut=False):
"""
Parameters
----------
date : str
ut : bool
Whether to return the date as a string or as a an int (seconds after epoch).
Returns
-------
Selects suitable date for daily ext... | [
"Parameters",
"----------",
"date",
":",
"str",
"ut",
":",
"bool",
"Whether",
"to",
"return",
"the",
"date",
"as",
"a",
"string",
"or",
"as",
"a",
"an",
"int",
"(",
"seconds",
"after",
"epoch",
")",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L650-L677 | [
"def",
"get_suitable_date_for_daily_extract",
"(",
"self",
",",
"date",
"=",
"None",
",",
"ut",
"=",
"False",
")",
":",
"daily_trips",
"=",
"self",
".",
"get_trip_counts_per_day",
"(",
")",
"max_daily_trips",
"=",
"daily_trips",
"[",
"u'trip_counts'",
"]",
".",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_weekly_extract_start_date | Find a suitable weekly extract start date (monday).
The goal is to obtain as 'usual' week as possible.
The weekdays of the weekly extract week should contain
at least 0.9 of the total maximum of trips.
Parameters
----------
ut: return unixtime?
weekdays_at_least_... | gtfspy/gtfs.py | def get_weekly_extract_start_date(self, ut=False, weekdays_at_least_of_max=0.9,
verbose=False, download_date_override=None):
"""
Find a suitable weekly extract start date (monday).
The goal is to obtain as 'usual' week as possible.
The weekdays of th... | def get_weekly_extract_start_date(self, ut=False, weekdays_at_least_of_max=0.9,
verbose=False, download_date_override=None):
"""
Find a suitable weekly extract start date (monday).
The goal is to obtain as 'usual' week as possible.
The weekdays of th... | [
"Find",
"a",
"suitable",
"weekly",
"extract",
"start",
"date",
"(",
"monday",
")",
".",
"The",
"goal",
"is",
"to",
"obtain",
"as",
"usual",
"week",
"as",
"possible",
".",
"The",
"weekdays",
"of",
"the",
"weekly",
"extract",
"week",
"should",
"contain",
"... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L679-L765 | [
"def",
"get_weekly_extract_start_date",
"(",
"self",
",",
"ut",
"=",
"False",
",",
"weekdays_at_least_of_max",
"=",
"0.9",
",",
"verbose",
"=",
"False",
",",
"download_date_override",
"=",
"None",
")",
":",
"daily_trip_counts",
"=",
"self",
".",
"get_trip_counts_p... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_spreading_trips | Starting from a specific point and time, get complete single source
shortest path spreading dynamics as trips, or "events".
Parameters
----------
start_time_ut: number
Start time of the spreading.
lat: float
latitude of the spreading seed location
... | gtfspy/gtfs.py | def get_spreading_trips(self, start_time_ut, lat, lon,
max_duration_ut=4 * 3600,
min_transfer_time=30,
use_shapes=False):
"""
Starting from a specific point and time, get complete single source
shortest path spre... | def get_spreading_trips(self, start_time_ut, lat, lon,
max_duration_ut=4 * 3600,
min_transfer_time=30,
use_shapes=False):
"""
Starting from a specific point and time, get complete single source
shortest path spre... | [
"Starting",
"from",
"a",
"specific",
"point",
"and",
"time",
"get",
"complete",
"single",
"source",
"shortest",
"path",
"spreading",
"dynamics",
"as",
"trips",
"or",
"events",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L767-L803 | [
"def",
"get_spreading_trips",
"(",
"self",
",",
"start_time_ut",
",",
"lat",
",",
"lon",
",",
"max_duration_ut",
"=",
"4",
"*",
"3600",
",",
"min_transfer_time",
"=",
"30",
",",
"use_shapes",
"=",
"False",
")",
":",
"from",
"gtfspy",
".",
"spreading",
".",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_closest_stop | Get closest stop to a given location.
Parameters
----------
lat: float
latitude coordinate of the location
lon: float
longitude coordinate of the location
Returns
-------
stop_I: int
the index of the stop in the database | gtfspy/gtfs.py | def get_closest_stop(self, lat, lon):
"""
Get closest stop to a given location.
Parameters
----------
lat: float
latitude coordinate of the location
lon: float
longitude coordinate of the location
Returns
-------
stop_I: i... | def get_closest_stop(self, lat, lon):
"""
Get closest stop to a given location.
Parameters
----------
lat: float
latitude coordinate of the location
lon: float
longitude coordinate of the location
Returns
-------
stop_I: i... | [
"Get",
"closest",
"stop",
"to",
"a",
"given",
"location",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L805-L830 | [
"def",
"get_closest_stop",
"(",
"self",
",",
"lat",
",",
"lon",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"min_dist",
"=",
"float",
"(",
"\"inf\"",
")",
"min_stop_I",
"=",
"None",
"rows",
"=",
"cur",
".",
"execute",
"(",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_route_name_and_type_of_tripI | Get route short name and type
Parameters
----------
trip_I: int
short trip index created when creating the database
Returns
-------
name: str
short name of the route, eg. 195N
type: int
route_type according to the GTFS standar... | gtfspy/gtfs.py | def get_route_name_and_type_of_tripI(self, trip_I):
"""
Get route short name and type
Parameters
----------
trip_I: int
short trip index created when creating the database
Returns
-------
name: str
short name of the route, eg. 195... | def get_route_name_and_type_of_tripI(self, trip_I):
"""
Get route short name and type
Parameters
----------
trip_I: int
short trip index created when creating the database
Returns
-------
name: str
short name of the route, eg. 195... | [
"Get",
"route",
"short",
"name",
"and",
"type"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L862-L882 | [
"def",
"get_route_name_and_type_of_tripI",
"(",
"self",
",",
"trip_I",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"results",
"=",
"cur",
".",
"execute",
"(",
"\"SELECT name, type FROM routes JOIN trips USING(route_I) WHERE trip_I={trip_I}\"",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_route_name_and_type | Get route short name and type
Parameters
----------
route_I: int
route index (database specific)
Returns
-------
name: str
short name of the route, eg. 195N
type: int
route_type according to the GTFS standard | gtfspy/gtfs.py | def get_route_name_and_type(self, route_I):
"""
Get route short name and type
Parameters
----------
route_I: int
route index (database specific)
Returns
-------
name: str
short name of the route, eg. 195N
type: int
... | def get_route_name_and_type(self, route_I):
"""
Get route short name and type
Parameters
----------
route_I: int
route index (database specific)
Returns
-------
name: str
short name of the route, eg. 195N
type: int
... | [
"Get",
"route",
"short",
"name",
"and",
"type"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L884-L903 | [
"def",
"get_route_name_and_type",
"(",
"self",
",",
"route_I",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"results",
"=",
"cur",
".",
"execute",
"(",
"\"SELECT name, type FROM routes WHERE route_I=(?)\"",
",",
"(",
"route_I",
",",
")",... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_trip_stop_coordinates | Get coordinates for a given trip_I
Parameters
----------
trip_I : int
the integer id of the trip
Returns
-------
stop_coords : pandas.DataFrame
with columns "lats" and "lons" | gtfspy/gtfs.py | def get_trip_stop_coordinates(self, trip_I):
"""
Get coordinates for a given trip_I
Parameters
----------
trip_I : int
the integer id of the trip
Returns
-------
stop_coords : pandas.DataFrame
with columns "lats" and "lons"
... | def get_trip_stop_coordinates(self, trip_I):
"""
Get coordinates for a given trip_I
Parameters
----------
trip_I : int
the integer id of the trip
Returns
-------
stop_coords : pandas.DataFrame
with columns "lats" and "lons"
... | [
"Get",
"coordinates",
"for",
"a",
"given",
"trip_I"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L905-L926 | [
"def",
"get_trip_stop_coordinates",
"(",
"self",
",",
"trip_I",
")",
":",
"query",
"=",
"\"\"\"SELECT lat, lon\n FROM stop_times\n JOIN stops\n USING(stop_I)\n WHERE trip_I={trip_I}\n ORDER BY stop... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_trip_stop_time_data | Obtain from the (standard) GTFS database, trip stop data
(departure time in ut, lat, lon, seq, shape_break) as a pandas DataFrame
Some filtering could be applied here, if only e.g. departure times
corresponding within some time interval should be considered.
Parameters
--------... | gtfspy/gtfs.py | def get_trip_stop_time_data(self, trip_I, day_start_ut):
"""
Obtain from the (standard) GTFS database, trip stop data
(departure time in ut, lat, lon, seq, shape_break) as a pandas DataFrame
Some filtering could be applied here, if only e.g. departure times
corresponding within ... | def get_trip_stop_time_data(self, trip_I, day_start_ut):
"""
Obtain from the (standard) GTFS database, trip stop data
(departure time in ut, lat, lon, seq, shape_break) as a pandas DataFrame
Some filtering could be applied here, if only e.g. departure times
corresponding within ... | [
"Obtain",
"from",
"the",
"(",
"standard",
")",
"GTFS",
"database",
"trip",
"stop",
"data",
"(",
"departure",
"time",
"in",
"ut",
"lat",
"lon",
"seq",
"shape_break",
")",
"as",
"a",
"pandas",
"DataFrame"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L928-L955 | [
"def",
"get_trip_stop_time_data",
"(",
"self",
",",
"trip_I",
",",
"day_start_ut",
")",
":",
"to_select",
"=",
"\"stop_I, \"",
"+",
"str",
"(",
"day_start_ut",
")",
"+",
"\"+dep_time_ds AS dep_time_ut, lat, lon, seq, shape_break\"",
"str_to_run",
"=",
"\"SELECT \"",
"+"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_events_by_tripI_and_dsut | Get trip data as a list of events (i.e. dicts).
Parameters
----------
trip_I : int
shorthand index of the trip.
day_start_ut : int
the start time of the day in unix time (seconds)
start_ut : int, optional
consider only events that start after ... | gtfspy/gtfs.py | def get_events_by_tripI_and_dsut(self, trip_I, day_start_ut,
start_ut=None, end_ut=None):
"""
Get trip data as a list of events (i.e. dicts).
Parameters
----------
trip_I : int
shorthand index of the trip.
day_start_ut : i... | def get_events_by_tripI_and_dsut(self, trip_I, day_start_ut,
start_ut=None, end_ut=None):
"""
Get trip data as a list of events (i.e. dicts).
Parameters
----------
trip_I : int
shorthand index of the trip.
day_start_ut : i... | [
"Get",
"trip",
"data",
"as",
"a",
"list",
"of",
"events",
"(",
"i",
".",
"e",
".",
"dicts",
")",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L957-L1018 | [
"def",
"get_events_by_tripI_and_dsut",
"(",
"self",
",",
"trip_I",
",",
"day_start_ut",
",",
"start_ut",
"=",
"None",
",",
"end_ut",
"=",
"None",
")",
":",
"# for checking input:",
"assert",
"day_start_ut",
"<=",
"start_ut",
"assert",
"day_start_ut",
"<=",
"end_ut... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.tripI_takes_place_on_dsut | Check that a trip takes place during a day
Parameters
----------
trip_I : int
index of the trip in the gtfs data base
day_start_ut : int
the starting time of the day in unix time (seconds)
Returns
-------
takes_place: bool
boo... | gtfspy/gtfs.py | def tripI_takes_place_on_dsut(self, trip_I, day_start_ut):
"""
Check that a trip takes place during a day
Parameters
----------
trip_I : int
index of the trip in the gtfs data base
day_start_ut : int
the starting time of the day in unix time (seco... | def tripI_takes_place_on_dsut(self, trip_I, day_start_ut):
"""
Check that a trip takes place during a day
Parameters
----------
trip_I : int
index of the trip in the gtfs data base
day_start_ut : int
the starting time of the day in unix time (seco... | [
"Check",
"that",
"a",
"trip",
"takes",
"place",
"during",
"a",
"day"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1020-L1045 | [
"def",
"tripI_takes_place_on_dsut",
"(",
"self",
",",
"trip_I",
",",
"day_start_ut",
")",
":",
"query",
"=",
"\"SELECT * FROM days WHERE trip_I=? AND day_start_ut=?\"",
"params",
"=",
"(",
"trip_I",
",",
"day_start_ut",
")",
"cur",
"=",
"self",
".",
"conn",
".",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.day_start_ut | Convert unixtime to unixtime on GTFS start-of-day.
GTFS defines the start of a day as "noon minus 12 hours" to solve
most DST-related problems. This means that on DST-changing days,
the day start isn't midnight. This function isn't idempotent.
Running it twice on the "move clocks backwa... | gtfspy/gtfs.py | def day_start_ut(self, ut):
"""
Convert unixtime to unixtime on GTFS start-of-day.
GTFS defines the start of a day as "noon minus 12 hours" to solve
most DST-related problems. This means that on DST-changing days,
the day start isn't midnight. This function isn't idempotent.
... | def day_start_ut(self, ut):
"""
Convert unixtime to unixtime on GTFS start-of-day.
GTFS defines the start of a day as "noon minus 12 hours" to solve
most DST-related problems. This means that on DST-changing days,
the day start isn't midnight. This function isn't idempotent.
... | [
"Convert",
"unixtime",
"to",
"unixtime",
"on",
"GTFS",
"start",
"-",
"of",
"-",
"day",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1087-L1111 | [
"def",
"day_start_ut",
"(",
"self",
",",
"ut",
")",
":",
"# set timezone to the one of gtfs",
"old_tz",
"=",
"self",
".",
"set_current_process_time_zone",
"(",
")",
"ut",
"=",
"time",
".",
"mktime",
"(",
"time",
".",
"localtime",
"(",
"ut",
")",
"[",
":",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.increment_day_start_ut | Increment the GTFS-definition of "day start".
Parameters
----------
day_start_ut : int
unixtime of the previous start of day. If this time is between
12:00 or greater, there *will* be bugs. To solve this, run the
input through day_start_ut first.
n_... | gtfspy/gtfs.py | def increment_day_start_ut(self, day_start_ut, n_days=1):
"""Increment the GTFS-definition of "day start".
Parameters
----------
day_start_ut : int
unixtime of the previous start of day. If this time is between
12:00 or greater, there *will* be bugs. To solve t... | def increment_day_start_ut(self, day_start_ut, n_days=1):
"""Increment the GTFS-definition of "day start".
Parameters
----------
day_start_ut : int
unixtime of the previous start of day. If this time is between
12:00 or greater, there *will* be bugs. To solve t... | [
"Increment",
"the",
"GTFS",
"-",
"definition",
"of",
"day",
"start",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1113-L1131 | [
"def",
"increment_day_start_ut",
"(",
"self",
",",
"day_start_ut",
",",
"n_days",
"=",
"1",
")",
":",
"old_tz",
"=",
"self",
".",
"set_current_process_time_zone",
"(",
")",
"day0",
"=",
"time",
".",
"localtime",
"(",
"day_start_ut",
"+",
"43200",
")",
"# tim... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS._get_possible_day_starts | Get all possible day start times between start_ut and end_ut
Currently this function is used only by get_tripIs_within_range_by_dsut
Parameters
----------
start_ut : list<int>
start time in unix time
end_ut : list<int>
end time in unix time
max_ti... | gtfspy/gtfs.py | def _get_possible_day_starts(self, start_ut, end_ut, max_time_overnight=None):
"""
Get all possible day start times between start_ut and end_ut
Currently this function is used only by get_tripIs_within_range_by_dsut
Parameters
----------
start_ut : list<int>
... | def _get_possible_day_starts(self, start_ut, end_ut, max_time_overnight=None):
"""
Get all possible day start times between start_ut and end_ut
Currently this function is used only by get_tripIs_within_range_by_dsut
Parameters
----------
start_ut : list<int>
... | [
"Get",
"all",
"possible",
"day",
"start",
"times",
"between",
"start_ut",
"and",
"end_ut",
"Currently",
"this",
"function",
"is",
"used",
"only",
"by",
"get_tripIs_within_range_by_dsut"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1133-L1202 | [
"def",
"_get_possible_day_starts",
"(",
"self",
",",
"start_ut",
",",
"end_ut",
",",
"max_time_overnight",
"=",
"None",
")",
":",
"if",
"max_time_overnight",
"is",
"None",
":",
"# 7 hours:",
"max_time_overnight",
"=",
"7",
"*",
"60",
"*",
"60",
"# sanity checks ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_tripIs_within_range_by_dsut | Obtain a list of trip_Is that take place during a time interval.
The trip needs to be only partially overlapping with the given time interval.
The grouping by dsut (day_start_ut) is required as same trip_I could
take place on multiple days.
Parameters
----------
start_ti... | gtfspy/gtfs.py | def get_tripIs_within_range_by_dsut(self,
start_time_ut,
end_time_ut):
"""
Obtain a list of trip_Is that take place during a time interval.
The trip needs to be only partially overlapping with the given time interval... | def get_tripIs_within_range_by_dsut(self,
start_time_ut,
end_time_ut):
"""
Obtain a list of trip_Is that take place during a time interval.
The trip needs to be only partially overlapping with the given time interval... | [
"Obtain",
"a",
"list",
"of",
"trip_Is",
"that",
"take",
"place",
"during",
"a",
"time",
"interval",
".",
"The",
"trip",
"needs",
"to",
"be",
"only",
"partially",
"overlapping",
"with",
"the",
"given",
"time",
"interval",
".",
"The",
"grouping",
"by",
"dsut... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1204-L1251 | [
"def",
"get_tripIs_within_range_by_dsut",
"(",
"self",
",",
"start_time_ut",
",",
"end_time_ut",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"assert",
"start_time_ut",
"<=",
"end_time_ut",
"dst_ut",
",",
"st_ds",
",",
"et_ds",
"=",
"s... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.stop | Get all stop data as a pandas DataFrame for all stops, or an individual stop'
Parameters
----------
stop_I : int
stop index
Returns
-------
stop: pandas.DataFrame | gtfspy/gtfs.py | def stop(self, stop_I):
"""
Get all stop data as a pandas DataFrame for all stops, or an individual stop'
Parameters
----------
stop_I : int
stop index
Returns
-------
stop: pandas.DataFrame
"""
return pd.read_sql_query("SELEC... | def stop(self, stop_I):
"""
Get all stop data as a pandas DataFrame for all stops, or an individual stop'
Parameters
----------
stop_I : int
stop index
Returns
-------
stop: pandas.DataFrame
"""
return pd.read_sql_query("SELEC... | [
"Get",
"all",
"stop",
"data",
"as",
"a",
"pandas",
"DataFrame",
"for",
"all",
"stops",
"or",
"an",
"individual",
"stop"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1263-L1276 | [
"def",
"stop",
"(",
"self",
",",
"stop_I",
")",
":",
"return",
"pd",
".",
"read_sql_query",
"(",
"\"SELECT * FROM stops WHERE stop_I={stop_I}\"",
".",
"format",
"(",
"stop_I",
"=",
"stop_I",
")",
",",
"self",
".",
"conn",
")"
] | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_stops_for_route_type | Parameters
----------
route_type: int
Returns
-------
stops: pandas.DataFrame | gtfspy/gtfs.py | def get_stops_for_route_type(self, route_type):
"""
Parameters
----------
route_type: int
Returns
-------
stops: pandas.DataFrame
"""
if route_type is WALK:
return self.stops()
else:
return pd.read_sql_query("SELEC... | def get_stops_for_route_type(self, route_type):
"""
Parameters
----------
route_type: int
Returns
-------
stops: pandas.DataFrame
"""
if route_type is WALK:
return self.stops()
else:
return pd.read_sql_query("SELEC... | [
"Parameters",
"----------",
"route_type",
":",
"int"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1296-L1314 | [
"def",
"get_stops_for_route_type",
"(",
"self",
",",
"route_type",
")",
":",
"if",
"route_type",
"is",
"WALK",
":",
"return",
"self",
".",
"stops",
"(",
")",
"else",
":",
"return",
"pd",
".",
"read_sql_query",
"(",
"\"SELECT DISTINCT stops.* \"",
"\"FROM stops J... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.generate_routable_transit_events | Generates events that take place during a time interval [start_time_ut, end_time_ut].
Each event needs to be only partially overlap the given time interval.
Does not include walking events.
This is just a quick and dirty implementation to get a way of quickly get a
method for generating ... | gtfspy/gtfs.py | def generate_routable_transit_events(self, start_time_ut=None, end_time_ut=None, route_type=None):
"""
Generates events that take place during a time interval [start_time_ut, end_time_ut].
Each event needs to be only partially overlap the given time interval.
Does not include walking eve... | def generate_routable_transit_events(self, start_time_ut=None, end_time_ut=None, route_type=None):
"""
Generates events that take place during a time interval [start_time_ut, end_time_ut].
Each event needs to be only partially overlap the given time interval.
Does not include walking eve... | [
"Generates",
"events",
"that",
"take",
"place",
"during",
"a",
"time",
"interval",
"[",
"start_time_ut",
"end_time_ut",
"]",
".",
"Each",
"event",
"needs",
"to",
"be",
"only",
"partially",
"overlap",
"the",
"given",
"time",
"interval",
".",
"Does",
"not",
"i... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1319-L1350 | [
"def",
"generate_routable_transit_events",
"(",
"self",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
",",
"route_type",
"=",
"None",
")",
":",
"from",
"gtfspy",
".",
"networks",
"import",
"temporal_network",
"df",
"=",
"temporal_network",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_transit_events | Obtain a list of events that take place during a time interval.
Each event needs to be only partially overlap the given time interval.
Does not include walking events.
Parameters
----------
start_time_ut : int
start of the time interval in unix time (seconds)
... | gtfspy/gtfs.py | def get_transit_events(self, start_time_ut=None, end_time_ut=None, route_type=None):
"""
Obtain a list of events that take place during a time interval.
Each event needs to be only partially overlap the given time interval.
Does not include walking events.
Parameters
---... | def get_transit_events(self, start_time_ut=None, end_time_ut=None, route_type=None):
"""
Obtain a list of events that take place during a time interval.
Each event needs to be only partially overlap the given time interval.
Does not include walking events.
Parameters
---... | [
"Obtain",
"a",
"list",
"of",
"events",
"that",
"take",
"place",
"during",
"a",
"time",
"interval",
".",
"Each",
"event",
"needs",
"to",
"be",
"only",
"partially",
"overlap",
"the",
"given",
"time",
"interval",
".",
"Does",
"not",
"include",
"walking",
"eve... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1352-L1438 | [
"def",
"get_transit_events",
"(",
"self",
",",
"start_time_ut",
"=",
"None",
",",
"end_time_ut",
"=",
"None",
",",
"route_type",
"=",
"None",
")",
":",
"table_name",
"=",
"self",
".",
"_get_day_trips_table_name",
"(",
")",
"event_query",
"=",
"\"SELECT stop_I, s... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_route_difference_with_other_db | Compares the routes based on stops in the schedule with the routes in another db and returns the ones without match.
Uniqueness thresholds or ratio can be used to allow small differences
:param uniqueness_threshold:
:param uniqueness_ratio:
:return: | gtfspy/gtfs.py | def get_route_difference_with_other_db(self, other_gtfs, start_time, end_time, uniqueness_threshold=None,
uniqueness_ratio=None):
"""
Compares the routes based on stops in the schedule with the routes in another db and returns the ones without match.
Un... | def get_route_difference_with_other_db(self, other_gtfs, start_time, end_time, uniqueness_threshold=None,
uniqueness_ratio=None):
"""
Compares the routes based on stops in the schedule with the routes in another db and returns the ones without match.
Un... | [
"Compares",
"the",
"routes",
"based",
"on",
"stops",
"in",
"the",
"schedule",
"with",
"the",
"routes",
"in",
"another",
"db",
"and",
"returns",
"the",
"ones",
"without",
"match",
".",
"Uniqueness",
"thresholds",
"or",
"ratio",
"can",
"be",
"used",
"to",
"a... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1440-L1482 | [
"def",
"get_route_difference_with_other_db",
"(",
"self",
",",
"other_gtfs",
",",
"start_time",
",",
"end_time",
",",
"uniqueness_threshold",
"=",
"None",
",",
"uniqueness_ratio",
"=",
"None",
")",
":",
"from",
"gtfspy",
".",
"stats",
"import",
"frequencies_by_gener... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_straight_line_transfer_distances | Get (straight line) distances to stations that can be transferred to.
Parameters
----------
stop_I : int, optional
If not specified return all possible transfer distances
Returns
-------
distances: pandas.DataFrame
each row has the following item... | gtfspy/gtfs.py | def get_straight_line_transfer_distances(self, stop_I=None):
"""
Get (straight line) distances to stations that can be transferred to.
Parameters
----------
stop_I : int, optional
If not specified return all possible transfer distances
Returns
------... | def get_straight_line_transfer_distances(self, stop_I=None):
"""
Get (straight line) distances to stations that can be transferred to.
Parameters
----------
stop_I : int, optional
If not specified return all possible transfer distances
Returns
------... | [
"Get",
"(",
"straight",
"line",
")",
"distances",
"to",
"stations",
"that",
"can",
"be",
"transferred",
"to",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1519-L1549 | [
"def",
"get_straight_line_transfer_distances",
"(",
"self",
",",
"stop_I",
"=",
"None",
")",
":",
"if",
"stop_I",
"is",
"not",
"None",
":",
"query",
"=",
"u\"\"\" SELECT from_stop_I, to_stop_I, d\n FROM stop_distances\n WHERE\n ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.get_day_start_ut_span | Return the first and last day_start_ut
Returns
-------
first_day_start_ut: int
last_day_start_ut: int | gtfspy/gtfs.py | def get_day_start_ut_span(self):
"""
Return the first and last day_start_ut
Returns
-------
first_day_start_ut: int
last_day_start_ut: int
"""
cur = self.conn.cursor()
first_day_start_ut, last_day_start_ut = \
cur.execute("SELECT min(d... | def get_day_start_ut_span(self):
"""
Return the first and last day_start_ut
Returns
-------
first_day_start_ut: int
last_day_start_ut: int
"""
cur = self.conn.cursor()
first_day_start_ut, last_day_start_ut = \
cur.execute("SELECT min(d... | [
"Return",
"the",
"first",
"and",
"last",
"day_start_ut"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1569-L1581 | [
"def",
"get_day_start_ut_span",
"(",
"self",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"first_day_start_ut",
",",
"last_day_start_ut",
"=",
"cur",
".",
"execute",
"(",
"\"SELECT min(day_start_ut), max(day_start_ut) FROM days;\"",
")",
".",
... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | GTFS.homogenize_stops_table_with_other_db | This function takes an external database, looks of common stops and adds the missing stops to both databases.
In addition the stop_pair_I column is added. This id links the stops between these two sources.
:param source: directory of external database
:return: | gtfspy/gtfs.py | def homogenize_stops_table_with_other_db(self, source):
"""
This function takes an external database, looks of common stops and adds the missing stops to both databases.
In addition the stop_pair_I column is added. This id links the stops between these two sources.
:param source: directo... | def homogenize_stops_table_with_other_db(self, source):
"""
This function takes an external database, looks of common stops and adds the missing stops to both databases.
In addition the stop_pair_I column is added. This id links the stops between these two sources.
:param source: directo... | [
"This",
"function",
"takes",
"an",
"external",
"database",
"looks",
"of",
"common",
"stops",
"and",
"adds",
"the",
"missing",
"stops",
"to",
"both",
"databases",
".",
"In",
"addition",
"the",
"stop_pair_I",
"column",
"is",
"added",
".",
"This",
"id",
"links"... | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1622-L1692 | [
"def",
"homogenize_stops_table_with_other_db",
"(",
"self",
",",
"source",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"self",
".",
"attach_gtfs_database",
"(",
"source",
")",
"query_inner_join",
"=",
"\"\"\"SELECT t1.*\n ... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | TravelImpedanceDataStore.read_data_as_dataframe | Recover pre-computed travel_impedance between od-pairs from the database.
Returns
-------
values: number | Pandas DataFrame | gtfspy/routing/travel_impedance_data_store.py | def read_data_as_dataframe(self,
travel_impedance_measure,
from_stop_I=None,
to_stop_I=None,
statistic=None):
"""
Recover pre-computed travel_impedance between od-pairs from the da... | def read_data_as_dataframe(self,
travel_impedance_measure,
from_stop_I=None,
to_stop_I=None,
statistic=None):
"""
Recover pre-computed travel_impedance between od-pairs from the da... | [
"Recover",
"pre",
"-",
"computed",
"travel_impedance",
"between",
"od",
"-",
"pairs",
"from",
"the",
"database",
"."
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/travel_impedance_data_store.py#L12-L44 | [
"def",
"read_data_as_dataframe",
"(",
"self",
",",
"travel_impedance_measure",
",",
"from_stop_I",
"=",
"None",
",",
"to_stop_I",
"=",
"None",
",",
"statistic",
"=",
"None",
")",
":",
"to_select",
"=",
"[",
"]",
"where_clauses",
"=",
"[",
"]",
"to_select",
"... | bddba4b74faae6c1b91202f19184811e326547e5 |
valid | TravelImpedanceDataStore.insert_data | Parameters
----------
travel_impedance_measure_name: str
data: list[dict]
Each list element must contain keys:
"from_stop_I", "to_stop_I", "min", "max", "median" and "mean" | gtfspy/routing/travel_impedance_data_store.py | def insert_data(self, travel_impedance_measure_name, data):
"""
Parameters
----------
travel_impedance_measure_name: str
data: list[dict]
Each list element must contain keys:
"from_stop_I", "to_stop_I", "min", "max", "median" and "mean"
"""
... | def insert_data(self, travel_impedance_measure_name, data):
"""
Parameters
----------
travel_impedance_measure_name: str
data: list[dict]
Each list element must contain keys:
"from_stop_I", "to_stop_I", "min", "max", "median" and "mean"
"""
... | [
"Parameters",
"----------",
"travel_impedance_measure_name",
":",
"str",
"data",
":",
"list",
"[",
"dict",
"]",
"Each",
"list",
"element",
"must",
"contain",
"keys",
":",
"from_stop_I",
"to_stop_I",
"min",
"max",
"median",
"and",
"mean"
] | CxAalto/gtfspy | python | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/travel_impedance_data_store.py#L83-L103 | [
"def",
"insert_data",
"(",
"self",
",",
"travel_impedance_measure_name",
",",
"data",
")",
":",
"f",
"=",
"float",
"data_tuple",
"=",
"[",
"(",
"int",
"(",
"x",
"[",
"\"from_stop_I\"",
"]",
")",
",",
"int",
"(",
"x",
"[",
"\"to_stop_I\"",
"]",
")",
","... | bddba4b74faae6c1b91202f19184811e326547e5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.