repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
google/transitfeed | merge.py | HTMLProblemAccumulator._GenerateSummary | def _GenerateSummary(self):
"""Generate a summary of the warnings and errors.
Returns:
The generated HTML as a string.
"""
items = []
if self._notices:
items.append('notices: %d' % self._notice_count)
if self._dataset_errors:
items.append('errors: %d' % self._error_count)
... | python | def _GenerateSummary(self):
"""Generate a summary of the warnings and errors.
Returns:
The generated HTML as a string.
"""
items = []
if self._notices:
items.append('notices: %d' % self._notice_count)
if self._dataset_errors:
items.append('errors: %d' % self._error_count)
... | [
"def",
"_GenerateSummary",
"(",
"self",
")",
":",
"items",
"=",
"[",
"]",
"if",
"self",
".",
"_notices",
":",
"items",
".",
"append",
"(",
"'notices: %d'",
"%",
"self",
".",
"_notice_count",
")",
"if",
"self",
".",
"_dataset_errors",
":",
"items",
".",
... | Generate a summary of the warnings and errors.
Returns:
The generated HTML as a string. | [
"Generate",
"a",
"summary",
"of",
"the",
"warnings",
"and",
"errors",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L246-L263 | train |
google/transitfeed | merge.py | HTMLProblemAccumulator._GenerateNotices | def _GenerateNotices(self):
"""Generate a summary of any notices.
Returns:
The generated HTML as a string.
"""
items = []
for e in self._notices:
d = e.GetDictToFormat()
if 'url' in d.keys():
d['url'] = '<a href="%(url)s">%(url)s</a>' % d
items.append('<li class="not... | python | def _GenerateNotices(self):
"""Generate a summary of any notices.
Returns:
The generated HTML as a string.
"""
items = []
for e in self._notices:
d = e.GetDictToFormat()
if 'url' in d.keys():
d['url'] = '<a href="%(url)s">%(url)s</a>' % d
items.append('<li class="not... | [
"def",
"_GenerateNotices",
"(",
"self",
")",
":",
"items",
"=",
"[",
"]",
"for",
"e",
"in",
"self",
".",
"_notices",
":",
"d",
"=",
"e",
".",
"GetDictToFormat",
"(",
")",
"if",
"'url'",
"in",
"d",
".",
"keys",
"(",
")",
":",
"d",
"[",
"'url'",
... | Generate a summary of any notices.
Returns:
The generated HTML as a string. | [
"Generate",
"a",
"summary",
"of",
"any",
"notices",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L265-L281 | train |
google/transitfeed | merge.py | DataSetMerger._MergeIdentical | def _MergeIdentical(self, a, b):
"""Tries to merge two values. The values are required to be identical.
Args:
a: The first value.
b: The second value.
Returns:
The trivially merged value.
Raises:
MergeError: The values were not identical.
"""
if a != b:
raise Mer... | python | def _MergeIdentical(self, a, b):
"""Tries to merge two values. The values are required to be identical.
Args:
a: The first value.
b: The second value.
Returns:
The trivially merged value.
Raises:
MergeError: The values were not identical.
"""
if a != b:
raise Mer... | [
"def",
"_MergeIdentical",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"if",
"a",
"!=",
"b",
":",
"raise",
"MergeError",
"(",
"\"values must be identical ('%s' vs '%s')\"",
"%",
"(",
"transitfeed",
".",
"EncodeUnicode",
"(",
"a",
")",
",",
"transitfeed",
".",
... | Tries to merge two values. The values are required to be identical.
Args:
a: The first value.
b: The second value.
Returns:
The trivially merged value.
Raises:
MergeError: The values were not identical. | [
"Tries",
"to",
"merge",
"two",
"values",
".",
"The",
"values",
"are",
"required",
"to",
"be",
"identical",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L394-L411 | train |
google/transitfeed | merge.py | DataSetMerger._MergeIdenticalCaseInsensitive | def _MergeIdenticalCaseInsensitive(self, a, b):
"""Tries to merge two strings.
The string are required to be the same ignoring case. The second string is
always used as the merged value.
Args:
a: The first string.
b: The second string.
Returns:
The merged string. This is equal t... | python | def _MergeIdenticalCaseInsensitive(self, a, b):
"""Tries to merge two strings.
The string are required to be the same ignoring case. The second string is
always used as the merged value.
Args:
a: The first string.
b: The second string.
Returns:
The merged string. This is equal t... | [
"def",
"_MergeIdenticalCaseInsensitive",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"if",
"a",
".",
"lower",
"(",
")",
"!=",
"b",
".",
"lower",
"(",
")",
":",
"raise",
"MergeError",
"(",
"\"values must be the same (case insensitive) \"",
"\"('%s' vs '%s')\"",
... | Tries to merge two strings.
The string are required to be the same ignoring case. The second string is
always used as the merged value.
Args:
a: The first string.
b: The second string.
Returns:
The merged string. This is equal to the second string.
Raises:
MergeError: The... | [
"Tries",
"to",
"merge",
"two",
"strings",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L413-L433 | train |
google/transitfeed | merge.py | DataSetMerger._MergeOptional | def _MergeOptional(self, a, b):
"""Tries to merge two values which may be None.
If both values are not None, they are required to be the same and the
merge is trivial. If one of the values is None and the other is not None,
the merge results in the one which is not None. If both are None, the merge
... | python | def _MergeOptional(self, a, b):
"""Tries to merge two values which may be None.
If both values are not None, they are required to be the same and the
merge is trivial. If one of the values is None and the other is not None,
the merge results in the one which is not None. If both are None, the merge
... | [
"def",
"_MergeOptional",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"if",
"a",
"and",
"b",
":",
"if",
"a",
"!=",
"b",
":",
"raise",
"MergeError",
"(",
"\"values must be identical if both specified \"",
"\"('%s' vs '%s')\"",
"%",
"(",
"transitfeed",
".",
"Enc... | Tries to merge two values which may be None.
If both values are not None, they are required to be the same and the
merge is trivial. If one of the values is None and the other is not None,
the merge results in the one which is not None. If both are None, the merge
results in None.
Args:
a: T... | [
"Tries",
"to",
"merge",
"two",
"values",
"which",
"may",
"be",
"None",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L435-L458 | train |
google/transitfeed | merge.py | DataSetMerger._MergeSameAgency | def _MergeSameAgency(self, a_agency_id, b_agency_id):
"""Merge agency ids to the corresponding agency id in the merged schedule.
Args:
a_agency_id: an agency id from the old schedule
b_agency_id: an agency id from the new schedule
Returns:
The agency id of the corresponding merged agency... | python | def _MergeSameAgency(self, a_agency_id, b_agency_id):
"""Merge agency ids to the corresponding agency id in the merged schedule.
Args:
a_agency_id: an agency id from the old schedule
b_agency_id: an agency id from the new schedule
Returns:
The agency id of the corresponding merged agency... | [
"def",
"_MergeSameAgency",
"(",
"self",
",",
"a_agency_id",
",",
"b_agency_id",
")",
":",
"a_agency_id",
"=",
"(",
"a_agency_id",
"or",
"self",
".",
"feed_merger",
".",
"a_schedule",
".",
"GetDefaultAgency",
"(",
")",
".",
"agency_id",
")",
"b_agency_id",
"=",... | Merge agency ids to the corresponding agency id in the merged schedule.
Args:
a_agency_id: an agency id from the old schedule
b_agency_id: an agency id from the new schedule
Returns:
The agency id of the corresponding merged agency.
Raises:
MergeError: If a_agency_id and b_agency_... | [
"Merge",
"agency",
"ids",
"to",
"the",
"corresponding",
"agency",
"id",
"in",
"the",
"merged",
"schedule",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L460-L485 | train |
google/transitfeed | merge.py | DataSetMerger._SchemedMerge | def _SchemedMerge(self, scheme, a, b):
"""Tries to merge two entities according to a merge scheme.
A scheme is specified by a map where the keys are entity attributes and the
values are merge functions like Merger._MergeIdentical or
Merger._MergeOptional. The entity is first migrated to the merged sche... | python | def _SchemedMerge(self, scheme, a, b):
"""Tries to merge two entities according to a merge scheme.
A scheme is specified by a map where the keys are entity attributes and the
values are merge functions like Merger._MergeIdentical or
Merger._MergeOptional. The entity is first migrated to the merged sche... | [
"def",
"_SchemedMerge",
"(",
"self",
",",
"scheme",
",",
"a",
",",
"b",
")",
":",
"migrated",
"=",
"self",
".",
"_Migrate",
"(",
"b",
",",
"self",
".",
"feed_merger",
".",
"b_schedule",
",",
"False",
")",
"for",
"attr",
",",
"merger",
"in",
"scheme",... | Tries to merge two entities according to a merge scheme.
A scheme is specified by a map where the keys are entity attributes and the
values are merge functions like Merger._MergeIdentical or
Merger._MergeOptional. The entity is first migrated to the merged schedule.
Then the attributes are individually... | [
"Tries",
"to",
"merge",
"two",
"entities",
"according",
"to",
"a",
"merge",
"scheme",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L487-L517 | train |
google/transitfeed | merge.py | DataSetMerger._MergeSameId | def _MergeSameId(self):
"""Tries to merge entities based on their ids.
This tries to merge only the entities from the old and new schedules which
have the same id. These are added into the merged schedule. Entities which
do not merge or do not have the same id as another entity in the other
schedul... | python | def _MergeSameId(self):
"""Tries to merge entities based on their ids.
This tries to merge only the entities from the old and new schedules which
have the same id. These are added into the merged schedule. Entities which
do not merge or do not have the same id as another entity in the other
schedul... | [
"def",
"_MergeSameId",
"(",
"self",
")",
":",
"a_not_merged",
"=",
"[",
"]",
"b_not_merged",
"=",
"[",
"]",
"for",
"a",
"in",
"self",
".",
"_GetIter",
"(",
"self",
".",
"feed_merger",
".",
"a_schedule",
")",
":",
"try",
":",
"b",
"=",
"self",
".",
... | Tries to merge entities based on their ids.
This tries to merge only the entities from the old and new schedules which
have the same id. These are added into the merged schedule. Entities which
do not merge or do not have the same id as another entity in the other
schedule are simply migrated into the ... | [
"Tries",
"to",
"merge",
"entities",
"based",
"on",
"their",
"ids",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L519-L575 | train |
google/transitfeed | merge.py | DataSetMerger._MergeDifferentId | def _MergeDifferentId(self):
"""Tries to merge all possible combinations of entities.
This tries to merge every entity in the old schedule with every entity in
the new schedule. Unlike _MergeSameId, the ids do not need to match.
However, _MergeDifferentId is much slower than _MergeSameId.
This met... | python | def _MergeDifferentId(self):
"""Tries to merge all possible combinations of entities.
This tries to merge every entity in the old schedule with every entity in
the new schedule. Unlike _MergeSameId, the ids do not need to match.
However, _MergeDifferentId is much slower than _MergeSameId.
This met... | [
"def",
"_MergeDifferentId",
"(",
"self",
")",
":",
"# TODO: The same entity from A could merge with multiple from B.",
"# This should either generate an error or should be prevented from",
"# happening.",
"for",
"a",
"in",
"self",
".",
"_GetIter",
"(",
"self",
".",
"feed_merger",... | Tries to merge all possible combinations of entities.
This tries to merge every entity in the old schedule with every entity in
the new schedule. Unlike _MergeSameId, the ids do not need to match.
However, _MergeDifferentId is much slower than _MergeSameId.
This method makes use of various methods lik... | [
"Tries",
"to",
"merge",
"all",
"possible",
"combinations",
"of",
"entities",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L618-L657 | train |
google/transitfeed | merge.py | DataSetMerger._ReportSameIdButNotMerged | def _ReportSameIdButNotMerged(self, entity_id, reason):
"""Report that two entities have the same id but could not be merged.
Args:
entity_id: The id of the entities.
reason: A string giving a reason why they could not be merged.
"""
self.feed_merger.problem_reporter.SameIdButNotMerged(self... | python | def _ReportSameIdButNotMerged(self, entity_id, reason):
"""Report that two entities have the same id but could not be merged.
Args:
entity_id: The id of the entities.
reason: A string giving a reason why they could not be merged.
"""
self.feed_merger.problem_reporter.SameIdButNotMerged(self... | [
"def",
"_ReportSameIdButNotMerged",
"(",
"self",
",",
"entity_id",
",",
"reason",
")",
":",
"self",
".",
"feed_merger",
".",
"problem_reporter",
".",
"SameIdButNotMerged",
"(",
"self",
",",
"entity_id",
",",
"reason",
")"
] | Report that two entities have the same id but could not be merged.
Args:
entity_id: The id of the entities.
reason: A string giving a reason why they could not be merged. | [
"Report",
"that",
"two",
"entities",
"have",
"the",
"same",
"id",
"but",
"could",
"not",
"be",
"merged",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L659-L668 | train |
google/transitfeed | merge.py | DataSetMerger._HasId | def _HasId(self, schedule, entity_id):
"""Check if the schedule has an entity with the given id.
Args:
schedule: The transitfeed.Schedule instance to look in.
entity_id: The id of the entity.
Returns:
True if the schedule has an entity with the id or False if not.
"""
try:
... | python | def _HasId(self, schedule, entity_id):
"""Check if the schedule has an entity with the given id.
Args:
schedule: The transitfeed.Schedule instance to look in.
entity_id: The id of the entity.
Returns:
True if the schedule has an entity with the id or False if not.
"""
try:
... | [
"def",
"_HasId",
"(",
"self",
",",
"schedule",
",",
"entity_id",
")",
":",
"try",
":",
"self",
".",
"_GetById",
"(",
"schedule",
",",
"entity_id",
")",
"has",
"=",
"True",
"except",
"KeyError",
":",
"has",
"=",
"False",
"return",
"has"
] | Check if the schedule has an entity with the given id.
Args:
schedule: The transitfeed.Schedule instance to look in.
entity_id: The id of the entity.
Returns:
True if the schedule has an entity with the id or False if not. | [
"Check",
"if",
"the",
"schedule",
"has",
"an",
"entity",
"with",
"the",
"given",
"id",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L708-L723 | train |
google/transitfeed | merge.py | AgencyMerger._MergeEntities | def _MergeEntities(self, a, b):
"""Merges two agencies.
To be merged, they are required to have the same id, name, url and
timezone. The remaining language attribute is taken from the new agency.
Args:
a: The first agency.
b: The second agency.
Returns:
The merged agency.
R... | python | def _MergeEntities(self, a, b):
"""Merges two agencies.
To be merged, they are required to have the same id, name, url and
timezone. The remaining language attribute is taken from the new agency.
Args:
a: The first agency.
b: The second agency.
Returns:
The merged agency.
R... | [
"def",
"_MergeEntities",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"def",
"_MergeAgencyId",
"(",
"a_agency_id",
",",
"b_agency_id",
")",
":",
"\"\"\"Merge two agency ids.\n\n The only difference between this and _MergeIdentical() is that the values\n None and '' are re... | Merges two agencies.
To be merged, they are required to have the same id, name, url and
timezone. The remaining language attribute is taken from the new agency.
Args:
a: The first agency.
b: The second agency.
Returns:
The merged agency.
Raises:
MergeError: The agencies c... | [
"Merges",
"two",
"agencies",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L841-L882 | train |
google/transitfeed | merge.py | StopMerger._MergeEntities | def _MergeEntities(self, a, b):
"""Merges two stops.
For the stops to be merged, they must have:
- the same stop_id
- the same stop_name (case insensitive)
- the same zone_id
- locations less than largest_stop_distance apart
The other attributes can have arbitary changes. The merged... | python | def _MergeEntities(self, a, b):
"""Merges two stops.
For the stops to be merged, they must have:
- the same stop_id
- the same stop_name (case insensitive)
- the same zone_id
- locations less than largest_stop_distance apart
The other attributes can have arbitary changes. The merged... | [
"def",
"_MergeEntities",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"distance",
"=",
"transitfeed",
".",
"ApproximateDistanceBetweenStops",
"(",
"a",
",",
"b",
")",
"if",
"distance",
">",
"self",
".",
"largest_stop_distance",
":",
"raise",
"MergeError",
"(",... | Merges two stops.
For the stops to be merged, they must have:
- the same stop_id
- the same stop_name (case insensitive)
- the same zone_id
- locations less than largest_stop_distance apart
The other attributes can have arbitary changes. The merged attributes are
taken from the new ... | [
"Merges",
"two",
"stops",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L932-L962 | train |
google/transitfeed | merge.py | StopMerger._UpdateAndMigrateUnmerged | def _UpdateAndMigrateUnmerged(self, not_merged_stops, zone_map, merge_map,
schedule):
"""Correct references in migrated unmerged stops and add to merged_schedule.
For stops migrated from one of the input feeds to the output feed update the
parent_station and zone_id referenc... | python | def _UpdateAndMigrateUnmerged(self, not_merged_stops, zone_map, merge_map,
schedule):
"""Correct references in migrated unmerged stops and add to merged_schedule.
For stops migrated from one of the input feeds to the output feed update the
parent_station and zone_id referenc... | [
"def",
"_UpdateAndMigrateUnmerged",
"(",
"self",
",",
"not_merged_stops",
",",
"zone_map",
",",
"merge_map",
",",
"schedule",
")",
":",
"# for the unmerged stops, we use an already mapped zone_id if possible",
"# if not, we generate a new one and add it to the map",
"for",
"stop",
... | Correct references in migrated unmerged stops and add to merged_schedule.
For stops migrated from one of the input feeds to the output feed update the
parent_station and zone_id references to point to objects in the output
feed. Then add the migrated stop to the new schedule.
Args:
not_merged_st... | [
"Correct",
"references",
"in",
"migrated",
"unmerged",
"stops",
"and",
"add",
"to",
"merged_schedule",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1014-L1041 | train |
google/transitfeed | merge.py | ServicePeriodMerger.DisjoinCalendars | def DisjoinCalendars(self, cutoff):
"""Forces the old and new calendars to be disjoint about a cutoff date.
This truncates the service periods of the old schedule so that service
stops one day before the given cutoff date and truncates the new schedule
so that service only begins on the cutoff date.
... | python | def DisjoinCalendars(self, cutoff):
"""Forces the old and new calendars to be disjoint about a cutoff date.
This truncates the service periods of the old schedule so that service
stops one day before the given cutoff date and truncates the new schedule
so that service only begins on the cutoff date.
... | [
"def",
"DisjoinCalendars",
"(",
"self",
",",
"cutoff",
")",
":",
"def",
"TruncatePeriod",
"(",
"service_period",
",",
"start",
",",
"end",
")",
":",
"\"\"\"Truncate the service period to into the range [start, end].\n\n Args:\n service_period: The service period to tr... | Forces the old and new calendars to be disjoint about a cutoff date.
This truncates the service periods of the old schedule so that service
stops one day before the given cutoff date and truncates the new schedule
so that service only begins on the cutoff date.
Args:
cutoff: The cutoff date as a... | [
"Forces",
"the",
"old",
"and",
"new",
"calendars",
"to",
"be",
"disjoint",
"about",
"a",
"cutoff",
"date",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1166-L1206 | train |
google/transitfeed | merge.py | ServicePeriodMerger.CheckDisjointCalendars | def CheckDisjointCalendars(self):
"""Check whether any old service periods intersect with any new ones.
This is a rather coarse check based on
transitfeed.SevicePeriod.GetDateRange.
Returns:
True if the calendars are disjoint or False if not.
"""
# TODO: Do an exact check here.
a_se... | python | def CheckDisjointCalendars(self):
"""Check whether any old service periods intersect with any new ones.
This is a rather coarse check based on
transitfeed.SevicePeriod.GetDateRange.
Returns:
True if the calendars are disjoint or False if not.
"""
# TODO: Do an exact check here.
a_se... | [
"def",
"CheckDisjointCalendars",
"(",
"self",
")",
":",
"# TODO: Do an exact check here.",
"a_service_periods",
"=",
"self",
".",
"feed_merger",
".",
"a_schedule",
".",
"GetServicePeriodList",
"(",
")",
"b_service_periods",
"=",
"self",
".",
"feed_merger",
".",
"b_sch... | Check whether any old service periods intersect with any new ones.
This is a rather coarse check based on
transitfeed.SevicePeriod.GetDateRange.
Returns:
True if the calendars are disjoint or False if not. | [
"Check",
"whether",
"any",
"old",
"service",
"periods",
"intersect",
"with",
"any",
"new",
"ones",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1208-L1230 | train |
google/transitfeed | merge.py | FareMerger._MergeEntities | def _MergeEntities(self, a, b):
"""Merges the fares if all the attributes are the same."""
scheme = {'price': self._MergeIdentical,
'currency_type': self._MergeIdentical,
'payment_method': self._MergeIdentical,
'transfers': self._MergeIdentical,
'transfer_... | python | def _MergeEntities(self, a, b):
"""Merges the fares if all the attributes are the same."""
scheme = {'price': self._MergeIdentical,
'currency_type': self._MergeIdentical,
'payment_method': self._MergeIdentical,
'transfers': self._MergeIdentical,
'transfer_... | [
"def",
"_MergeEntities",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"scheme",
"=",
"{",
"'price'",
":",
"self",
".",
"_MergeIdentical",
",",
"'currency_type'",
":",
"self",
".",
"_MergeIdentical",
",",
"'payment_method'",
":",
"self",
".",
"_MergeIdentical",... | Merges the fares if all the attributes are the same. | [
"Merges",
"the",
"fares",
"if",
"all",
"the",
"attributes",
"are",
"the",
"same",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1249-L1256 | train |
google/transitfeed | merge.py | ShapeMerger._MergeEntities | def _MergeEntities(self, a, b):
"""Merges the shapes by taking the new shape.
Args:
a: The first transitfeed.Shape instance.
b: The second transitfeed.Shape instance.
Returns:
The merged shape.
Raises:
MergeError: If the ids are different or if the endpoints are further
... | python | def _MergeEntities(self, a, b):
"""Merges the shapes by taking the new shape.
Args:
a: The first transitfeed.Shape instance.
b: The second transitfeed.Shape instance.
Returns:
The merged shape.
Raises:
MergeError: If the ids are different or if the endpoints are further
... | [
"def",
"_MergeEntities",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"if",
"a",
".",
"shape_id",
"!=",
"b",
".",
"shape_id",
":",
"raise",
"MergeError",
"(",
"'shape_id must be the same'",
")",
"distance",
"=",
"max",
"(",
"ApproximateDistanceBetweenPoints",
... | Merges the shapes by taking the new shape.
Args:
a: The first transitfeed.Shape instance.
b: The second transitfeed.Shape instance.
Returns:
The merged shape.
Raises:
MergeError: If the ids are different or if the endpoints are further
than largest_shape_distance... | [
"Merges",
"the",
"shapes",
"by",
"taking",
"the",
"new",
"shape",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1361-L1387 | train |
google/transitfeed | merge.py | FareRuleMerger.MergeDataSets | def MergeDataSets(self):
"""Merge the fare rule datasets.
The fare rules are first migrated. Merging is done by removing any
duplicate rules.
Returns:
True since fare rules can always be merged.
"""
rules = set()
for (schedule, merge_map, zone_map) in ([self.feed_merger.a_schedule,
... | python | def MergeDataSets(self):
"""Merge the fare rule datasets.
The fare rules are first migrated. Merging is done by removing any
duplicate rules.
Returns:
True since fare rules can always be merged.
"""
rules = set()
for (schedule, merge_map, zone_map) in ([self.feed_merger.a_schedule,
... | [
"def",
"MergeDataSets",
"(",
"self",
")",
":",
"rules",
"=",
"set",
"(",
")",
"for",
"(",
"schedule",
",",
"merge_map",
",",
"zone_map",
")",
"in",
"(",
"[",
"self",
".",
"feed_merger",
".",
"a_schedule",
",",
"self",
".",
"feed_merger",
".",
"a_merge_... | Merge the fare rule datasets.
The fare rules are first migrated. Merging is done by removing any
duplicate rules.
Returns:
True since fare rules can always be merged. | [
"Merge",
"the",
"fare",
"rule",
"datasets",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1510-L1547 | train |
google/transitfeed | merge.py | FeedMerger._FindLargestIdPostfixNumber | def _FindLargestIdPostfixNumber(self, schedule):
"""Finds the largest integer used as the ending of an id in the schedule.
Args:
schedule: The schedule to check.
Returns:
The maximum integer used as an ending for an id.
"""
postfix_number_re = re.compile('(\d+)$')
def ExtractPostf... | python | def _FindLargestIdPostfixNumber(self, schedule):
"""Finds the largest integer used as the ending of an id in the schedule.
Args:
schedule: The schedule to check.
Returns:
The maximum integer used as an ending for an id.
"""
postfix_number_re = re.compile('(\d+)$')
def ExtractPostf... | [
"def",
"_FindLargestIdPostfixNumber",
"(",
"self",
",",
"schedule",
")",
":",
"postfix_number_re",
"=",
"re",
".",
"compile",
"(",
"'(\\d+)$'",
")",
"def",
"ExtractPostfixNumber",
"(",
"entity_id",
")",
":",
"\"\"\"Try to extract an integer from the end of entity_id.\n\n ... | Finds the largest integer used as the ending of an id in the schedule.
Args:
schedule: The schedule to check.
Returns:
The maximum integer used as an ending for an id. | [
"Finds",
"the",
"largest",
"integer",
"used",
"as",
"the",
"ending",
"of",
"an",
"id",
"in",
"the",
"schedule",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1597-L1642 | train |
google/transitfeed | merge.py | FeedMerger.GenerateId | def GenerateId(self, entity_id=None):
"""Generate a unique id based on the given id.
This is done by appending a counter which is then incremented. The
counter is initialised at the maximum number used as an ending for
any id in the old and new schedules.
Args:
entity_id: The base id string.... | python | def GenerateId(self, entity_id=None):
"""Generate a unique id based on the given id.
This is done by appending a counter which is then incremented. The
counter is initialised at the maximum number used as an ending for
any id in the old and new schedules.
Args:
entity_id: The base id string.... | [
"def",
"GenerateId",
"(",
"self",
",",
"entity_id",
"=",
"None",
")",
":",
"self",
".",
"_idnum",
"+=",
"1",
"if",
"entity_id",
":",
"return",
"'%s_merged_%d'",
"%",
"(",
"entity_id",
",",
"self",
".",
"_idnum",
")",
"else",
":",
"return",
"'merged_%d'",... | Generate a unique id based on the given id.
This is done by appending a counter which is then incremented. The
counter is initialised at the maximum number used as an ending for
any id in the old and new schedules.
Args:
entity_id: The base id string. This is allowed to be None.
Returns:
... | [
"Generate",
"a",
"unique",
"id",
"based",
"on",
"the",
"given",
"id",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1661-L1678 | train |
google/transitfeed | merge.py | FeedMerger.Register | def Register(self, a, b, migrated_entity):
"""Registers a merge mapping.
If a and b are both not None, this means that entities a and b were merged
to produce migrated_entity. If one of a or b are not None, then it means
it was not merged but simply migrated.
The effect of a call to register is to... | python | def Register(self, a, b, migrated_entity):
"""Registers a merge mapping.
If a and b are both not None, this means that entities a and b were merged
to produce migrated_entity. If one of a or b are not None, then it means
it was not merged but simply migrated.
The effect of a call to register is to... | [
"def",
"Register",
"(",
"self",
",",
"a",
",",
"b",
",",
"migrated_entity",
")",
":",
"# There are a few places where code needs to find the corresponding",
"# migrated entity of an object without knowing in which original schedule",
"# the entity started. With a_merge_map and b_merge_ma... | Registers a merge mapping.
If a and b are both not None, this means that entities a and b were merged
to produce migrated_entity. If one of a or b are not None, then it means
it was not merged but simply migrated.
The effect of a call to register is to update a_merge_map and b_merge_map
according ... | [
"Registers",
"a",
"merge",
"mapping",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1680-L1708 | train |
google/transitfeed | merge.py | FeedMerger.AddDefaultMergers | def AddDefaultMergers(self):
"""Adds the default DataSetMergers defined in this module."""
self.AddMerger(AgencyMerger(self))
self.AddMerger(StopMerger(self))
self.AddMerger(RouteMerger(self))
self.AddMerger(ServicePeriodMerger(self))
self.AddMerger(FareMerger(self))
self.AddMerger(ShapeMerg... | python | def AddDefaultMergers(self):
"""Adds the default DataSetMergers defined in this module."""
self.AddMerger(AgencyMerger(self))
self.AddMerger(StopMerger(self))
self.AddMerger(RouteMerger(self))
self.AddMerger(ServicePeriodMerger(self))
self.AddMerger(FareMerger(self))
self.AddMerger(ShapeMerg... | [
"def",
"AddDefaultMergers",
"(",
"self",
")",
":",
"self",
".",
"AddMerger",
"(",
"AgencyMerger",
"(",
"self",
")",
")",
"self",
".",
"AddMerger",
"(",
"StopMerger",
"(",
"self",
")",
")",
"self",
".",
"AddMerger",
"(",
"RouteMerger",
"(",
"self",
")",
... | Adds the default DataSetMergers defined in this module. | [
"Adds",
"the",
"default",
"DataSetMergers",
"defined",
"in",
"this",
"module",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1718-L1727 | train |
google/transitfeed | merge.py | FeedMerger.GetMerger | def GetMerger(self, cls):
"""Looks for an added DataSetMerger derived from the given class.
Args:
cls: A class derived from DataSetMerger.
Returns:
The matching DataSetMerger instance.
Raises:
LookupError: No matching DataSetMerger has been added.
"""
for merger in self._mer... | python | def GetMerger(self, cls):
"""Looks for an added DataSetMerger derived from the given class.
Args:
cls: A class derived from DataSetMerger.
Returns:
The matching DataSetMerger instance.
Raises:
LookupError: No matching DataSetMerger has been added.
"""
for merger in self._mer... | [
"def",
"GetMerger",
"(",
"self",
",",
"cls",
")",
":",
"for",
"merger",
"in",
"self",
".",
"_mergers",
":",
"if",
"isinstance",
"(",
"merger",
",",
"cls",
")",
":",
"return",
"merger",
"raise",
"LookupError",
"(",
"'No matching DataSetMerger found'",
")"
] | Looks for an added DataSetMerger derived from the given class.
Args:
cls: A class derived from DataSetMerger.
Returns:
The matching DataSetMerger instance.
Raises:
LookupError: No matching DataSetMerger has been added. | [
"Looks",
"for",
"an",
"added",
"DataSetMerger",
"derived",
"from",
"the",
"given",
"class",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L1729-L1744 | train |
google/transitfeed | unusual_trip_filter.py | UnusualTripFilter.filter_line | def filter_line(self, route):
"""Mark unusual trips for the given route."""
if self._route_type is not None and self._route_type != route.route_type:
self.info('Skipping route %s due to different route_type value (%s)' %
(route['route_id'], route['route_type']))
return
self.info(... | python | def filter_line(self, route):
"""Mark unusual trips for the given route."""
if self._route_type is not None and self._route_type != route.route_type:
self.info('Skipping route %s due to different route_type value (%s)' %
(route['route_id'], route['route_type']))
return
self.info(... | [
"def",
"filter_line",
"(",
"self",
",",
"route",
")",
":",
"if",
"self",
".",
"_route_type",
"is",
"not",
"None",
"and",
"self",
".",
"_route_type",
"!=",
"route",
".",
"route_type",
":",
"self",
".",
"info",
"(",
"'Skipping route %s due to different route_typ... | Mark unusual trips for the given route. | [
"Mark",
"unusual",
"trips",
"for",
"the",
"given",
"route",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/unusual_trip_filter.py#L56-L90 | train |
google/transitfeed | unusual_trip_filter.py | UnusualTripFilter.filter | def filter(self, dataset):
"""Mark unusual trips for all the routes in the dataset."""
self.info('Going to filter infrequent routes in the dataset')
for route in dataset.routes.values():
self.filter_line(route) | python | def filter(self, dataset):
"""Mark unusual trips for all the routes in the dataset."""
self.info('Going to filter infrequent routes in the dataset')
for route in dataset.routes.values():
self.filter_line(route) | [
"def",
"filter",
"(",
"self",
",",
"dataset",
")",
":",
"self",
".",
"info",
"(",
"'Going to filter infrequent routes in the dataset'",
")",
"for",
"route",
"in",
"dataset",
".",
"routes",
".",
"values",
"(",
")",
":",
"self",
".",
"filter_line",
"(",
"route... | Mark unusual trips for all the routes in the dataset. | [
"Mark",
"unusual",
"trips",
"for",
"all",
"the",
"routes",
"in",
"the",
"dataset",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/unusual_trip_filter.py#L92-L96 | train |
google/transitfeed | schedule_viewer.py | StopToTuple | def StopToTuple(stop):
"""Return tuple as expected by javascript function addStopMarkerFromList"""
return (stop.stop_id, stop.stop_name, float(stop.stop_lat),
float(stop.stop_lon), stop.location_type) | python | def StopToTuple(stop):
"""Return tuple as expected by javascript function addStopMarkerFromList"""
return (stop.stop_id, stop.stop_name, float(stop.stop_lat),
float(stop.stop_lon), stop.location_type) | [
"def",
"StopToTuple",
"(",
"stop",
")",
":",
"return",
"(",
"stop",
".",
"stop_id",
",",
"stop",
".",
"stop_name",
",",
"float",
"(",
"stop",
".",
"stop_lat",
")",
",",
"float",
"(",
"stop",
".",
"stop_lon",
")",
",",
"stop",
".",
"location_type",
")... | Return tuple as expected by javascript function addStopMarkerFromList | [
"Return",
"tuple",
"as",
"expected",
"by",
"javascript",
"function",
"addStopMarkerFromList"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L89-L92 | train |
google/transitfeed | schedule_viewer.py | FindDefaultFileDir | def FindDefaultFileDir():
"""Return the path of the directory containing the static files. By default
the directory is called 'files'. The location depends on where setup.py put
it."""
base = FindPy2ExeBase()
if base:
return os.path.join(base, 'schedule_viewer_files')
else:
# For all other distribut... | python | def FindDefaultFileDir():
"""Return the path of the directory containing the static files. By default
the directory is called 'files'. The location depends on where setup.py put
it."""
base = FindPy2ExeBase()
if base:
return os.path.join(base, 'schedule_viewer_files')
else:
# For all other distribut... | [
"def",
"FindDefaultFileDir",
"(",
")",
":",
"base",
"=",
"FindPy2ExeBase",
"(",
")",
"if",
"base",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"'schedule_viewer_files'",
")",
"else",
":",
"# For all other distributions 'files' is in the gtfssc... | Return the path of the directory containing the static files. By default
the directory is called 'files'. The location depends on where setup.py put
it. | [
"Return",
"the",
"path",
"of",
"the",
"directory",
"containing",
"the",
"static",
"files",
".",
"By",
"default",
"the",
"directory",
"is",
"called",
"files",
".",
"The",
"location",
"depends",
"on",
"where",
"setup",
".",
"py",
"put",
"it",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L461-L472 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_routepatterns | def handle_json_GET_routepatterns(self, params):
"""Given a route_id generate a list of patterns of the route. For each
pattern include some basic information and a few sample trips."""
schedule = self.server.schedule
route = schedule.GetRoute(params.get('route', None))
if not route:
self.send... | python | def handle_json_GET_routepatterns(self, params):
"""Given a route_id generate a list of patterns of the route. For each
pattern include some basic information and a few sample trips."""
schedule = self.server.schedule
route = schedule.GetRoute(params.get('route', None))
if not route:
self.send... | [
"def",
"handle_json_GET_routepatterns",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"route",
"=",
"schedule",
".",
"GetRoute",
"(",
"params",
".",
"get",
"(",
"'route'",
",",
"None",
")",
")",
"if",
"not... | Given a route_id generate a list of patterns of the route. For each
pattern include some basic information and a few sample trips. | [
"Given",
"a",
"route_id",
"generate",
"a",
"list",
"of",
"patterns",
"of",
"the",
"route",
".",
"For",
"each",
"pattern",
"include",
"some",
"basic",
"information",
"and",
"a",
"few",
"sample",
"trips",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L187-L257 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_wrapper_GET | def handle_json_wrapper_GET(self, handler, parsed_params):
"""Call handler and output the return value in JSON."""
schedule = self.server.schedule
result = handler(parsed_params)
content = ResultEncoder().encode(result)
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
s... | python | def handle_json_wrapper_GET(self, handler, parsed_params):
"""Call handler and output the return value in JSON."""
schedule = self.server.schedule
result = handler(parsed_params)
content = ResultEncoder().encode(result)
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
s... | [
"def",
"handle_json_wrapper_GET",
"(",
"self",
",",
"handler",
",",
"parsed_params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"result",
"=",
"handler",
"(",
"parsed_params",
")",
"content",
"=",
"ResultEncoder",
"(",
")",
".",
"enco... | Call handler and output the return value in JSON. | [
"Call",
"handler",
"and",
"output",
"the",
"return",
"value",
"in",
"JSON",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L259-L268 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_routes | def handle_json_GET_routes(self, params):
"""Return a list of all routes."""
schedule = self.server.schedule
result = []
for r in schedule.GetRouteList():
result.append( (r.route_id, r.route_short_name, r.route_long_name) )
result.sort(key = lambda x: x[1:3])
return result | python | def handle_json_GET_routes(self, params):
"""Return a list of all routes."""
schedule = self.server.schedule
result = []
for r in schedule.GetRouteList():
result.append( (r.route_id, r.route_short_name, r.route_long_name) )
result.sort(key = lambda x: x[1:3])
return result | [
"def",
"handle_json_GET_routes",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"result",
"=",
"[",
"]",
"for",
"r",
"in",
"schedule",
".",
"GetRouteList",
"(",
")",
":",
"result",
".",
"append",
"(",
"("... | Return a list of all routes. | [
"Return",
"a",
"list",
"of",
"all",
"routes",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L270-L277 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_triprows | def handle_json_GET_triprows(self, params):
"""Return a list of rows from the feed file that are related to this
trip."""
schedule = self.server.schedule
try:
trip = schedule.GetTrip(params.get('trip', None))
except KeyError:
# if a non-existent trip is searched for, the return nothing
... | python | def handle_json_GET_triprows(self, params):
"""Return a list of rows from the feed file that are related to this
trip."""
schedule = self.server.schedule
try:
trip = schedule.GetTrip(params.get('trip', None))
except KeyError:
# if a non-existent trip is searched for, the return nothing
... | [
"def",
"handle_json_GET_triprows",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"try",
":",
"trip",
"=",
"schedule",
".",
"GetTrip",
"(",
"params",
".",
"get",
"(",
"'trip'",
",",
"None",
")",
")",
"exc... | Return a list of rows from the feed file that are related to this
trip. | [
"Return",
"a",
"list",
"of",
"rows",
"from",
"the",
"feed",
"file",
"that",
"are",
"related",
"to",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L284-L296 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_neareststops | def handle_json_GET_neareststops(self, params):
"""Return a list of the nearest 'limit' stops to 'lat', 'lon'"""
schedule = self.server.schedule
lat = float(params.get('lat'))
lon = float(params.get('lon'))
limit = int(params.get('limit'))
stops = schedule.GetNearestStops(lat=lat, lon=lon, n=lim... | python | def handle_json_GET_neareststops(self, params):
"""Return a list of the nearest 'limit' stops to 'lat', 'lon'"""
schedule = self.server.schedule
lat = float(params.get('lat'))
lon = float(params.get('lon'))
limit = int(params.get('limit'))
stops = schedule.GetNearestStops(lat=lat, lon=lon, n=lim... | [
"def",
"handle_json_GET_neareststops",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"lat",
"=",
"float",
"(",
"params",
".",
"get",
"(",
"'lat'",
")",
")",
"lon",
"=",
"float",
"(",
"params",
".",
"get"... | Return a list of the nearest 'limit' stops to 'lat', 'lon | [
"Return",
"a",
"list",
"of",
"the",
"nearest",
"limit",
"stops",
"to",
"lat",
"lon"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L337-L344 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_boundboxstops | def handle_json_GET_boundboxstops(self, params):
"""Return a list of up to 'limit' stops within bounding box with 'n','e'
and 's','w' in the NE and SW corners. Does not handle boxes crossing
longitude line 180."""
schedule = self.server.schedule
n = float(params.get('n'))
e = float(params.get('e... | python | def handle_json_GET_boundboxstops(self, params):
"""Return a list of up to 'limit' stops within bounding box with 'n','e'
and 's','w' in the NE and SW corners. Does not handle boxes crossing
longitude line 180."""
schedule = self.server.schedule
n = float(params.get('n'))
e = float(params.get('e... | [
"def",
"handle_json_GET_boundboxstops",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"n",
"=",
"float",
"(",
"params",
".",
"get",
"(",
"'n'",
")",
")",
"e",
"=",
"float",
"(",
"params",
".",
"get",
"... | Return a list of up to 'limit' stops within bounding box with 'n','e'
and 's','w' in the NE and SW corners. Does not handle boxes crossing
longitude line 180. | [
"Return",
"a",
"list",
"of",
"up",
"to",
"limit",
"stops",
"within",
"bounding",
"box",
"with",
"n",
"e",
"and",
"s",
"w",
"in",
"the",
"NE",
"and",
"SW",
"corners",
".",
"Does",
"not",
"handle",
"boxes",
"crossing",
"longitude",
"line",
"180",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L346-L357 | train |
google/transitfeed | schedule_viewer.py | ScheduleRequestHandler.handle_json_GET_stoptrips | def handle_json_GET_stoptrips(self, params):
"""Given a stop_id and time in seconds since midnight return the next
trips to visit the stop."""
schedule = self.server.schedule
stop = schedule.GetStop(params.get('stop', None))
time = int(params.get('time', 0))
date = params.get('date', "")
ti... | python | def handle_json_GET_stoptrips(self, params):
"""Given a stop_id and time in seconds since midnight return the next
trips to visit the stop."""
schedule = self.server.schedule
stop = schedule.GetStop(params.get('stop', None))
time = int(params.get('time', 0))
date = params.get('date', "")
ti... | [
"def",
"handle_json_GET_stoptrips",
"(",
"self",
",",
"params",
")",
":",
"schedule",
"=",
"self",
".",
"server",
".",
"schedule",
"stop",
"=",
"schedule",
".",
"GetStop",
"(",
"params",
".",
"get",
"(",
"'stop'",
",",
"None",
")",
")",
"time",
"=",
"i... | Given a stop_id and time in seconds since midnight return the next
trips to visit the stop. | [
"Given",
"a",
"stop_id",
"and",
"time",
"in",
"seconds",
"since",
"midnight",
"return",
"the",
"next",
"trips",
"to",
"visit",
"the",
"stop",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/schedule_viewer.py#L368-L410 | train |
google/transitfeed | misc/traceplus.py | MakeExpandedTrace | def MakeExpandedTrace(frame_records):
"""Return a list of text lines for the given list of frame records."""
dump = []
for (frame_obj, filename, line_num, fun_name, context_lines,
context_index) in frame_records:
dump.append('File "%s", line %d, in %s\n' % (filename, line_num,
... | python | def MakeExpandedTrace(frame_records):
"""Return a list of text lines for the given list of frame records."""
dump = []
for (frame_obj, filename, line_num, fun_name, context_lines,
context_index) in frame_records:
dump.append('File "%s", line %d, in %s\n' % (filename, line_num,
... | [
"def",
"MakeExpandedTrace",
"(",
"frame_records",
")",
":",
"dump",
"=",
"[",
"]",
"for",
"(",
"frame_obj",
",",
"filename",
",",
"line_num",
",",
"fun_name",
",",
"context_lines",
",",
"context_index",
")",
"in",
"frame_records",
":",
"dump",
".",
"append",... | Return a list of text lines for the given list of frame records. | [
"Return",
"a",
"list",
"of",
"text",
"lines",
"for",
"the",
"given",
"list",
"of",
"frame",
"records",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/traceplus.py#L24-L51 | train |
google/transitfeed | transitfeed/shapepoint.py | ShapePoint.ParseAttributes | def ParseAttributes(self, problems):
"""Parse all attributes, calling problems as needed.
Return True if all of the values are valid.
"""
if util.IsEmpty(self.shape_id):
problems.MissingValue('shape_id')
return
try:
if not isinstance(self.shape_pt_sequence, int):
self.sha... | python | def ParseAttributes(self, problems):
"""Parse all attributes, calling problems as needed.
Return True if all of the values are valid.
"""
if util.IsEmpty(self.shape_id):
problems.MissingValue('shape_id')
return
try:
if not isinstance(self.shape_pt_sequence, int):
self.sha... | [
"def",
"ParseAttributes",
"(",
"self",
",",
"problems",
")",
":",
"if",
"util",
".",
"IsEmpty",
"(",
"self",
".",
"shape_id",
")",
":",
"problems",
".",
"MissingValue",
"(",
"'shape_id'",
")",
"return",
"try",
":",
"if",
"not",
"isinstance",
"(",
"self",... | Parse all attributes, calling problems as needed.
Return True if all of the values are valid. | [
"Parse",
"all",
"attributes",
"calling",
"problems",
"as",
"needed",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapepoint.py#L59-L125 | train |
google/transitfeed | transitfeed/problems.py | ProblemReporter.SetFileContext | def SetFileContext(self, file_name, row_num, row, headers):
"""Save the current context to be output with any errors.
Args:
file_name: string
row_num: int
row: list of strings
headers: list of column headers, its order corresponding to row's
"""
self._context = (file_name, row_n... | python | def SetFileContext(self, file_name, row_num, row, headers):
"""Save the current context to be output with any errors.
Args:
file_name: string
row_num: int
row: list of strings
headers: list of column headers, its order corresponding to row's
"""
self._context = (file_name, row_n... | [
"def",
"SetFileContext",
"(",
"self",
",",
"file_name",
",",
"row_num",
",",
"row",
",",
"headers",
")",
":",
"self",
".",
"_context",
"=",
"(",
"file_name",
",",
"row_num",
",",
"row",
",",
"headers",
")"
] | Save the current context to be output with any errors.
Args:
file_name: string
row_num: int
row: list of strings
headers: list of column headers, its order corresponding to row's | [
"Save",
"the",
"current",
"context",
"to",
"be",
"output",
"with",
"any",
"errors",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L53-L62 | train |
google/transitfeed | transitfeed/problems.py | ProblemReporter.InvalidLineEnd | def InvalidLineEnd(self, bad_line_end, context=None, type=TYPE_WARNING):
"""bad_line_end is a human readable string."""
e = InvalidLineEnd(bad_line_end=bad_line_end, context=context,
context2=self._context, type=type)
self.AddToAccumulator(e) | python | def InvalidLineEnd(self, bad_line_end, context=None, type=TYPE_WARNING):
"""bad_line_end is a human readable string."""
e = InvalidLineEnd(bad_line_end=bad_line_end, context=context,
context2=self._context, type=type)
self.AddToAccumulator(e) | [
"def",
"InvalidLineEnd",
"(",
"self",
",",
"bad_line_end",
",",
"context",
"=",
"None",
",",
"type",
"=",
"TYPE_WARNING",
")",
":",
"e",
"=",
"InvalidLineEnd",
"(",
"bad_line_end",
"=",
"bad_line_end",
",",
"context",
"=",
"context",
",",
"context2",
"=",
... | bad_line_end is a human readable string. | [
"bad_line_end",
"is",
"a",
"human",
"readable",
"string",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L268-L272 | train |
google/transitfeed | transitfeed/problems.py | ExceptionWithContext.GetDictToFormat | def GetDictToFormat(self):
"""Return a copy of self as a dict, suitable for passing to FormatProblem"""
d = {}
for k, v in self.__dict__.items():
# TODO: Better handling of unicode/utf-8 within Schedule objects.
# Concatinating a unicode and utf-8 str object causes an exception such
# as "... | python | def GetDictToFormat(self):
"""Return a copy of self as a dict, suitable for passing to FormatProblem"""
d = {}
for k, v in self.__dict__.items():
# TODO: Better handling of unicode/utf-8 within Schedule objects.
# Concatinating a unicode and utf-8 str object causes an exception such
# as "... | [
"def",
"GetDictToFormat",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"# TODO: Better handling of unicode/utf-8 within Schedule objects.",
"# Concatinating a unicode and utf-8 str object ... | Return a copy of self as a dict, suitable for passing to FormatProblem | [
"Return",
"a",
"copy",
"of",
"self",
"as",
"a",
"dict",
"suitable",
"for",
"passing",
"to",
"FormatProblem"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L445-L457 | train |
google/transitfeed | transitfeed/problems.py | ExceptionWithContext.FormatProblem | def FormatProblem(self, d=None):
"""Return a text string describing the problem.
Args:
d: map returned by GetDictToFormat with with formatting added
"""
if not d:
d = self.GetDictToFormat()
output_error_text = self.__class__.ERROR_TEXT % d
if ('reason' in d) and d['reason']:
... | python | def FormatProblem(self, d=None):
"""Return a text string describing the problem.
Args:
d: map returned by GetDictToFormat with with formatting added
"""
if not d:
d = self.GetDictToFormat()
output_error_text = self.__class__.ERROR_TEXT % d
if ('reason' in d) and d['reason']:
... | [
"def",
"FormatProblem",
"(",
"self",
",",
"d",
"=",
"None",
")",
":",
"if",
"not",
"d",
":",
"d",
"=",
"self",
".",
"GetDictToFormat",
"(",
")",
"output_error_text",
"=",
"self",
".",
"__class__",
".",
"ERROR_TEXT",
"%",
"d",
"if",
"(",
"'reason'",
"... | Return a text string describing the problem.
Args:
d: map returned by GetDictToFormat with with formatting added | [
"Return",
"a",
"text",
"string",
"describing",
"the",
"problem",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L459-L472 | train |
google/transitfeed | transitfeed/problems.py | ExceptionWithContext.FormatContext | def FormatContext(self):
"""Return a text string describing the context"""
text = ''
if hasattr(self, 'feed_name'):
text += "In feed '%s': " % self.feed_name
if hasattr(self, 'file_name'):
text += self.file_name
if hasattr(self, 'row_num'):
text += ":%i" % self.row_num
if hasat... | python | def FormatContext(self):
"""Return a text string describing the context"""
text = ''
if hasattr(self, 'feed_name'):
text += "In feed '%s': " % self.feed_name
if hasattr(self, 'file_name'):
text += self.file_name
if hasattr(self, 'row_num'):
text += ":%i" % self.row_num
if hasat... | [
"def",
"FormatContext",
"(",
"self",
")",
":",
"text",
"=",
"''",
"if",
"hasattr",
"(",
"self",
",",
"'feed_name'",
")",
":",
"text",
"+=",
"\"In feed '%s': \"",
"%",
"self",
".",
"feed_name",
"if",
"hasattr",
"(",
"self",
",",
"'file_name'",
")",
":",
... | Return a text string describing the context | [
"Return",
"a",
"text",
"string",
"describing",
"the",
"context"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L474-L485 | train |
google/transitfeed | transitfeed/problems.py | ExceptionWithContext.GetOrderKey | def GetOrderKey(self):
"""Return a tuple that can be used to sort problems into a consistent order.
Returns:
A list of values.
"""
context_attributes = ['_type']
context_attributes.extend(ExceptionWithContext.CONTEXT_PARTS)
context_attributes.extend(self._GetExtraOrderAttributes())
t... | python | def GetOrderKey(self):
"""Return a tuple that can be used to sort problems into a consistent order.
Returns:
A list of values.
"""
context_attributes = ['_type']
context_attributes.extend(ExceptionWithContext.CONTEXT_PARTS)
context_attributes.extend(self._GetExtraOrderAttributes())
t... | [
"def",
"GetOrderKey",
"(",
"self",
")",
":",
"context_attributes",
"=",
"[",
"'_type'",
"]",
"context_attributes",
".",
"extend",
"(",
"ExceptionWithContext",
".",
"CONTEXT_PARTS",
")",
"context_attributes",
".",
"extend",
"(",
"self",
".",
"_GetExtraOrderAttributes... | Return a tuple that can be used to sort problems into a consistent order.
Returns:
A list of values. | [
"Return",
"a",
"tuple",
"that",
"can",
"be",
"used",
"to",
"sort",
"problems",
"into",
"a",
"consistent",
"order",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/problems.py#L506-L519 | train |
google/transitfeed | visualize_pathways.py | gtfs_to_graphviz | def gtfs_to_graphviz(gtfs, stop_ids=None):
"""Reads GTFS data and returns GraphViz DOT file content as string.
"""
graph = GraphViz()
location_ids = choose_location_ids(gtfs, stop_ids)
locations = [gtfs.get_location(i) for i in location_ids]
for location in locations:
if not location.p... | python | def gtfs_to_graphviz(gtfs, stop_ids=None):
"""Reads GTFS data and returns GraphViz DOT file content as string.
"""
graph = GraphViz()
location_ids = choose_location_ids(gtfs, stop_ids)
locations = [gtfs.get_location(i) for i in location_ids]
for location in locations:
if not location.p... | [
"def",
"gtfs_to_graphviz",
"(",
"gtfs",
",",
"stop_ids",
"=",
"None",
")",
":",
"graph",
"=",
"GraphViz",
"(",
")",
"location_ids",
"=",
"choose_location_ids",
"(",
"gtfs",
",",
"stop_ids",
")",
"locations",
"=",
"[",
"gtfs",
".",
"get_location",
"(",
"i",... | Reads GTFS data and returns GraphViz DOT file content as string. | [
"Reads",
"GTFS",
"data",
"and",
"returns",
"GraphViz",
"DOT",
"file",
"content",
"as",
"string",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/visualize_pathways.py#L424-L466 | train |
google/transitfeed | transitfeed/gtfsfactoryuser.py | GtfsFactoryUser.GetGtfsFactory | def GetGtfsFactory(self):
"""Return the object's GTFS Factory.
Returns:
The GTFS Factory that was set for this object. If none was explicitly
set, it first sets the object's factory to transitfeed's GtfsFactory
and returns it"""
if self._gtfs_factory is None:
#TODO(anog): We ... | python | def GetGtfsFactory(self):
"""Return the object's GTFS Factory.
Returns:
The GTFS Factory that was set for this object. If none was explicitly
set, it first sets the object's factory to transitfeed's GtfsFactory
and returns it"""
if self._gtfs_factory is None:
#TODO(anog): We ... | [
"def",
"GetGtfsFactory",
"(",
"self",
")",
":",
"if",
"self",
".",
"_gtfs_factory",
"is",
"None",
":",
"#TODO(anog): We really need to create a dependency graph and clean things",
"# up, as the comment in __init__.py says.",
"# Not having GenericGTFSObject as a le... | Return the object's GTFS Factory.
Returns:
The GTFS Factory that was set for this object. If none was explicitly
set, it first sets the object's factory to transitfeed's GtfsFactory
and returns it | [
"Return",
"the",
"object",
"s",
"GTFS",
"Factory",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactoryuser.py#L26-L44 | train |
google/transitfeed | transitfeed/gtfsobjectbase.py | GtfsObjectBase.keys | def keys(self):
"""Return iterable of columns used by this object."""
columns = set()
for name in vars(self):
if (not name) or name[0] == "_":
continue
columns.add(name)
return columns | python | def keys(self):
"""Return iterable of columns used by this object."""
columns = set()
for name in vars(self):
if (not name) or name[0] == "_":
continue
columns.add(name)
return columns | [
"def",
"keys",
"(",
"self",
")",
":",
"columns",
"=",
"set",
"(",
")",
"for",
"name",
"in",
"vars",
"(",
"self",
")",
":",
"if",
"(",
"not",
"name",
")",
"or",
"name",
"[",
"0",
"]",
"==",
"\"_\"",
":",
"continue",
"columns",
".",
"add",
"(",
... | Return iterable of columns used by this object. | [
"Return",
"iterable",
"of",
"columns",
"used",
"by",
"this",
"object",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsobjectbase.py#L108-L115 | train |
google/transitfeed | transitfeed/shape.py | Shape.AddShapePointObjectUnsorted | def AddShapePointObjectUnsorted(self, shapepoint, problems):
"""Insert a point into a correct position by sequence. """
if (len(self.sequence) == 0 or
shapepoint.shape_pt_sequence >= self.sequence[-1]):
index = len(self.sequence)
elif shapepoint.shape_pt_sequence <= self.sequence[0]:
ind... | python | def AddShapePointObjectUnsorted(self, shapepoint, problems):
"""Insert a point into a correct position by sequence. """
if (len(self.sequence) == 0 or
shapepoint.shape_pt_sequence >= self.sequence[-1]):
index = len(self.sequence)
elif shapepoint.shape_pt_sequence <= self.sequence[0]:
ind... | [
"def",
"AddShapePointObjectUnsorted",
"(",
"self",
",",
"shapepoint",
",",
"problems",
")",
":",
"if",
"(",
"len",
"(",
"self",
".",
"sequence",
")",
"==",
"0",
"or",
"shapepoint",
".",
"shape_pt_sequence",
">=",
"self",
".",
"sequence",
"[",
"-",
"1",
"... | Insert a point into a correct position by sequence. | [
"Insert",
"a",
"point",
"into",
"a",
"correct",
"position",
"by",
"sequence",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shape.py#L54-L96 | train |
google/transitfeed | transitfeed/shape.py | Shape.GetPointWithDistanceTraveled | def GetPointWithDistanceTraveled(self, shape_dist_traveled):
"""Returns a point on the shape polyline with the input shape_dist_traveled.
Args:
shape_dist_traveled: The input shape_dist_traveled.
Returns:
The shape point as a tuple (lat, lng, shape_dist_traveled), where lat and
lng is th... | python | def GetPointWithDistanceTraveled(self, shape_dist_traveled):
"""Returns a point on the shape polyline with the input shape_dist_traveled.
Args:
shape_dist_traveled: The input shape_dist_traveled.
Returns:
The shape point as a tuple (lat, lng, shape_dist_traveled), where lat and
lng is th... | [
"def",
"GetPointWithDistanceTraveled",
"(",
"self",
",",
"shape_dist_traveled",
")",
":",
"if",
"not",
"self",
".",
"distance",
":",
"return",
"None",
"if",
"shape_dist_traveled",
"<=",
"self",
".",
"distance",
"[",
"0",
"]",
":",
"return",
"self",
".",
"poi... | Returns a point on the shape polyline with the input shape_dist_traveled.
Args:
shape_dist_traveled: The input shape_dist_traveled.
Returns:
The shape point as a tuple (lat, lng, shape_dist_traveled), where lat and
lng is the location of the shape point, and shape_dist_traveled is an
i... | [
"Returns",
"a",
"point",
"on",
"the",
"shape",
"polyline",
"with",
"the",
"input",
"shape_dist_traveled",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shape.py#L129-L170 | train |
google/transitfeed | transitfeed/trip.py | Trip.AddStopTime | def AddStopTime(self, stop, problems=None, schedule=None, **kwargs):
"""Add a stop to this trip. Stops must be added in the order visited.
Args:
stop: A Stop object
kwargs: remaining keyword args passed to StopTime.__init__
Returns:
None
"""
if problems is None:
# TODO: del... | python | def AddStopTime(self, stop, problems=None, schedule=None, **kwargs):
"""Add a stop to this trip. Stops must be added in the order visited.
Args:
stop: A Stop object
kwargs: remaining keyword args passed to StopTime.__init__
Returns:
None
"""
if problems is None:
# TODO: del... | [
"def",
"AddStopTime",
"(",
"self",
",",
"stop",
",",
"problems",
"=",
"None",
",",
"schedule",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"problems",
"is",
"None",
":",
"# TODO: delete this branch when StopTime.__init__ doesn't need a",
"# ProblemReport... | Add a stop to this trip. Stops must be added in the order visited.
Args:
stop: A Stop object
kwargs: remaining keyword args passed to StopTime.__init__
Returns:
None | [
"Add",
"a",
"stop",
"to",
"this",
"trip",
".",
"Stops",
"must",
"be",
"added",
"in",
"the",
"order",
"visited",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L59-L75 | train |
google/transitfeed | transitfeed/trip.py | Trip._AddStopTimeObjectUnordered | def _AddStopTimeObjectUnordered(self, stoptime, schedule):
"""Add StopTime object to this trip.
The trip isn't checked for duplicate sequence numbers so it must be
validated later."""
stop_time_class = self.GetGtfsFactory().StopTime
cursor = schedule._connection.cursor()
insert_query = "INSERT ... | python | def _AddStopTimeObjectUnordered(self, stoptime, schedule):
"""Add StopTime object to this trip.
The trip isn't checked for duplicate sequence numbers so it must be
validated later."""
stop_time_class = self.GetGtfsFactory().StopTime
cursor = schedule._connection.cursor()
insert_query = "INSERT ... | [
"def",
"_AddStopTimeObjectUnordered",
"(",
"self",
",",
"stoptime",
",",
"schedule",
")",
":",
"stop_time_class",
"=",
"self",
".",
"GetGtfsFactory",
"(",
")",
".",
"StopTime",
"cursor",
"=",
"schedule",
".",
"_connection",
".",
"cursor",
"(",
")",
"insert_que... | Add StopTime object to this trip.
The trip isn't checked for duplicate sequence numbers so it must be
validated later. | [
"Add",
"StopTime",
"object",
"to",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L77-L89 | train |
google/transitfeed | transitfeed/trip.py | Trip.ReplaceStopTimeObject | def ReplaceStopTimeObject(self, stoptime, schedule=None):
"""Replace a StopTime object from this trip with the given one.
Keys the StopTime object to be replaced by trip_id, stop_sequence
and stop_id as 'stoptime', with the object 'stoptime'.
"""
if schedule is None:
schedule = self._schedul... | python | def ReplaceStopTimeObject(self, stoptime, schedule=None):
"""Replace a StopTime object from this trip with the given one.
Keys the StopTime object to be replaced by trip_id, stop_sequence
and stop_id as 'stoptime', with the object 'stoptime'.
"""
if schedule is None:
schedule = self._schedul... | [
"def",
"ReplaceStopTimeObject",
"(",
"self",
",",
"stoptime",
",",
"schedule",
"=",
"None",
")",
":",
"if",
"schedule",
"is",
"None",
":",
"schedule",
"=",
"self",
".",
"_schedule",
"new_secs",
"=",
"stoptime",
".",
"GetTimeSecs",
"(",
")",
"cursor",
"=",
... | Replace a StopTime object from this trip with the given one.
Keys the StopTime object to be replaced by trip_id, stop_sequence
and stop_id as 'stoptime', with the object 'stoptime'. | [
"Replace",
"a",
"StopTime",
"object",
"from",
"this",
"trip",
"with",
"the",
"given",
"one",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L91-L108 | train |
google/transitfeed | transitfeed/trip.py | Trip.AddStopTimeObject | def AddStopTimeObject(self, stoptime, schedule=None, problems=None):
"""Add a StopTime object to the end of this trip.
Args:
stoptime: A StopTime object. Should not be reused in multiple trips.
schedule: Schedule object containing this trip which must be
passed to Trip.__init__ or here
... | python | def AddStopTimeObject(self, stoptime, schedule=None, problems=None):
"""Add a StopTime object to the end of this trip.
Args:
stoptime: A StopTime object. Should not be reused in multiple trips.
schedule: Schedule object containing this trip which must be
passed to Trip.__init__ or here
... | [
"def",
"AddStopTimeObject",
"(",
"self",
",",
"stoptime",
",",
"schedule",
"=",
"None",
",",
"problems",
"=",
"None",
")",
":",
"if",
"schedule",
"is",
"None",
":",
"schedule",
"=",
"self",
".",
"_schedule",
"if",
"schedule",
"is",
"None",
":",
"warnings... | Add a StopTime object to the end of this trip.
Args:
stoptime: A StopTime object. Should not be reused in multiple trips.
schedule: Schedule object containing this trip which must be
passed to Trip.__init__ or here
problems: ProblemReporter object for validating the StopTime in its new
... | [
"Add",
"a",
"StopTime",
"object",
"to",
"the",
"end",
"of",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L110-L153 | train |
google/transitfeed | transitfeed/trip.py | Trip.GetCountStopTimes | def GetCountStopTimes(self):
"""Return the number of stops made by this trip."""
cursor = self._schedule._connection.cursor()
cursor.execute(
'SELECT count(*) FROM stop_times WHERE trip_id=?', (self.trip_id,))
return cursor.fetchone()[0] | python | def GetCountStopTimes(self):
"""Return the number of stops made by this trip."""
cursor = self._schedule._connection.cursor()
cursor.execute(
'SELECT count(*) FROM stop_times WHERE trip_id=?', (self.trip_id,))
return cursor.fetchone()[0] | [
"def",
"GetCountStopTimes",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"_schedule",
".",
"_connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"'SELECT count(*) FROM stop_times WHERE trip_id=?'",
",",
"(",
"self",
".",
"trip_id",
",",
... | Return the number of stops made by this trip. | [
"Return",
"the",
"number",
"of",
"stops",
"made",
"by",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L163-L168 | train |
google/transitfeed | transitfeed/trip.py | Trip.ClearStopTimes | def ClearStopTimes(self):
"""Remove all stop times from this trip.
StopTime objects previously returned by GetStopTimes are unchanged but are
no longer associated with this trip.
"""
cursor = self._schedule._connection.cursor()
cursor.execute('DELETE FROM stop_times WHERE trip_id=?', (self.trip... | python | def ClearStopTimes(self):
"""Remove all stop times from this trip.
StopTime objects previously returned by GetStopTimes are unchanged but are
no longer associated with this trip.
"""
cursor = self._schedule._connection.cursor()
cursor.execute('DELETE FROM stop_times WHERE trip_id=?', (self.trip... | [
"def",
"ClearStopTimes",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"_schedule",
".",
"_connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"'DELETE FROM stop_times WHERE trip_id=?'",
",",
"(",
"self",
".",
"trip_id",
",",
")",
")"
] | Remove all stop times from this trip.
StopTime objects previously returned by GetStopTimes are unchanged but are
no longer associated with this trip. | [
"Remove",
"all",
"stop",
"times",
"from",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L218-L225 | train |
google/transitfeed | transitfeed/trip.py | Trip.GetStopTimes | def GetStopTimes(self, problems=None):
"""Return a sorted list of StopTime objects for this trip."""
# In theory problems=None should be safe because data from database has been
# validated. See comment in _LoadStopTimes for why this isn't always true.
cursor = self._schedule._connection.cursor()
cu... | python | def GetStopTimes(self, problems=None):
"""Return a sorted list of StopTime objects for this trip."""
# In theory problems=None should be safe because data from database has been
# validated. See comment in _LoadStopTimes for why this isn't always true.
cursor = self._schedule._connection.cursor()
cu... | [
"def",
"GetStopTimes",
"(",
"self",
",",
"problems",
"=",
"None",
")",
":",
"# In theory problems=None should be safe because data from database has been",
"# validated. See comment in _LoadStopTimes for why this isn't always true.",
"cursor",
"=",
"self",
".",
"_schedule",
".",
... | Return a sorted list of StopTime objects for this trip. | [
"Return",
"a",
"sorted",
"list",
"of",
"StopTime",
"objects",
"for",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L227-L256 | train |
google/transitfeed | transitfeed/trip.py | Trip.GetFrequencyStopTimes | def GetFrequencyStopTimes(self, problems=None):
"""Return a list of StopTime objects for each headway-based run.
Returns:
a list of list of StopTime objects. Each list of StopTime objects
represents one run. If this trip doesn't have headways returns an empty
list.
"""
stoptimes_list ... | python | def GetFrequencyStopTimes(self, problems=None):
"""Return a list of StopTime objects for each headway-based run.
Returns:
a list of list of StopTime objects. Each list of StopTime objects
represents one run. If this trip doesn't have headways returns an empty
list.
"""
stoptimes_list ... | [
"def",
"GetFrequencyStopTimes",
"(",
"self",
",",
"problems",
"=",
"None",
")",
":",
"stoptimes_list",
"=",
"[",
"]",
"# list of stoptime lists to be returned",
"stoptime_pattern",
"=",
"self",
".",
"GetStopTimes",
"(",
")",
"first_secs",
"=",
"stoptime_pattern",
"[... | Return a list of StopTime objects for each headway-based run.
Returns:
a list of list of StopTime objects. Each list of StopTime objects
represents one run. If this trip doesn't have headways returns an empty
list. | [
"Return",
"a",
"list",
"of",
"StopTime",
"objects",
"for",
"each",
"headway",
"-",
"based",
"run",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L265-L301 | train |
google/transitfeed | transitfeed/trip.py | Trip.GetFrequencyStartTimes | def GetFrequencyStartTimes(self):
"""Return a list of start time for each headway-based run.
Returns:
a sorted list of seconds since midnight, the start time of each run. If
this trip doesn't have headways returns an empty list."""
start_times = []
# for each headway period of the trip
... | python | def GetFrequencyStartTimes(self):
"""Return a list of start time for each headway-based run.
Returns:
a sorted list of seconds since midnight, the start time of each run. If
this trip doesn't have headways returns an empty list."""
start_times = []
# for each headway period of the trip
... | [
"def",
"GetFrequencyStartTimes",
"(",
"self",
")",
":",
"start_times",
"=",
"[",
"]",
"# for each headway period of the trip",
"for",
"freq_tuple",
"in",
"self",
".",
"GetFrequencyTuples",
"(",
")",
":",
"(",
"start_secs",
",",
"end_secs",
",",
"headway_secs",
")"... | Return a list of start time for each headway-based run.
Returns:
a sorted list of seconds since midnight, the start time of each run. If
this trip doesn't have headways returns an empty list. | [
"Return",
"a",
"list",
"of",
"start",
"time",
"for",
"each",
"headway",
"-",
"based",
"run",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L327-L343 | train |
google/transitfeed | transitfeed/trip.py | Trip._GenerateStopTimesTuples | def _GenerateStopTimesTuples(self):
"""Generator for rows of the stop_times file"""
stoptimes = self.GetStopTimes()
for i, st in enumerate(stoptimes):
yield st.GetFieldValuesTuple(self.trip_id) | python | def _GenerateStopTimesTuples(self):
"""Generator for rows of the stop_times file"""
stoptimes = self.GetStopTimes()
for i, st in enumerate(stoptimes):
yield st.GetFieldValuesTuple(self.trip_id) | [
"def",
"_GenerateStopTimesTuples",
"(",
"self",
")",
":",
"stoptimes",
"=",
"self",
".",
"GetStopTimes",
"(",
")",
"for",
"i",
",",
"st",
"in",
"enumerate",
"(",
"stoptimes",
")",
":",
"yield",
"st",
".",
"GetFieldValuesTuple",
"(",
"self",
".",
"trip_id",... | Generator for rows of the stop_times file | [
"Generator",
"for",
"rows",
"of",
"the",
"stop_times",
"file"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L362-L366 | train |
google/transitfeed | transitfeed/trip.py | Trip.GetPattern | def GetPattern(self):
"""Return a tuple of Stop objects, in the order visited"""
stoptimes = self.GetStopTimes()
return tuple(st.stop for st in stoptimes) | python | def GetPattern(self):
"""Return a tuple of Stop objects, in the order visited"""
stoptimes = self.GetStopTimes()
return tuple(st.stop for st in stoptimes) | [
"def",
"GetPattern",
"(",
"self",
")",
":",
"stoptimes",
"=",
"self",
".",
"GetStopTimes",
"(",
")",
"return",
"tuple",
"(",
"st",
".",
"stop",
"for",
"st",
"in",
"stoptimes",
")"
] | Return a tuple of Stop objects, in the order visited | [
"Return",
"a",
"tuple",
"of",
"Stop",
"objects",
"in",
"the",
"order",
"visited"
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L374-L377 | train |
google/transitfeed | transitfeed/trip.py | Trip.AddHeadwayPeriodObject | def AddHeadwayPeriodObject(self, headway_period, problem_reporter):
"""Deprecated. Please use AddFrequencyObject instead."""
warnings.warn("No longer supported. The HeadwayPeriod class was renamed to "
"Frequency, and all related functions were renamed "
"accordingly.", Depre... | python | def AddHeadwayPeriodObject(self, headway_period, problem_reporter):
"""Deprecated. Please use AddFrequencyObject instead."""
warnings.warn("No longer supported. The HeadwayPeriod class was renamed to "
"Frequency, and all related functions were renamed "
"accordingly.", Depre... | [
"def",
"AddHeadwayPeriodObject",
"(",
"self",
",",
"headway_period",
",",
"problem_reporter",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No longer supported. The HeadwayPeriod class was renamed to \"",
"\"Frequency, and all related functions were renamed \"",
"\"accordingly.\"",
",... | Deprecated. Please use AddFrequencyObject instead. | [
"Deprecated",
".",
"Please",
"use",
"AddFrequencyObject",
"instead",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L379-L384 | train |
google/transitfeed | transitfeed/trip.py | Trip.AddFrequencyObject | def AddFrequencyObject(self, frequency, problem_reporter):
"""Add a Frequency object to this trip's list of Frequencies."""
if frequency is not None:
self.AddFrequency(frequency.StartTime(),
frequency.EndTime(),
frequency.HeadwaySecs(),
... | python | def AddFrequencyObject(self, frequency, problem_reporter):
"""Add a Frequency object to this trip's list of Frequencies."""
if frequency is not None:
self.AddFrequency(frequency.StartTime(),
frequency.EndTime(),
frequency.HeadwaySecs(),
... | [
"def",
"AddFrequencyObject",
"(",
"self",
",",
"frequency",
",",
"problem_reporter",
")",
":",
"if",
"frequency",
"is",
"not",
"None",
":",
"self",
".",
"AddFrequency",
"(",
"frequency",
".",
"StartTime",
"(",
")",
",",
"frequency",
".",
"EndTime",
"(",
")... | Add a Frequency object to this trip's list of Frequencies. | [
"Add",
"a",
"Frequency",
"object",
"to",
"this",
"trip",
"s",
"list",
"of",
"Frequencies",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L386-L393 | train |
google/transitfeed | transitfeed/trip.py | Trip.AddHeadwayPeriod | def AddHeadwayPeriod(self, start_time, end_time, headway_secs,
problem_reporter=problems_module.default_problem_reporter):
"""Deprecated. Please use AddFrequency instead."""
warnings.warn("No longer supported. The HeadwayPeriod class was renamed to "
"Frequency, and all related functions... | python | def AddHeadwayPeriod(self, start_time, end_time, headway_secs,
problem_reporter=problems_module.default_problem_reporter):
"""Deprecated. Please use AddFrequency instead."""
warnings.warn("No longer supported. The HeadwayPeriod class was renamed to "
"Frequency, and all related functions... | [
"def",
"AddHeadwayPeriod",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"headway_secs",
",",
"problem_reporter",
"=",
"problems_module",
".",
"default_problem_reporter",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No longer supported. The HeadwayPeriod class was r... | Deprecated. Please use AddFrequency instead. | [
"Deprecated",
".",
"Please",
"use",
"AddFrequency",
"instead",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L395-L401 | train |
google/transitfeed | transitfeed/trip.py | Trip.Validate | def Validate(self, problems, validate_children=True):
"""Validate attributes of this object.
Check that this object has all required values set to a valid value without
reference to the rest of the schedule. If the _schedule attribute is set
then check that references such as route_id and service_id ar... | python | def Validate(self, problems, validate_children=True):
"""Validate attributes of this object.
Check that this object has all required values set to a valid value without
reference to the rest of the schedule. If the _schedule attribute is set
then check that references such as route_id and service_id ar... | [
"def",
"Validate",
"(",
"self",
",",
"problems",
",",
"validate_children",
"=",
"True",
")",
":",
"self",
".",
"ValidateRouteId",
"(",
"problems",
")",
"self",
".",
"ValidateServicePeriod",
"(",
"problems",
")",
"self",
".",
"ValidateDirectionId",
"(",
"proble... | Validate attributes of this object.
Check that this object has all required values set to a valid value without
reference to the rest of the schedule. If the _schedule attribute is set
then check that references such as route_id and service_id are correct.
Args:
problems: A ProblemReporter objec... | [
"Validate",
"attributes",
"of",
"this",
"object",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L551-L573 | train |
google/transitfeed | transitfeed/trip.py | Trip.ValidateChildren | def ValidateChildren(self, problems):
"""Validate StopTimes and headways of this trip."""
assert self._schedule, "Trip must be in a schedule to ValidateChildren"
# TODO: validate distance values in stop times (if applicable)
self.ValidateNoDuplicateStopSequences(problems)
stoptimes = self.GetStopTi... | python | def ValidateChildren(self, problems):
"""Validate StopTimes and headways of this trip."""
assert self._schedule, "Trip must be in a schedule to ValidateChildren"
# TODO: validate distance values in stop times (if applicable)
self.ValidateNoDuplicateStopSequences(problems)
stoptimes = self.GetStopTi... | [
"def",
"ValidateChildren",
"(",
"self",
",",
"problems",
")",
":",
"assert",
"self",
".",
"_schedule",
",",
"\"Trip must be in a schedule to ValidateChildren\"",
"# TODO: validate distance values in stop times (if applicable)",
"self",
".",
"ValidateNoDuplicateStopSequences",
"("... | Validate StopTimes and headways of this trip. | [
"Validate",
"StopTimes",
"and",
"headways",
"of",
"this",
"trip",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/trip.py#L697-L711 | train |
google/transitfeed | transitfeed/stoptime.py | StopTime.GetFieldValuesTuple | def GetFieldValuesTuple(self, trip_id):
"""Return a tuple that outputs a row of _FIELD_NAMES to be written to a
GTFS file.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime.
"""
result = [... | python | def GetFieldValuesTuple(self, trip_id):
"""Return a tuple that outputs a row of _FIELD_NAMES to be written to a
GTFS file.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime.
"""
result = [... | [
"def",
"GetFieldValuesTuple",
"(",
"self",
",",
"trip_id",
")",
":",
"result",
"=",
"[",
"]",
"for",
"fn",
"in",
"self",
".",
"_FIELD_NAMES",
":",
"if",
"fn",
"==",
"'trip_id'",
":",
"result",
".",
"append",
"(",
"trip_id",
")",
"else",
":",
"# Since w... | Return a tuple that outputs a row of _FIELD_NAMES to be written to a
GTFS file.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime. | [
"Return",
"a",
"tuple",
"that",
"outputs",
"a",
"row",
"of",
"_FIELD_NAMES",
"to",
"be",
"written",
"to",
"a",
"GTFS",
"file",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/stoptime.py#L165-L181 | train |
google/transitfeed | transitfeed/stoptime.py | StopTime.GetSqlValuesTuple | def GetSqlValuesTuple(self, trip_id):
"""Return a tuple that outputs a row of _FIELD_NAMES to be written to a
SQLite database.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime.
"""
resul... | python | def GetSqlValuesTuple(self, trip_id):
"""Return a tuple that outputs a row of _FIELD_NAMES to be written to a
SQLite database.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime.
"""
resul... | [
"def",
"GetSqlValuesTuple",
"(",
"self",
",",
"trip_id",
")",
":",
"result",
"=",
"[",
"]",
"for",
"fn",
"in",
"self",
".",
"_SQL_FIELD_NAMES",
":",
"if",
"fn",
"==",
"'trip_id'",
":",
"result",
".",
"append",
"(",
"trip_id",
")",
"else",
":",
"# Since... | Return a tuple that outputs a row of _FIELD_NAMES to be written to a
SQLite database.
Arguments:
trip_id: The trip_id of the trip to which this StopTime corresponds.
It must be provided, as it is not stored in StopTime. | [
"Return",
"a",
"tuple",
"that",
"outputs",
"a",
"row",
"of",
"_FIELD_NAMES",
"to",
"be",
"written",
"to",
"a",
"SQLite",
"database",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/stoptime.py#L183-L201 | train |
google/transitfeed | transitfeed/stoptime.py | StopTime.GetTimeSecs | def GetTimeSecs(self):
"""Return the first of arrival_secs and departure_secs that is not None.
If both are None return None."""
if self.arrival_secs != None:
return self.arrival_secs
elif self.departure_secs != None:
return self.departure_secs
else:
return None | python | def GetTimeSecs(self):
"""Return the first of arrival_secs and departure_secs that is not None.
If both are None return None."""
if self.arrival_secs != None:
return self.arrival_secs
elif self.departure_secs != None:
return self.departure_secs
else:
return None | [
"def",
"GetTimeSecs",
"(",
"self",
")",
":",
"if",
"self",
".",
"arrival_secs",
"!=",
"None",
":",
"return",
"self",
".",
"arrival_secs",
"elif",
"self",
".",
"departure_secs",
"!=",
"None",
":",
"return",
"self",
".",
"departure_secs",
"else",
":",
"retur... | Return the first of arrival_secs and departure_secs that is not None.
If both are None return None. | [
"Return",
"the",
"first",
"of",
"arrival_secs",
"and",
"departure_secs",
"that",
"is",
"not",
"None",
".",
"If",
"both",
"are",
"None",
"return",
"None",
"."
] | eb2991a3747ba541b2cb66502b305b6304a1f85f | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/stoptime.py#L203-L211 | train |
equinor/segyio | python/segyio/create.py | create | def create(filename, spec):
"""Create a new segy file.
Create a new segy file with the geometry and properties given by `spec`.
This enables creating SEGY files from your data. The created file supports
all segyio modes, but has an emphasis on writing. The spec must be
complete, otherwise an except... | python | def create(filename, spec):
"""Create a new segy file.
Create a new segy file with the geometry and properties given by `spec`.
This enables creating SEGY files from your data. The created file supports
all segyio modes, but has an emphasis on writing. The spec must be
complete, otherwise an except... | [
"def",
"create",
"(",
"filename",
",",
"spec",
")",
":",
"from",
".",
"import",
"_segyio",
"if",
"not",
"structured",
"(",
"spec",
")",
":",
"tracecount",
"=",
"spec",
".",
"tracecount",
"else",
":",
"tracecount",
"=",
"len",
"(",
"spec",
".",
"ilines"... | Create a new segy file.
Create a new segy file with the geometry and properties given by `spec`.
This enables creating SEGY files from your data. The created file supports
all segyio modes, but has an emphasis on writing. The spec must be
complete, otherwise an exception will be raised. A default, empt... | [
"Create",
"a",
"new",
"segy",
"file",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/create.py#L38-L246 | train |
equinor/segyio | python/segyio/su/file.py | open | def open(filename, mode = 'r', iline = 189,
xline = 193,
strict = True,
ignore_geometry = False,
endian = 'big' ):
"""Open a seismic unix file.
Behaves identically to open(), except it ex... | python | def open(filename, mode = 'r', iline = 189,
xline = 193,
strict = True,
ignore_geometry = False,
endian = 'big' ):
"""Open a seismic unix file.
Behaves identically to open(), except it ex... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"iline",
"=",
"189",
",",
"xline",
"=",
"193",
",",
"strict",
"=",
"True",
",",
"ignore_geometry",
"=",
"False",
",",
"endian",
"=",
"'big'",
")",
":",
"if",
"'w'",
"in",
"mode",
":",
... | Open a seismic unix file.
Behaves identically to open(), except it expects the seismic unix format,
not SEG-Y.
Parameters
----------
filename : str
Path to file to open
mode : {'r', 'r+'}
File access mode, read-only ('r', default) or read-write ('r+')
iline : int or segyi... | [
"Open",
"a",
"seismic",
"unix",
"file",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/su/file.py#L23-L118 | train |
equinor/segyio | python/segyio/tools.py | create_text_header | def create_text_header(lines):
"""Format textual header
Create a "correct" SEG-Y textual header. Every line will be prefixed with
C## and there are 40 lines. The input must be a dictionary with the line
number[1-40] as a key. The value for each key should be up to 76 character
long string.
Pa... | python | def create_text_header(lines):
"""Format textual header
Create a "correct" SEG-Y textual header. Every line will be prefixed with
C## and there are 40 lines. The input must be a dictionary with the line
number[1-40] as a key. The value for each key should be up to 76 character
long string.
Pa... | [
"def",
"create_text_header",
"(",
"lines",
")",
":",
"rows",
"=",
"[",
"]",
"for",
"line_no",
"in",
"range",
"(",
"1",
",",
"41",
")",
":",
"line",
"=",
"\"\"",
"if",
"line_no",
"in",
"lines",
":",
"line",
"=",
"lines",
"[",
"line_no",
"]",
"row",
... | Format textual header
Create a "correct" SEG-Y textual header. Every line will be prefixed with
C## and there are 40 lines. The input must be a dictionary with the line
number[1-40] as a key. The value for each key should be up to 76 character
long string.
Parameters
----------
lines : d... | [
"Format",
"textual",
"header"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L65-L98 | train |
equinor/segyio | python/segyio/tools.py | wrap | def wrap(s, width=80):
"""
Formats the text input with newlines given the user specified width for
each line.
Parameters
----------
s : str
width : int
Returns
-------
text : str
Notes
-----
.. versionadded:: 1.1
"""
return '\n'.join(textwrap.wrap(str(s... | python | def wrap(s, width=80):
"""
Formats the text input with newlines given the user specified width for
each line.
Parameters
----------
s : str
width : int
Returns
-------
text : str
Notes
-----
.. versionadded:: 1.1
"""
return '\n'.join(textwrap.wrap(str(s... | [
"def",
"wrap",
"(",
"s",
",",
"width",
"=",
"80",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"textwrap",
".",
"wrap",
"(",
"str",
"(",
"s",
")",
",",
"width",
"=",
"width",
")",
")"
] | Formats the text input with newlines given the user specified width for
each line.
Parameters
----------
s : str
width : int
Returns
-------
text : str
Notes
-----
.. versionadded:: 1.1 | [
"Formats",
"the",
"text",
"input",
"with",
"newlines",
"given",
"the",
"user",
"specified",
"width",
"for",
"each",
"line",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L100-L122 | train |
equinor/segyio | python/segyio/tools.py | native | def native(data,
format = segyio.SegySampleFormat.IBM_FLOAT_4_BYTE,
copy = True):
"""Convert numpy array to native float
Converts a numpy array from raw segy trace data to native floats. Works for numpy ndarrays.
Parameters
----------
data : numpy.ndarray
format : int or... | python | def native(data,
format = segyio.SegySampleFormat.IBM_FLOAT_4_BYTE,
copy = True):
"""Convert numpy array to native float
Converts a numpy array from raw segy trace data to native floats. Works for numpy ndarrays.
Parameters
----------
data : numpy.ndarray
format : int or... | [
"def",
"native",
"(",
"data",
",",
"format",
"=",
"segyio",
".",
"SegySampleFormat",
".",
"IBM_FLOAT_4_BYTE",
",",
"copy",
"=",
"True",
")",
":",
"data",
"=",
"data",
".",
"view",
"(",
"dtype",
"=",
"np",
".",
"single",
")",
"if",
"copy",
":",
"data"... | Convert numpy array to native float
Converts a numpy array from raw segy trace data to native floats. Works for numpy ndarrays.
Parameters
----------
data : numpy.ndarray
format : int or segyio.SegySampleFormat
copy : bool
If True, convert on a copy, and leave the input array unmodifi... | [
"Convert",
"numpy",
"array",
"to",
"native",
"float"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L125-L166 | train |
equinor/segyio | python/segyio/tools.py | cube | def cube(f):
"""Read a full cube from a file
Takes an open segy file (created with segyio.open) or a file name.
If the file is a prestack file, the cube returned has the dimensions
``(fast, slow, offset, sample)``. If it is post-stack (only the one
offset), the dimensions are normalised to ``(fast... | python | def cube(f):
"""Read a full cube from a file
Takes an open segy file (created with segyio.open) or a file name.
If the file is a prestack file, the cube returned has the dimensions
``(fast, slow, offset, sample)``. If it is post-stack (only the one
offset), the dimensions are normalised to ``(fast... | [
"def",
"cube",
"(",
"f",
")",
":",
"if",
"not",
"isinstance",
"(",
"f",
",",
"segyio",
".",
"SegyFile",
")",
":",
"with",
"segyio",
".",
"open",
"(",
"f",
")",
"as",
"fl",
":",
"return",
"cube",
"(",
"fl",
")",
"ilsort",
"=",
"f",
".",
"sorting... | Read a full cube from a file
Takes an open segy file (created with segyio.open) or a file name.
If the file is a prestack file, the cube returned has the dimensions
``(fast, slow, offset, sample)``. If it is post-stack (only the one
offset), the dimensions are normalised to ``(fast, slow, sample)``
... | [
"Read",
"a",
"full",
"cube",
"from",
"a",
"file"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L203-L239 | train |
equinor/segyio | python/segyio/tools.py | rotation | def rotation(f, line = 'fast'):
""" Find rotation of the survey
Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
The clock-wise rotation is defined as the angle in radians between line
given by the first and last trace of the first line and the axis that gives
increasing ... | python | def rotation(f, line = 'fast'):
""" Find rotation of the survey
Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
The clock-wise rotation is defined as the angle in radians between line
given by the first and last trace of the first line and the axis that gives
increasing ... | [
"def",
"rotation",
"(",
"f",
",",
"line",
"=",
"'fast'",
")",
":",
"if",
"f",
".",
"unstructured",
":",
"raise",
"ValueError",
"(",
"\"Rotation requires a structured file\"",
")",
"lines",
"=",
"{",
"'fast'",
":",
"f",
".",
"fast",
",",
"'slow'",
":",
"f... | Find rotation of the survey
Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
The clock-wise rotation is defined as the angle in radians between line
given by the first and last trace of the first line and the axis that gives
increasing CDP-Y, in the direction that gives incre... | [
"Find",
"rotation",
"of",
"the",
"survey"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L241-L297 | train |
equinor/segyio | python/segyio/tools.py | metadata | def metadata(f):
"""Get survey structural properties and metadata
Create a description object that, when passed to ``segyio.create()``, would
create a new file with the same structure, dimensions, and metadata as
``f``.
Takes an open segy file (created with segyio.open) or a file name.
Parame... | python | def metadata(f):
"""Get survey structural properties and metadata
Create a description object that, when passed to ``segyio.create()``, would
create a new file with the same structure, dimensions, and metadata as
``f``.
Takes an open segy file (created with segyio.open) or a file name.
Parame... | [
"def",
"metadata",
"(",
"f",
")",
":",
"if",
"not",
"isinstance",
"(",
"f",
",",
"segyio",
".",
"SegyFile",
")",
":",
"with",
"segyio",
".",
"open",
"(",
"f",
")",
"as",
"fl",
":",
"return",
"metadata",
"(",
"fl",
")",
"spec",
"=",
"segyio",
".",... | Get survey structural properties and metadata
Create a description object that, when passed to ``segyio.create()``, would
create a new file with the same structure, dimensions, and metadata as
``f``.
Takes an open segy file (created with segyio.open) or a file name.
Parameters
----------
... | [
"Get",
"survey",
"structural",
"properties",
"and",
"metadata"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L299-L345 | train |
equinor/segyio | python/segyio/tools.py | resample | def resample(f, rate = None, delay = None, micro = False,
trace = True,
binary = True):
"""Resample a file
Resample all data traces, and update the file handle to reflect the new
sample rate. No actual samples (data trace... | python | def resample(f, rate = None, delay = None, micro = False,
trace = True,
binary = True):
"""Resample a file
Resample all data traces, and update the file handle to reflect the new
sample rate. No actual samples (data trace... | [
"def",
"resample",
"(",
"f",
",",
"rate",
"=",
"None",
",",
"delay",
"=",
"None",
",",
"micro",
"=",
"False",
",",
"trace",
"=",
"True",
",",
"binary",
"=",
"True",
")",
":",
"if",
"rate",
"is",
"not",
"None",
":",
"if",
"not",
"micro",
":",
"r... | Resample a file
Resample all data traces, and update the file handle to reflect the new
sample rate. No actual samples (data traces) are modified, only the header
fields and interpretation.
By default, the rate and the delay are in millseconds - if you need higher
resolution, passing micro=True in... | [
"Resample",
"a",
"file"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L347-L408 | train |
equinor/segyio | python/segyio/tools.py | from_array3D | def from_array3D(filename, data, iline=189,
xline=193,
format=SegySampleFormat.IBM_FLOAT_4_BYTE,
dt=4000,
delrt=0):
""" Create a new SEGY file from a 3D array
Create an structured ... | python | def from_array3D(filename, data, iline=189,
xline=193,
format=SegySampleFormat.IBM_FLOAT_4_BYTE,
dt=4000,
delrt=0):
""" Create a new SEGY file from a 3D array
Create an structured ... | [
"def",
"from_array3D",
"(",
"filename",
",",
"data",
",",
"iline",
"=",
"189",
",",
"xline",
"=",
"193",
",",
"format",
"=",
"SegySampleFormat",
".",
"IBM_FLOAT_4_BYTE",
",",
"dt",
"=",
"4000",
",",
"delrt",
"=",
"0",
")",
":",
"data",
"=",
"np",
"."... | Create a new SEGY file from a 3D array
Create an structured SEGY file with defaulted headers from a 3-dimensional
array. The file is inline-sorted. ilines, xlines and samples are inferred
from the array. Structure-defining fields in the binary header and
in the traceheaders are set accordingly. Such fie... | [
"Create",
"a",
"new",
"SEGY",
"file",
"from",
"a",
"3D",
"array",
"Create",
"an",
"structured",
"SEGY",
"file",
"with",
"defaulted",
"headers",
"from",
"a",
"3",
"-",
"dimensional",
"array",
".",
"The",
"file",
"is",
"inline",
"-",
"sorted",
".",
"ilines... | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L592-L662 | train |
equinor/segyio | python/segyio/open.py | open | def open(filename, mode="r", iline = 189,
xline = 193,
strict = True,
ignore_geometry = False,
endian = 'big'):
"""Open a segy file.
Opens a segy file and tries to figure out its sorting, inline ... | python | def open(filename, mode="r", iline = 189,
xline = 193,
strict = True,
ignore_geometry = False,
endian = 'big'):
"""Open a segy file.
Opens a segy file and tries to figure out its sorting, inline ... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"\"r\"",
",",
"iline",
"=",
"189",
",",
"xline",
"=",
"193",
",",
"strict",
"=",
"True",
",",
"ignore_geometry",
"=",
"False",
",",
"endian",
"=",
"'big'",
")",
":",
"if",
"'w'",
"in",
"mode",
":",
... | Open a segy file.
Opens a segy file and tries to figure out its sorting, inline numbers,
crossline numbers, and offsets, and enables reading and writing to this
file in a simple manner.
For reading, the access mode `r` is preferred. All write operations will
raise an exception. For writing, the mo... | [
"Open",
"a",
"segy",
"file",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/open.py#L33-L187 | train |
equinor/segyio | python/segyio/field.py | Field.fetch | def fetch(self, buf = None, traceno = None):
"""Fetch the header from disk
This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
This method is largely meant for internal use - if you need to reload
... | python | def fetch(self, buf = None, traceno = None):
"""Fetch the header from disk
This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
This method is largely meant for internal use - if you need to reload
... | [
"def",
"fetch",
"(",
"self",
",",
"buf",
"=",
"None",
",",
"traceno",
"=",
"None",
")",
":",
"if",
"buf",
"is",
"None",
":",
"buf",
"=",
"self",
".",
"buf",
"if",
"traceno",
"is",
"None",
":",
"traceno",
"=",
"self",
".",
"traceno",
"try",
":",
... | Fetch the header from disk
This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
This method is largely meant for internal use - if you need to reload
disk contents, use ``reload``.
Fetch does ... | [
"Fetch",
"the",
"header",
"from",
"disk"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/field.py#L183-L243 | train |
equinor/segyio | python/segyio/field.py | Field.reload | def reload(self):
"""
This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
It's rarely required to call this method, and it's a symptom of fragile
code. However, if you have multiple handles to... | python | def reload(self):
"""
This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
It's rarely required to call this method, and it's a symptom of fragile
code. However, if you have multiple handles to... | [
"def",
"reload",
"(",
"self",
")",
":",
"self",
".",
"buf",
"=",
"self",
".",
"fetch",
"(",
"buf",
"=",
"self",
".",
"buf",
")",
"return",
"self"
] | This object will read header when it is constructed, which means it
might be out-of-date if the file is updated through some other handle.
It's rarely required to call this method, and it's a symptom of fragile
code. However, if you have multiple handles to the same header, it
might be ... | [
"This",
"object",
"will",
"read",
"header",
"when",
"it",
"is",
"constructed",
"which",
"means",
"it",
"might",
"be",
"out",
"-",
"of",
"-",
"date",
"if",
"the",
"file",
"is",
"updated",
"through",
"some",
"other",
"handle",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/field.py#L245-L288 | train |
equinor/segyio | python/segyio/field.py | Field.flush | def flush(self):
"""Commit backing storage to disk
This method is largely internal, and it is not necessary to call this
from user code. It should not be explicitly invoked and may be removed
in future versions.
"""
if self.kind == TraceField:
self.filehandl... | python | def flush(self):
"""Commit backing storage to disk
This method is largely internal, and it is not necessary to call this
from user code. It should not be explicitly invoked and may be removed
in future versions.
"""
if self.kind == TraceField:
self.filehandl... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"kind",
"==",
"TraceField",
":",
"self",
".",
"filehandle",
".",
"putth",
"(",
"self",
".",
"traceno",
",",
"self",
".",
"buf",
")",
"elif",
"self",
".",
"kind",
"==",
"BinField",
":",
"self... | Commit backing storage to disk
This method is largely internal, and it is not necessary to call this
from user code. It should not be explicitly invoked and may be removed
in future versions. | [
"Commit",
"backing",
"storage",
"to",
"disk"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/field.py#L290-L306 | train |
equinor/segyio | python/segyio/trace.py | Trace.raw | def raw(self):
"""
An eager version of Trace
Returns
-------
raw : RawTrace
"""
return RawTrace(self.filehandle,
self.dtype,
len(self),
self.shape,
self.readonly,
... | python | def raw(self):
"""
An eager version of Trace
Returns
-------
raw : RawTrace
"""
return RawTrace(self.filehandle,
self.dtype,
len(self),
self.shape,
self.readonly,
... | [
"def",
"raw",
"(",
"self",
")",
":",
"return",
"RawTrace",
"(",
"self",
".",
"filehandle",
",",
"self",
".",
"dtype",
",",
"len",
"(",
"self",
")",
",",
"self",
".",
"shape",
",",
"self",
".",
"readonly",
",",
")"
] | An eager version of Trace
Returns
-------
raw : RawTrace | [
"An",
"eager",
"version",
"of",
"Trace"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/trace.py#L253-L266 | train |
equinor/segyio | python/segyio/trace.py | Trace.ref | def ref(self):
"""
A write-back version of Trace
Returns
-------
ref : RefTrace
`ref` is returned in a context manager, and must be in a ``with``
statement
Notes
-----
.. versionadded:: 1.6
Examples
--------
... | python | def ref(self):
"""
A write-back version of Trace
Returns
-------
ref : RefTrace
`ref` is returned in a context manager, and must be in a ``with``
statement
Notes
-----
.. versionadded:: 1.6
Examples
--------
... | [
"def",
"ref",
"(",
"self",
")",
":",
"x",
"=",
"RefTrace",
"(",
"self",
".",
"filehandle",
",",
"self",
".",
"dtype",
",",
"len",
"(",
"self",
")",
",",
"self",
".",
"shape",
",",
"self",
".",
"readonly",
",",
")",
"yield",
"x",
"x",
".",
"flus... | A write-back version of Trace
Returns
-------
ref : RefTrace
`ref` is returned in a context manager, and must be in a ``with``
statement
Notes
-----
.. versionadded:: 1.6
Examples
--------
>>> with trace.ref as ref:
... | [
"A",
"write",
"-",
"back",
"version",
"of",
"Trace"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/trace.py#L270-L297 | train |
equinor/segyio | python/segyio/trace.py | RefTrace.flush | def flush(self):
"""
Commit cached writes to the file handle. Does not flush libc buffers or
notifies the kernel, so these changes may not immediately be visible to
other processes.
Updates the fingerprints whena writes happen, so successive ``flush()``
invocations are n... | python | def flush(self):
"""
Commit cached writes to the file handle. Does not flush libc buffers or
notifies the kernel, so these changes may not immediately be visible to
other processes.
Updates the fingerprints whena writes happen, so successive ``flush()``
invocations are n... | [
"def",
"flush",
"(",
"self",
")",
":",
"garbage",
"=",
"[",
"]",
"for",
"i",
",",
"(",
"x",
",",
"signature",
")",
"in",
"self",
".",
"refs",
".",
"items",
"(",
")",
":",
"if",
"sys",
".",
"getrefcount",
"(",
"x",
")",
"==",
"3",
":",
"garbag... | Commit cached writes to the file handle. Does not flush libc buffers or
notifies the kernel, so these changes may not immediately be visible to
other processes.
Updates the fingerprints whena writes happen, so successive ``flush()``
invocations are no-ops.
It is not necessary t... | [
"Commit",
"cached",
"writes",
"to",
"the",
"file",
"handle",
".",
"Does",
"not",
"flush",
"libc",
"buffers",
"or",
"notifies",
"the",
"kernel",
"so",
"these",
"changes",
"may",
"not",
"immediately",
"be",
"visible",
"to",
"other",
"processes",
"."
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/trace.py#L376-L408 | train |
equinor/segyio | python/segyio/segy.py | SegyFile.iline | def iline(self):
"""
Interact with segy in inline mode
Returns
-------
iline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1
"""
if self.unstructu... | python | def iline(self):
"""
Interact with segy in inline mode
Returns
-------
iline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1
"""
if self.unstructu... | [
"def",
"iline",
"(",
"self",
")",
":",
"if",
"self",
".",
"unstructured",
":",
"raise",
"ValueError",
"(",
"self",
".",
"_unstructured_errmsg",
")",
"if",
"self",
".",
"_iline",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_iline",
"self",
".",
"_... | Interact with segy in inline mode
Returns
-------
iline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1 | [
"Interact",
"with",
"segy",
"in",
"inline",
"mode"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/segy.py#L501-L532 | train |
equinor/segyio | python/segyio/segy.py | SegyFile.xline | def xline(self):
"""
Interact with segy in crossline mode
Returns
-------
xline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1
"""
if self.unstruc... | python | def xline(self):
"""
Interact with segy in crossline mode
Returns
-------
xline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1
"""
if self.unstruc... | [
"def",
"xline",
"(",
"self",
")",
":",
"if",
"self",
".",
"unstructured",
":",
"raise",
"ValueError",
"(",
"self",
".",
"_unstructured_errmsg",
")",
"if",
"self",
".",
"_xline",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_xline",
"self",
".",
"_... | Interact with segy in crossline mode
Returns
-------
xline : Line or None
Raises
------
ValueError
If the file is unstructured
Notes
-----
.. versionadded:: 1.1 | [
"Interact",
"with",
"segy",
"in",
"crossline",
"mode"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/segy.py#L573-L603 | train |
equinor/segyio | python/segyio/segy.py | SegyFile.fast | def fast(self):
"""Access the 'fast' dimension
This mode yields iline or xline mode, depending on which one is laid
out `faster`, i.e. the line with linear disk layout. Use this mode if
the inline/crossline distinction isn't as interesting as traversing in
a fast manner (typical... | python | def fast(self):
"""Access the 'fast' dimension
This mode yields iline or xline mode, depending on which one is laid
out `faster`, i.e. the line with linear disk layout. Use this mode if
the inline/crossline distinction isn't as interesting as traversing in
a fast manner (typical... | [
"def",
"fast",
"(",
"self",
")",
":",
"if",
"self",
".",
"sorting",
"==",
"TraceSortingFormat",
".",
"INLINE_SORTING",
":",
"return",
"self",
".",
"iline",
"elif",
"self",
".",
"sorting",
"==",
"TraceSortingFormat",
".",
"CROSSLINE_SORTING",
":",
"return",
"... | Access the 'fast' dimension
This mode yields iline or xline mode, depending on which one is laid
out `faster`, i.e. the line with linear disk layout. Use this mode if
the inline/crossline distinction isn't as interesting as traversing in
a fast manner (typically when you want to apply a... | [
"Access",
"the",
"fast",
"dimension"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/segy.py#L630-L653 | train |
equinor/segyio | python/segyio/segy.py | SegyFile.gather | def gather(self):
"""
Interact with segy in gather mode
Returns
-------
gather : Gather
"""
if self.unstructured:
raise ValueError(self._unstructured_errmsg)
if self._gather is not None:
return self._gather
self._gather =... | python | def gather(self):
"""
Interact with segy in gather mode
Returns
-------
gather : Gather
"""
if self.unstructured:
raise ValueError(self._unstructured_errmsg)
if self._gather is not None:
return self._gather
self._gather =... | [
"def",
"gather",
"(",
"self",
")",
":",
"if",
"self",
".",
"unstructured",
":",
"raise",
"ValueError",
"(",
"self",
".",
"_unstructured_errmsg",
")",
"if",
"self",
".",
"_gather",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_gather",
"self",
".",
... | Interact with segy in gather mode
Returns
-------
gather : Gather | [
"Interact",
"with",
"segy",
"in",
"gather",
"mode"
] | 58fd449947ccd330b9af0699d6b8710550d34e8e | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/segy.py#L729-L744 | train |
pymc-devs/pymc | pymc/StepMethods.py | pick_best_methods | def pick_best_methods(stochastic):
"""
Picks the StepMethods best suited to handle
a stochastic variable.
"""
# Keep track of most competent methohd
max_competence = 0
# Empty set of appropriate StepMethods
best_candidates = set([])
# Loop over StepMethodRegistry
for method in ... | python | def pick_best_methods(stochastic):
"""
Picks the StepMethods best suited to handle
a stochastic variable.
"""
# Keep track of most competent methohd
max_competence = 0
# Empty set of appropriate StepMethods
best_candidates = set([])
# Loop over StepMethodRegistry
for method in ... | [
"def",
"pick_best_methods",
"(",
"stochastic",
")",
":",
"# Keep track of most competent methohd",
"max_competence",
"=",
"0",
"# Empty set of appropriate StepMethods",
"best_candidates",
"=",
"set",
"(",
"[",
"]",
")",
"# Loop over StepMethodRegistry",
"for",
"method",
"in... | Picks the StepMethods best suited to handle
a stochastic variable. | [
"Picks",
"the",
"StepMethods",
"best",
"suited",
"to",
"handle",
"a",
"stochastic",
"variable",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L59-L94 | train |
pymc-devs/pymc | pymc/StepMethods.py | StepMethod.loglike | def loglike(self):
'''
The summed log-probability of all stochastic variables that depend on
self.stochastics, with self.stochastics removed.
'''
sum = logp_of_set(self.children)
if self.verbose > 2:
print_('\t' + self._id + ' Current log-likelihood ', sum)
... | python | def loglike(self):
'''
The summed log-probability of all stochastic variables that depend on
self.stochastics, with self.stochastics removed.
'''
sum = logp_of_set(self.children)
if self.verbose > 2:
print_('\t' + self._id + ' Current log-likelihood ', sum)
... | [
"def",
"loglike",
"(",
"self",
")",
":",
"sum",
"=",
"logp_of_set",
"(",
"self",
".",
"children",
")",
"if",
"self",
".",
"verbose",
">",
"2",
":",
"print_",
"(",
"'\\t'",
"+",
"self",
".",
"_id",
"+",
"' Current log-likelihood '",
",",
"sum",
")",
"... | The summed log-probability of all stochastic variables that depend on
self.stochastics, with self.stochastics removed. | [
"The",
"summed",
"log",
"-",
"probability",
"of",
"all",
"stochastic",
"variables",
"that",
"depend",
"on",
"self",
".",
"stochastics",
"with",
"self",
".",
"stochastics",
"removed",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L292-L300 | train |
pymc-devs/pymc | pymc/StepMethods.py | StepMethod.logp_plus_loglike | def logp_plus_loglike(self):
'''
The summed log-probability of all stochastic variables that depend on
self.stochastics, and self.stochastics.
'''
sum = logp_of_set(self.markov_blanket)
if self.verbose > 2:
print_('\t' + self._id +
' Current... | python | def logp_plus_loglike(self):
'''
The summed log-probability of all stochastic variables that depend on
self.stochastics, and self.stochastics.
'''
sum = logp_of_set(self.markov_blanket)
if self.verbose > 2:
print_('\t' + self._id +
' Current... | [
"def",
"logp_plus_loglike",
"(",
"self",
")",
":",
"sum",
"=",
"logp_of_set",
"(",
"self",
".",
"markov_blanket",
")",
"if",
"self",
".",
"verbose",
">",
"2",
":",
"print_",
"(",
"'\\t'",
"+",
"self",
".",
"_id",
"+",
"' Current log-likelihood plus current l... | The summed log-probability of all stochastic variables that depend on
self.stochastics, and self.stochastics. | [
"The",
"summed",
"log",
"-",
"probability",
"of",
"all",
"stochastic",
"variables",
"that",
"depend",
"on",
"self",
".",
"stochastics",
"and",
"self",
".",
"stochastics",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L303-L312 | train |
pymc-devs/pymc | pymc/StepMethods.py | StepMethod.current_state | def current_state(self):
"""Return a dictionary with the current value of the variables defining
the state of the step method."""
state = {}
for s in self._state:
state[s] = getattr(self, s)
return state | python | def current_state(self):
"""Return a dictionary with the current value of the variables defining
the state of the step method."""
state = {}
for s in self._state:
state[s] = getattr(self, s)
return state | [
"def",
"current_state",
"(",
"self",
")",
":",
"state",
"=",
"{",
"}",
"for",
"s",
"in",
"self",
".",
"_state",
":",
"state",
"[",
"s",
"]",
"=",
"getattr",
"(",
"self",
",",
"s",
")",
"return",
"state"
] | Return a dictionary with the current value of the variables defining
the state of the step method. | [
"Return",
"a",
"dictionary",
"with",
"the",
"current",
"value",
"of",
"the",
"variables",
"defining",
"the",
"state",
"of",
"the",
"step",
"method",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L318-L324 | train |
pymc-devs/pymc | pymc/StepMethods.py | Metropolis.step | def step(self):
"""
The default step method applies if the variable is floating-point
valued, and is not being proposed from its prior.
"""
# Probability and likelihood for s's current value:
if self.verbose > 2:
print_()
print_(self._id + ' gett... | python | def step(self):
"""
The default step method applies if the variable is floating-point
valued, and is not being proposed from its prior.
"""
# Probability and likelihood for s's current value:
if self.verbose > 2:
print_()
print_(self._id + ' gett... | [
"def",
"step",
"(",
"self",
")",
":",
"# Probability and likelihood for s's current value:",
"if",
"self",
".",
"verbose",
">",
"2",
":",
"print_",
"(",
")",
"print_",
"(",
"self",
".",
"_id",
"+",
"' getting initial logp.'",
")",
"if",
"self",
".",
"proposal_... | The default step method applies if the variable is floating-point
valued, and is not being proposed from its prior. | [
"The",
"default",
"step",
"method",
"applies",
"if",
"the",
"variable",
"is",
"floating",
"-",
"point",
"valued",
"and",
"is",
"not",
"being",
"proposed",
"from",
"its",
"prior",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L470-L539 | train |
pymc-devs/pymc | pymc/StepMethods.py | PDMatrixMetropolis.competence | def competence(s):
"""
The competence function for MatrixMetropolis
"""
# MatrixMetropolis handles the Wishart family, which are valued as
# _symmetric_ matrices.
if any([isinstance(s, cls)
for cls in [distributions.Wishart, distributions.WishartCov]]):
... | python | def competence(s):
"""
The competence function for MatrixMetropolis
"""
# MatrixMetropolis handles the Wishart family, which are valued as
# _symmetric_ matrices.
if any([isinstance(s, cls)
for cls in [distributions.Wishart, distributions.WishartCov]]):
... | [
"def",
"competence",
"(",
"s",
")",
":",
"# MatrixMetropolis handles the Wishart family, which are valued as",
"# _symmetric_ matrices.",
"if",
"any",
"(",
"[",
"isinstance",
"(",
"s",
",",
"cls",
")",
"for",
"cls",
"in",
"[",
"distributions",
".",
"Wishart",
",",
... | The competence function for MatrixMetropolis | [
"The",
"competence",
"function",
"for",
"MatrixMetropolis"
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L657-L667 | train |
pymc-devs/pymc | pymc/StepMethods.py | PDMatrixMetropolis.propose | def propose(self):
"""
Proposals for positive definite matrix using random walk deviations on the Cholesky
factor of the current value.
"""
# Locally store size of matrix
dims = self.stochastic.value.shape
# Add normal deviate to value and symmetrize
dev... | python | def propose(self):
"""
Proposals for positive definite matrix using random walk deviations on the Cholesky
factor of the current value.
"""
# Locally store size of matrix
dims = self.stochastic.value.shape
# Add normal deviate to value and symmetrize
dev... | [
"def",
"propose",
"(",
"self",
")",
":",
"# Locally store size of matrix",
"dims",
"=",
"self",
".",
"stochastic",
".",
"value",
".",
"shape",
"# Add normal deviate to value and symmetrize",
"dev",
"=",
"rnormal",
"(",
"0",
",",
"self",
".",
"adaptive_scale_factor",... | Proposals for positive definite matrix using random walk deviations on the Cholesky
factor of the current value. | [
"Proposals",
"for",
"positive",
"definite",
"matrix",
"using",
"random",
"walk",
"deviations",
"on",
"the",
"Cholesky",
"factor",
"of",
"the",
"current",
"value",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L669-L687 | train |
pymc-devs/pymc | pymc/StepMethods.py | BinaryMetropolis.competence | def competence(stochastic):
"""
The competence function for Binary One-At-A-Time Metropolis
"""
if stochastic.dtype in bool_dtypes:
return 2
elif isinstance(stochastic, distributions.Bernoulli):
return 2
elif (isinstance(stochastic, d... | python | def competence(stochastic):
"""
The competence function for Binary One-At-A-Time Metropolis
"""
if stochastic.dtype in bool_dtypes:
return 2
elif isinstance(stochastic, distributions.Bernoulli):
return 2
elif (isinstance(stochastic, d... | [
"def",
"competence",
"(",
"stochastic",
")",
":",
"if",
"stochastic",
".",
"dtype",
"in",
"bool_dtypes",
":",
"return",
"2",
"elif",
"isinstance",
"(",
"stochastic",
",",
"distributions",
".",
"Bernoulli",
")",
":",
"return",
"2",
"elif",
"(",
"isinstance",
... | The competence function for Binary One-At-A-Time Metropolis | [
"The",
"competence",
"function",
"for",
"Binary",
"One",
"-",
"At",
"-",
"A",
"-",
"Time",
"Metropolis"
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L901-L916 | train |
pymc-devs/pymc | pymc/StepMethods.py | AdaptiveMetropolis.cov_from_value | def cov_from_value(self, scaling):
"""Return a covariance matrix for the jump distribution using
the actual value of the stochastic as a guess of their variance,
divided by the `scaling` argument.
Note that this is likely to return a poor guess.
"""
rv = []
for s... | python | def cov_from_value(self, scaling):
"""Return a covariance matrix for the jump distribution using
the actual value of the stochastic as a guess of their variance,
divided by the `scaling` argument.
Note that this is likely to return a poor guess.
"""
rv = []
for s... | [
"def",
"cov_from_value",
"(",
"self",
",",
"scaling",
")",
":",
"rv",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"stochastics",
":",
"rv",
".",
"extend",
"(",
"np",
".",
"ravel",
"(",
"s",
".",
"value",
")",
".",
"copy",
"(",
")",
")",
"# Re... | Return a covariance matrix for the jump distribution using
the actual value of the stochastic as a guess of their variance,
divided by the `scaling` argument.
Note that this is likely to return a poor guess. | [
"Return",
"a",
"covariance",
"matrix",
"for",
"the",
"jump",
"distribution",
"using",
"the",
"actual",
"value",
"of",
"the",
"stochastic",
"as",
"a",
"guess",
"of",
"their",
"variance",
"divided",
"by",
"the",
"scaling",
"argument",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1135-L1151 | train |
pymc-devs/pymc | pymc/StepMethods.py | AdaptiveMetropolis.cov_from_scales | def cov_from_scales(self, scales):
"""Return a covariance matrix built from a dictionary of scales.
`scales` is a dictionary keyed by stochastic instances, and the
values refer are the variance of the jump distribution for each
stochastic. If a stochastic is a sequence, the variance mus... | python | def cov_from_scales(self, scales):
"""Return a covariance matrix built from a dictionary of scales.
`scales` is a dictionary keyed by stochastic instances, and the
values refer are the variance of the jump distribution for each
stochastic. If a stochastic is a sequence, the variance mus... | [
"def",
"cov_from_scales",
"(",
"self",
",",
"scales",
")",
":",
"# Get array of scales",
"ord_sc",
"=",
"[",
"]",
"for",
"stochastic",
"in",
"self",
".",
"stochastics",
":",
"ord_sc",
".",
"append",
"(",
"np",
".",
"ravel",
"(",
"scales",
"[",
"stochastic"... | Return a covariance matrix built from a dictionary of scales.
`scales` is a dictionary keyed by stochastic instances, and the
values refer are the variance of the jump distribution for each
stochastic. If a stochastic is a sequence, the variance must
have the same length. | [
"Return",
"a",
"covariance",
"matrix",
"built",
"from",
"a",
"dictionary",
"of",
"scales",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1153-L1173 | train |
pymc-devs/pymc | pymc/StepMethods.py | AdaptiveMetropolis.cov_from_trace | def cov_from_trace(self, trace=slice(None)):
"""Define the jump distribution covariance matrix from the object's
stored trace.
:Parameters:
- `trace` : slice or int
A slice for the stochastic object's trace in the last chain, or a
an integer indicating the how many o... | python | def cov_from_trace(self, trace=slice(None)):
"""Define the jump distribution covariance matrix from the object's
stored trace.
:Parameters:
- `trace` : slice or int
A slice for the stochastic object's trace in the last chain, or a
an integer indicating the how many o... | [
"def",
"cov_from_trace",
"(",
"self",
",",
"trace",
"=",
"slice",
"(",
"None",
")",
")",
":",
"n",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"stochastics",
":",
"n",
".",
"append",
"(",
"s",
".",
"trace",
".",
"length",
"(",
")",
")",
"n",
... | Define the jump distribution covariance matrix from the object's
stored trace.
:Parameters:
- `trace` : slice or int
A slice for the stochastic object's trace in the last chain, or a
an integer indicating the how many of the last samples will be used. | [
"Define",
"the",
"jump",
"distribution",
"covariance",
"matrix",
"from",
"the",
"object",
"s",
"stored",
"trace",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1175-L1202 | train |
pymc-devs/pymc | pymc/StepMethods.py | AdaptiveMetropolis.check_type | def check_type(self):
"""Make sure each stochastic has a correct type, and identify discrete stochastics."""
self.isdiscrete = {}
for stochastic in self.stochastics:
if stochastic.dtype in integer_dtypes:
self.isdiscrete[stochastic] = True
elif stochastic.... | python | def check_type(self):
"""Make sure each stochastic has a correct type, and identify discrete stochastics."""
self.isdiscrete = {}
for stochastic in self.stochastics:
if stochastic.dtype in integer_dtypes:
self.isdiscrete[stochastic] = True
elif stochastic.... | [
"def",
"check_type",
"(",
"self",
")",
":",
"self",
".",
"isdiscrete",
"=",
"{",
"}",
"for",
"stochastic",
"in",
"self",
".",
"stochastics",
":",
"if",
"stochastic",
".",
"dtype",
"in",
"integer_dtypes",
":",
"self",
".",
"isdiscrete",
"[",
"stochastic",
... | Make sure each stochastic has a correct type, and identify discrete stochastics. | [
"Make",
"sure",
"each",
"stochastic",
"has",
"a",
"correct",
"type",
"and",
"identify",
"discrete",
"stochastics",
"."
] | c6e530210bff4c0d7189b35b2c971bc53f93f7cd | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1204-L1214 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.