repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
HazyResearch/metal
metal/tuners/hyperband_tuner.py
HyperbandTuner.get_largest_schedule_within_budget
def get_largest_schedule_within_budget(self, budget, proportion_discard): """ Gets the largest hyperband schedule within target_budget. This is required since the original hyperband algorithm uses R, the maximum number of resources per configuration. TODO(maxlam): Possibly binary...
python
def get_largest_schedule_within_budget(self, budget, proportion_discard): """ Gets the largest hyperband schedule within target_budget. This is required since the original hyperband algorithm uses R, the maximum number of resources per configuration. TODO(maxlam): Possibly binary...
[ "def", "get_largest_schedule_within_budget", "(", "self", ",", "budget", ",", "proportion_discard", ")", ":", "# Exhaustively generate schedules and check if", "# they're within budget, adding to a list.", "valid_schedules_and_costs", "=", "[", "]", "for", "R", "in", "range", ...
Gets the largest hyperband schedule within target_budget. This is required since the original hyperband algorithm uses R, the maximum number of resources per configuration. TODO(maxlam): Possibly binary search it if this becomes a bottleneck. Args: budget: total budget of th...
[ "Gets", "the", "largest", "hyperband", "schedule", "within", "target_budget", ".", "This", "is", "required", "since", "the", "original", "hyperband", "algorithm", "uses", "R", "the", "maximum", "number", "of", "resources", "per", "configuration", ".", "TODO", "(...
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/hyperband_tuner.py#L96-L120
train
Returns the largest hyperband schedule within target budget.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/hyperband_tuner.py
HyperbandTuner.generate_hyperband_schedule
def generate_hyperband_schedule(self, R, eta): """ Generate hyperband schedule according to the paper. Args: R: maximum resources per config. eta: proportion of configruations to discard per iteration of successive halving. Returns: hyperband sch...
python
def generate_hyperband_schedule(self, R, eta): """ Generate hyperband schedule according to the paper. Args: R: maximum resources per config. eta: proportion of configruations to discard per iteration of successive halving. Returns: hyperband sch...
[ "def", "generate_hyperband_schedule", "(", "self", ",", "R", ",", "eta", ")", ":", "schedule", "=", "[", "]", "s_max", "=", "int", "(", "math", ".", "floor", "(", "math", ".", "log", "(", "R", ",", "eta", ")", ")", ")", "# B = (s_max + 1) * R", "for"...
Generate hyperband schedule according to the paper. Args: R: maximum resources per config. eta: proportion of configruations to discard per iteration of successive halving. Returns: hyperband schedule, which is represented as a list of brackets, wher...
[ "Generate", "hyperband", "schedule", "according", "to", "the", "paper", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/hyperband_tuner.py#L127-L154
train
Generate hyperband schedule according to the paper.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/hyperband_tuner.py
HyperbandTuner.search
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, seed=None, **score_kwar...
python
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, seed=None, **score_kwar...
[ "def", "search", "(", "self", ",", "search_space", ",", "valid_data", ",", "init_args", "=", "[", "]", ",", "train_args", "=", "[", "]", ",", "init_kwargs", "=", "{", "}", ",", "train_kwargs", "=", "{", "}", ",", "module_args", "=", "{", "}", ",", ...
Performs hyperband search according to the generated schedule. At the beginning of each bracket, we generate a list of random configurations and perform successive halving on it; we repeat this process for the number of brackets in the schedule. Args: init_args: (li...
[ "Performs", "hyperband", "search", "according", "to", "the", "generated", "schedule", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/hyperband_tuner.py#L156-L267
train
This function searches the modelTuner for the given set of models in the given set of models.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/contrib/info_extraction/utils.py
mark_entities
def mark_entities(tokens, positions, markers=[], style="insert"): """Adds special markers around tokens at specific positions (e.g., entities) Args: tokens: A list of tokens (the sentence) positions: 1) A list of inclusive ranges (tuples) corresponding to the token range...
python
def mark_entities(tokens, positions, markers=[], style="insert"): """Adds special markers around tokens at specific positions (e.g., entities) Args: tokens: A list of tokens (the sentence) positions: 1) A list of inclusive ranges (tuples) corresponding to the token range...
[ "def", "mark_entities", "(", "tokens", ",", "positions", ",", "markers", "=", "[", "]", ",", "style", "=", "\"insert\"", ")", ":", "if", "markers", "and", "len", "(", "markers", ")", "!=", "2", "*", "len", "(", "positions", ")", ":", "msg", "=", "(...
Adds special markers around tokens at specific positions (e.g., entities) Args: tokens: A list of tokens (the sentence) positions: 1) A list of inclusive ranges (tuples) corresponding to the token ranges of the entities in order. (Assumes each entity has only one...
[ "Adds", "special", "markers", "around", "tokens", "at", "specific", "positions", "(", "e", ".", "g", ".", "entities", ")" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/contrib/info_extraction/utils.py#L1-L76
train
Mark the entities at specific positions in the given list of tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/tuner.py
ModelTuner._clear_state
def _clear_state(self, seed=None): """Clears the state, starts clock""" self.start_time = time() self.run_stats = [] self.best_index = -1 self.best_score = -1 self.best_config = None # Note: These must be set at the start of self.search() self.search_spac...
python
def _clear_state(self, seed=None): """Clears the state, starts clock""" self.start_time = time() self.run_stats = [] self.best_index = -1 self.best_score = -1 self.best_config = None # Note: These must be set at the start of self.search() self.search_spac...
[ "def", "_clear_state", "(", "self", ",", "seed", "=", "None", ")", ":", "self", ".", "start_time", "=", "time", "(", ")", "self", ".", "run_stats", "=", "[", "]", "self", ".", "best_index", "=", "-", "1", "self", ".", "best_score", "=", "-", "1", ...
Clears the state, starts clock
[ "Clears", "the", "state", "starts", "clock" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/tuner.py#L78-L91
train
Clears the state of the current object
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/tuner.py
ModelTuner.run_stats_df
def run_stats_df(self): """Returns self.run_stats over search params as pandas dataframe.""" run_stats_df = [] for x in self.run_stats: search_results = {**x["search_params"]} search_results["score"] = x["score"] run_stats_df.append(search_results) re...
python
def run_stats_df(self): """Returns self.run_stats over search params as pandas dataframe.""" run_stats_df = [] for x in self.run_stats: search_results = {**x["search_params"]} search_results["score"] = x["score"] run_stats_df.append(search_results) re...
[ "def", "run_stats_df", "(", "self", ")", ":", "run_stats_df", "=", "[", "]", "for", "x", "in", "self", ".", "run_stats", ":", "search_results", "=", "{", "*", "*", "x", "[", "\"search_params\"", "]", "}", "search_results", "[", "\"score\"", "]", "=", "...
Returns self.run_stats over search params as pandas dataframe.
[ "Returns", "self", ".", "run_stats", "over", "search", "params", "as", "pandas", "dataframe", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/tuner.py#L209-L217
train
Returns self. run_stats over search params as pandas dataframe.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/tuner.py
ModelTuner.search
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, **score_kwargs, ): ...
python
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, **score_kwargs, ): ...
[ "def", "search", "(", "self", ",", "search_space", ",", "valid_data", ",", "init_args", "=", "[", "]", ",", "train_args", "=", "[", "]", ",", "init_kwargs", "=", "{", "}", ",", "train_kwargs", "=", "{", "}", ",", "module_args", "=", "{", "}", ",", ...
Args: search_space: see config_generator() documentation valid_data: a tuple of Tensors (X,Y), a Dataset, or a DataLoader of X (data) and Y (labels) for the dev split init_args: (list) positional args for initializing the model train_args: (list) positiona...
[ "Args", ":", "search_space", ":", "see", "config_generator", "()", "documentation", "valid_data", ":", "a", "tuple", "of", "Tensors", "(", "X", "Y", ")", "a", "Dataset", "or", "a", "DataLoader", "of", "X", "(", "data", ")", "and", "Y", "(", "labels", "...
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/tuner.py#L219-L255
train
Search the modelTuner for the given set of modules in the given search space.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/tuner.py
ModelTuner.config_generator
def config_generator(search_space, max_search, rng, shuffle=True): """Generates config dicts from the given search space Args: search_space: (dict) A dictionary of parameters to search over. See note below for more details. max_search: (int) The maximum number of...
python
def config_generator(search_space, max_search, rng, shuffle=True): """Generates config dicts from the given search space Args: search_space: (dict) A dictionary of parameters to search over. See note below for more details. max_search: (int) The maximum number of...
[ "def", "config_generator", "(", "search_space", ",", "max_search", ",", "rng", ",", "shuffle", "=", "True", ")", ":", "def", "dict_product", "(", "d", ")", ":", "keys", "=", "d", ".", "keys", "(", ")", "for", "element", "in", "product", "(", "*", "d"...
Generates config dicts from the given search space Args: search_space: (dict) A dictionary of parameters to search over. See note below for more details. max_search: (int) The maximum number of configurations to search. If max_search is None, do a full gr...
[ "Generates", "config", "dicts", "from", "the", "given", "search", "space" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/tuner.py#L258-L351
train
Generates a list of config dicts for the given search space and max_search parameters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/label_model/utils.py
compute_mu
def compute_mu(L_aug, Y, k, p): """Given label matrix L_aug and labels Y, compute the true mu params. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The class...
python
def compute_mu(L_aug, Y, k, p): """Given label matrix L_aug and labels Y, compute the true mu params. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The class...
[ "def", "compute_mu", "(", "L_aug", ",", "Y", ",", "k", ",", "p", ")", ":", "n", ",", "d", "=", "L_aug", ".", "shape", "assert", "Y", ".", "shape", "[", "0", "]", "==", "n", "# Compute mu", "mu", "=", "np", ".", "zeros", "(", "(", "d", ",", ...
Given label matrix L_aug and labels Y, compute the true mu params. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The class balance
[ "Given", "label", "matrix", "L_aug", "and", "labels", "Y", "compute", "the", "true", "mu", "params", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/label_model/utils.py#L4-L21
train
Given label matrix L_aug and labels Y compute the true mu params.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/label_model/utils.py
compute_covariance
def compute_covariance(L_aug, Y, k, p): """Given label matrix L_aug and labels Y, compute the covariance. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The c...
python
def compute_covariance(L_aug, Y, k, p): """Given label matrix L_aug and labels Y, compute the covariance. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The c...
[ "def", "compute_covariance", "(", "L_aug", ",", "Y", ",", "k", ",", "p", ")", ":", "n", ",", "d", "=", "L_aug", ".", "shape", "assert", "Y", ".", "shape", "[", "0", "]", "==", "n", "mu", "=", "compute_mu", "(", "L_aug", ",", "Y", ",", "k", ",...
Given label matrix L_aug and labels Y, compute the covariance. Args: L: (np.array {0,1}) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} k: (int) Cardinality p: (np.array float) [k] The class balance
[ "Given", "label", "matrix", "L_aug", "and", "labels", "Y", "compute", "the", "covariance", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/label_model/utils.py#L24-L36
train
Given label matrix L_aug and labels Y compute the covariance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/label_model/utils.py
compute_inv_covariance
def compute_inv_covariance(L_aug, Y, k, p): """Given label matrix L and labels Y, compute the covariance. Args: L: (np.array) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} """ return np.linalg.inv(compute_covariance(L_aug, Y, k, p))
python
def compute_inv_covariance(L_aug, Y, k, p): """Given label matrix L and labels Y, compute the covariance. Args: L: (np.array) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k} """ return np.linalg.inv(compute_covariance(L_aug, Y, k, p))
[ "def", "compute_inv_covariance", "(", "L_aug", ",", "Y", ",", "k", ",", "p", ")", ":", "return", "np", ".", "linalg", ".", "inv", "(", "compute_covariance", "(", "L_aug", ",", "Y", ",", "k", ",", "p", ")", ")" ]
Given label matrix L and labels Y, compute the covariance. Args: L: (np.array) [n, d] The augmented (indicator) label matrix Y: (np.array int) [n] The true labels in {1,...,k}
[ "Given", "label", "matrix", "L", "and", "labels", "Y", "compute", "the", "covariance", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/label_model/utils.py#L39-L46
train
Given label matrix L and labels Y compute the covariance matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/label_model/utils.py
print_matrix
def print_matrix(X, decimals=1): """Pretty printing for numpy matrix X""" for row in np.round(X, decimals=decimals): print(row)
python
def print_matrix(X, decimals=1): """Pretty printing for numpy matrix X""" for row in np.round(X, decimals=decimals): print(row)
[ "def", "print_matrix", "(", "X", ",", "decimals", "=", "1", ")", ":", "for", "row", "in", "np", ".", "round", "(", "X", ",", "decimals", "=", "decimals", ")", ":", "print", "(", "row", ")" ]
Pretty printing for numpy matrix X
[ "Pretty", "printing", "for", "numpy", "matrix", "X" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/label_model/utils.py#L49-L52
train
Pretty printing for numpy matrix X
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
_conflicted_data_points
def _conflicted_data_points(L): """Returns an indicator vector where ith element = 1 if x_i is labeled by at least two LFs that give it disagreeing labels.""" m = sparse.diags(np.ravel(L.max(axis=1).todense())) return np.ravel(np.max(m @ (L != 0) != L, axis=1).astype(int).todense())
python
def _conflicted_data_points(L): """Returns an indicator vector where ith element = 1 if x_i is labeled by at least two LFs that give it disagreeing labels.""" m = sparse.diags(np.ravel(L.max(axis=1).todense())) return np.ravel(np.max(m @ (L != 0) != L, axis=1).astype(int).todense())
[ "def", "_conflicted_data_points", "(", "L", ")", ":", "m", "=", "sparse", ".", "diags", "(", "np", ".", "ravel", "(", "L", ".", "max", "(", "axis", "=", "1", ")", ".", "todense", "(", ")", ")", ")", "return", "np", ".", "ravel", "(", "np", ".",...
Returns an indicator vector where ith element = 1 if x_i is labeled by at least two LFs that give it disagreeing labels.
[ "Returns", "an", "indicator", "vector", "where", "ith", "element", "=", "1", "if", "x_i", "is", "labeled", "by", "at", "least", "two", "LFs", "that", "give", "it", "disagreeing", "labels", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L25-L29
train
Returns an indicator vector where ith element = 1 if x_i is labeled by at least two LFs that give it disagreeing labels.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
lf_polarities
def lf_polarities(L): """Return the polarities of each LF based on evidence in a label matrix. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate """ polarities = [sorted(list(set(L[:, i].data))) for i in range(L.shape[1])] ...
python
def lf_polarities(L): """Return the polarities of each LF based on evidence in a label matrix. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate """ polarities = [sorted(list(set(L[:, i].data))) for i in range(L.shape[1])] ...
[ "def", "lf_polarities", "(", "L", ")", ":", "polarities", "=", "[", "sorted", "(", "list", "(", "set", "(", "L", "[", ":", ",", "i", "]", ".", "data", ")", ")", ")", "for", "i", "in", "range", "(", "L", ".", "shape", "[", "1", "]", ")", "]"...
Return the polarities of each LF based on evidence in a label matrix. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate
[ "Return", "the", "polarities", "of", "each", "LF", "based", "on", "evidence", "in", "a", "label", "matrix", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L60-L68
train
Return the polarities of each LF based on evidence in a label matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
lf_overlaps
def lf_overlaps(L, normalize_by_coverage=False): """Return the **fraction of items each LF labels that are also labeled by at least one other LF.** Note that the maximum possible overlap fraction for an LF is the LF's coverage, unless `normalize_by_coverage=True`, in which case it is 1. Args: ...
python
def lf_overlaps(L, normalize_by_coverage=False): """Return the **fraction of items each LF labels that are also labeled by at least one other LF.** Note that the maximum possible overlap fraction for an LF is the LF's coverage, unless `normalize_by_coverage=True`, in which case it is 1. Args: ...
[ "def", "lf_overlaps", "(", "L", ",", "normalize_by_coverage", "=", "False", ")", ":", "overlaps", "=", "(", "L", "!=", "0", ")", ".", "T", "@", "_overlapped_data_points", "(", "L", ")", "/", "L", ".", "shape", "[", "0", "]", "if", "normalize_by_coverag...
Return the **fraction of items each LF labels that are also labeled by at least one other LF.** Note that the maximum possible overlap fraction for an LF is the LF's coverage, unless `normalize_by_coverage=True`, in which case it is 1. Args: L: an n x m scipy.sparse matrix where L_{i,j} is th...
[ "Return", "the", "**", "fraction", "of", "items", "each", "LF", "labels", "that", "are", "also", "labeled", "by", "at", "least", "one", "other", "LF", ".", "**" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L80-L96
train
Returns the fraction of items each LF label is also labeled by at least one other LF.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
lf_conflicts
def lf_conflicts(L, normalize_by_overlaps=False): """Return the **fraction of items each LF labels that are also given a different (non-abstain) label by at least one other LF.** Note that the maximum possible conflict fraction for an LF is the LF's overlaps fraction, unless `normalize_by_overlaps=...
python
def lf_conflicts(L, normalize_by_overlaps=False): """Return the **fraction of items each LF labels that are also given a different (non-abstain) label by at least one other LF.** Note that the maximum possible conflict fraction for an LF is the LF's overlaps fraction, unless `normalize_by_overlaps=...
[ "def", "lf_conflicts", "(", "L", ",", "normalize_by_overlaps", "=", "False", ")", ":", "conflicts", "=", "(", "L", "!=", "0", ")", ".", "T", "@", "_conflicted_data_points", "(", "L", ")", "/", "L", ".", "shape", "[", "0", "]", "if", "normalize_by_overl...
Return the **fraction of items each LF labels that are also given a different (non-abstain) label by at least one other LF.** Note that the maximum possible conflict fraction for an LF is the LF's overlaps fraction, unless `normalize_by_overlaps=True`, in which case it is 1. Args: ...
[ "Return", "the", "**", "fraction", "of", "items", "each", "LF", "labels", "that", "are", "also", "given", "a", "different", "(", "non", "-", "abstain", ")", "label", "by", "at", "least", "one", "other", "LF", ".", "**" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L99-L116
train
Returns the fraction of items each LF label is also given by at least one other LF.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
lf_empirical_accuracies
def lf_empirical_accuracies(L, Y): """Return the **empirical accuracy** against a set of labels Y (e.g. dev set) for each LF. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels ...
python
def lf_empirical_accuracies(L, Y): """Return the **empirical accuracy** against a set of labels Y (e.g. dev set) for each LF. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels ...
[ "def", "lf_empirical_accuracies", "(", "L", ",", "Y", ")", ":", "# Assume labeled set is small, work with dense matrices", "Y", "=", "arraylike_to_numpy", "(", "Y", ")", "L", "=", "L", ".", "toarray", "(", ")", "X", "=", "np", ".", "where", "(", "L", "==", ...
Return the **empirical accuracy** against a set of labels Y (e.g. dev set) for each LF. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels
[ "Return", "the", "**", "empirical", "accuracy", "**", "against", "a", "set", "of", "labels", "Y", "(", "e", ".", "g", ".", "dev", "set", ")", "for", "each", "LF", ".", "Args", ":", "L", ":", "an", "n", "x", "m", "scipy", ".", "sparse", "matrix", ...
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L119-L131
train
Return the empirical accuracy against a set of labels Y
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
lf_summary
def lf_summary(L, Y=None, lf_names=None, est_accs=None): """Returns a pandas DataFrame with the various per-LF statistics. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels. ...
python
def lf_summary(L, Y=None, lf_names=None, est_accs=None): """Returns a pandas DataFrame with the various per-LF statistics. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels. ...
[ "def", "lf_summary", "(", "L", ",", "Y", "=", "None", ",", "lf_names", "=", "None", ",", "est_accs", "=", "None", ")", ":", "n", ",", "m", "=", "L", ".", "shape", "if", "lf_names", "is", "not", "None", ":", "col_names", "=", "[", "\"j\"", "]", ...
Returns a pandas DataFrame with the various per-LF statistics. Args: L: an n x m scipy.sparse matrix where L_{i,j} is the label given by the jth LF to the ith candidate Y: an [n] or [n, 1] np.ndarray of gold labels. If provided, the empirical accuracy for each LF will be cal...
[ "Returns", "a", "pandas", "DataFrame", "with", "the", "various", "per", "-", "LF", "statistics", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L134-L177
train
Returns a pandas DataFrame with the various per - LF statistics.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
single_lf_summary
def single_lf_summary(Y_p, Y=None): """Calculates coverage, overlap, conflicts, and accuracy for a single LF Args: Y_p: a np.array or torch.Tensor of predicted labels Y: a np.array or torch.Tensor of true labels (if known) """ L = sparse.csr_matrix(arraylike_to_numpy(Y_p).reshape(-1, 1)...
python
def single_lf_summary(Y_p, Y=None): """Calculates coverage, overlap, conflicts, and accuracy for a single LF Args: Y_p: a np.array or torch.Tensor of predicted labels Y: a np.array or torch.Tensor of true labels (if known) """ L = sparse.csr_matrix(arraylike_to_numpy(Y_p).reshape(-1, 1)...
[ "def", "single_lf_summary", "(", "Y_p", ",", "Y", "=", "None", ")", ":", "L", "=", "sparse", ".", "csr_matrix", "(", "arraylike_to_numpy", "(", "Y_p", ")", ".", "reshape", "(", "-", "1", ",", "1", ")", ")", "return", "lf_summary", "(", "L", ",", "Y...
Calculates coverage, overlap, conflicts, and accuracy for a single LF Args: Y_p: a np.array or torch.Tensor of predicted labels Y: a np.array or torch.Tensor of true labels (if known)
[ "Calculates", "coverage", "overlap", "conflicts", "and", "accuracy", "for", "a", "single", "LF" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L180-L188
train
Calculates coverage overlap conflicts and accuracy for a single LF
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
error_buckets
def error_buckets(gold, pred, X=None): """Group items by error buckets Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) X: an iterable of items Returns: buckets: A dict of items where buckets[i,j] is a list of items with p...
python
def error_buckets(gold, pred, X=None): """Group items by error buckets Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) X: an iterable of items Returns: buckets: A dict of items where buckets[i,j] is a list of items with p...
[ "def", "error_buckets", "(", "gold", ",", "pred", ",", "X", "=", "None", ")", ":", "buckets", "=", "defaultdict", "(", "list", ")", "gold", "=", "arraylike_to_numpy", "(", "gold", ")", "pred", "=", "arraylike_to_numpy", "(", "pred", ")", "for", "i", ",...
Group items by error buckets Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) X: an iterable of items Returns: buckets: A dict of items where buckets[i,j] is a list of items with predicted label i and true label j. If X is Non...
[ "Group", "items", "by", "error", "buckets" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L191-L214
train
Group items by error buckets.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
confusion_matrix
def confusion_matrix( gold, pred, null_pred=False, null_gold=False, normalize=False, pretty_print=True ): """A shortcut method for building a confusion matrix all at once. Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) null_pred: If True, i...
python
def confusion_matrix( gold, pred, null_pred=False, null_gold=False, normalize=False, pretty_print=True ): """A shortcut method for building a confusion matrix all at once. Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) null_pred: If True, i...
[ "def", "confusion_matrix", "(", "gold", ",", "pred", ",", "null_pred", "=", "False", ",", "null_gold", "=", "False", ",", "normalize", "=", "False", ",", "pretty_print", "=", "True", ")", ":", "conf", "=", "ConfusionMatrix", "(", "null_pred", "=", "null_pr...
A shortcut method for building a confusion matrix all at once. Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) null_pred: If True, include the row corresponding to null predictions null_gold: If True, include the col corresponding to null go...
[ "A", "shortcut", "method", "for", "building", "a", "confusion", "matrix", "all", "at", "once", "." ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L217-L242
train
A shortcut method for building a confusion matrix all at once.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/analysis.py
ConfusionMatrix.add
def add(self, gold, pred): """ Args: gold: a np.ndarray of gold labels (ints) pred: a np.ndarray of predictions (ints) """ self.counter.update(zip(gold, pred))
python
def add(self, gold, pred): """ Args: gold: a np.ndarray of gold labels (ints) pred: a np.ndarray of predictions (ints) """ self.counter.update(zip(gold, pred))
[ "def", "add", "(", "self", ",", "gold", ",", "pred", ")", ":", "self", ".", "counter", ".", "update", "(", "zip", "(", "gold", ",", "pred", ")", ")" ]
Args: gold: a np.ndarray of gold labels (ints) pred: a np.ndarray of predictions (ints)
[ "Args", ":", "gold", ":", "a", "np", ".", "ndarray", "of", "gold", "labels", "(", "ints", ")", "pred", ":", "a", "np", ".", "ndarray", "of", "predictions", "(", "ints", ")" ]
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L271-L277
train
Adds gold and pred to the set of known classes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
HazyResearch/metal
metal/tuners/random_tuner.py
RandomSearchTuner.search
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, clean_up=True, seed=Non...
python
def search( self, search_space, valid_data, init_args=[], train_args=[], init_kwargs={}, train_kwargs={}, module_args={}, module_kwargs={}, max_search=None, shuffle=True, verbose=True, clean_up=True, seed=Non...
[ "def", "search", "(", "self", ",", "search_space", ",", "valid_data", ",", "init_args", "=", "[", "]", ",", "train_args", "=", "[", "]", ",", "init_kwargs", "=", "{", "}", ",", "train_kwargs", "=", "{", "}", ",", "module_args", "=", "{", "}", ",", ...
Args: search_space: see config_generator() documentation valid_data: a tuple of Tensors (X,Y), a Dataset, or a DataLoader of X (data) and Y (labels) for the dev split init_args: (list) positional args for initializing the model train_args: (list) positiona...
[ "Args", ":", "search_space", ":", "see", "config_generator", "()", "documentation", "valid_data", ":", "a", "tuple", "of", "Tensors", "(", "X", "Y", ")", "a", "Dataset", "or", "a", "DataLoader", "of", "X", "(", "data", ")", "and", "Y", "(", "labels", "...
c24e3772e25ac6d0917b8b7af4c1bcb92928f84a
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/tuners/random_tuner.py#L14-L86
train
Search the model for the given set of modules.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
config
def config(data_folder=settings.data_folder, logs_folder=settings.logs_folder, imgs_folder=settings.imgs_folder, cache_folder=settings.cache_folder, use_cache=settings.use_cache, log_file=settings.log_file, log_console=settings.log_console, lo...
python
def config(data_folder=settings.data_folder, logs_folder=settings.logs_folder, imgs_folder=settings.imgs_folder, cache_folder=settings.cache_folder, use_cache=settings.use_cache, log_file=settings.log_file, log_console=settings.log_console, lo...
[ "def", "config", "(", "data_folder", "=", "settings", ".", "data_folder", ",", "logs_folder", "=", "settings", ".", "logs_folder", ",", "imgs_folder", "=", "settings", ".", "imgs_folder", ",", "cache_folder", "=", "settings", ".", "cache_folder", ",", "use_cache...
Configure osmnx by setting the default global vars to desired values. Parameters --------- data_folder : string where to save and load data files logs_folder : string where to write the log files imgs_folder : string where to save figures cache_folder : string wh...
[ "Configure", "osmnx", "by", "setting", "the", "default", "global", "vars", "to", "desired", "values", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L45-L139
train
Configure osmnx by setting the default global vars to desired values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
log
def log(message, level=None, name=None, filename=None): """ Write a message to the log file and/or print to the the console. Parameters ---------- message : string the content of the message to log level : int one of the logger.level constants name : string name of t...
python
def log(message, level=None, name=None, filename=None): """ Write a message to the log file and/or print to the the console. Parameters ---------- message : string the content of the message to log level : int one of the logger.level constants name : string name of t...
[ "def", "log", "(", "message", ",", "level", "=", "None", ",", "name", "=", "None", ",", "filename", "=", "None", ")", ":", "if", "level", "is", "None", ":", "level", "=", "settings", ".", "log_level", "if", "name", "is", "None", ":", "name", "=", ...
Write a message to the log file and/or print to the the console. Parameters ---------- message : string the content of the message to log level : int one of the logger.level constants name : string name of the logger filename : string name of the log file Re...
[ "Write", "a", "message", "to", "the", "log", "file", "and", "/", "or", "print", "to", "the", "the", "console", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L142-L196
train
Write a message to the log file and or to the console.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_logger
def get_logger(level=None, name=None, filename=None): """ Create a logger or return the current one if already instantiated. Parameters ---------- level : int one of the logger.level constants name : string name of the logger filename : string name of the log file ...
python
def get_logger(level=None, name=None, filename=None): """ Create a logger or return the current one if already instantiated. Parameters ---------- level : int one of the logger.level constants name : string name of the logger filename : string name of the log file ...
[ "def", "get_logger", "(", "level", "=", "None", ",", "name", "=", "None", ",", "filename", "=", "None", ")", ":", "if", "level", "is", "None", ":", "level", "=", "settings", ".", "log_level", "if", "name", "is", "None", ":", "name", "=", "settings", ...
Create a logger or return the current one if already instantiated. Parameters ---------- level : int one of the logger.level constants name : string name of the logger filename : string name of the log file Returns ------- logger.logger
[ "Create", "a", "logger", "or", "return", "the", "current", "one", "if", "already", "instantiated", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L200-L246
train
Create a logger or return the current one if already instantiated.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
induce_subgraph
def induce_subgraph(G, node_subset): """ Induce a subgraph of G. Parameters ---------- G : networkx multidigraph node_subset : list-like the subset of nodes to induce a subgraph of G Returns ------- G2 : networkx multidigraph the subgraph of G induced by node_subset...
python
def induce_subgraph(G, node_subset): """ Induce a subgraph of G. Parameters ---------- G : networkx multidigraph node_subset : list-like the subset of nodes to induce a subgraph of G Returns ------- G2 : networkx multidigraph the subgraph of G induced by node_subset...
[ "def", "induce_subgraph", "(", "G", ",", "node_subset", ")", ":", "node_subset", "=", "set", "(", "node_subset", ")", "# copy nodes into new graph", "G2", "=", "G", ".", "__class__", "(", ")", "G2", ".", "add_nodes_from", "(", "(", "n", ",", "G", ".", "n...
Induce a subgraph of G. Parameters ---------- G : networkx multidigraph node_subset : list-like the subset of nodes to induce a subgraph of G Returns ------- G2 : networkx multidigraph the subgraph of G induced by node_subset
[ "Induce", "a", "subgraph", "of", "G", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L272-L307
train
Induce a subgraph of G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_largest_component
def get_largest_component(G, strongly=False): """ Return a subgraph of the largest weakly or strongly connected component from a directed graph. Parameters ---------- G : networkx multidigraph strongly : bool if True, return the largest strongly instead of weakly connected c...
python
def get_largest_component(G, strongly=False): """ Return a subgraph of the largest weakly or strongly connected component from a directed graph. Parameters ---------- G : networkx multidigraph strongly : bool if True, return the largest strongly instead of weakly connected c...
[ "def", "get_largest_component", "(", "G", ",", "strongly", "=", "False", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "original_len", "=", "len", "(", "list", "(", "G", ".", "nodes", "(", ")", ")", ")", "if", "strongly", ":", "# if the...
Return a subgraph of the largest weakly or strongly connected component from a directed graph. Parameters ---------- G : networkx multidigraph strongly : bool if True, return the largest strongly instead of weakly connected component Returns ------- G : networkx multidi...
[ "Return", "a", "subgraph", "of", "the", "largest", "weakly", "or", "strongly", "connected", "component", "from", "a", "directed", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L311-L357
train
Returns a subgraph of the largest weakly or strongly connected component from a directed graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
great_circle_vec
def great_circle_vec(lat1, lng1, lat2, lng2, earth_radius=6371009): """ Vectorized function to calculate the great-circle distance between two points or between vectors of points, using haversine. Parameters ---------- lat1 : float or array of float lng1 : float or array of float lat2 :...
python
def great_circle_vec(lat1, lng1, lat2, lng2, earth_radius=6371009): """ Vectorized function to calculate the great-circle distance between two points or between vectors of points, using haversine. Parameters ---------- lat1 : float or array of float lng1 : float or array of float lat2 :...
[ "def", "great_circle_vec", "(", "lat1", ",", "lng1", ",", "lat2", ",", "lng2", ",", "earth_radius", "=", "6371009", ")", ":", "phi1", "=", "np", ".", "deg2rad", "(", "lat1", ")", "phi2", "=", "np", ".", "deg2rad", "(", "lat2", ")", "d_phi", "=", "p...
Vectorized function to calculate the great-circle distance between two points or between vectors of points, using haversine. Parameters ---------- lat1 : float or array of float lng1 : float or array of float lat2 : float or array of float lng2 : float or array of float earth_radius : n...
[ "Vectorized", "function", "to", "calculate", "the", "great", "-", "circle", "distance", "between", "two", "points", "or", "between", "vectors", "of", "points", "using", "haversine", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L361-L398
train
Vectorized function to calculate the great circle distance between two points or between vectors of points using haversine.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
euclidean_dist_vec
def euclidean_dist_vec(y1, x1, y2, x2): """ Vectorized function to calculate the euclidean distance between two points or between vectors of points. Parameters ---------- y1 : float or array of float x1 : float or array of float y2 : float or array of float x2 : float or array of fl...
python
def euclidean_dist_vec(y1, x1, y2, x2): """ Vectorized function to calculate the euclidean distance between two points or between vectors of points. Parameters ---------- y1 : float or array of float x1 : float or array of float y2 : float or array of float x2 : float or array of fl...
[ "def", "euclidean_dist_vec", "(", "y1", ",", "x1", ",", "y2", ",", "x2", ")", ":", "# euclid's formula", "distance", "=", "(", "(", "x1", "-", "x2", ")", "**", "2", "+", "(", "y1", "-", "y2", ")", "**", "2", ")", "**", "0.5", "return", "distance"...
Vectorized function to calculate the euclidean distance between two points or between vectors of points. Parameters ---------- y1 : float or array of float x1 : float or array of float y2 : float or array of float x2 : float or array of float Returns ------- distance : float or...
[ "Vectorized", "function", "to", "calculate", "the", "euclidean", "distance", "between", "two", "points", "or", "between", "vectors", "of", "points", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L402-L422
train
Vectorized function to calculate the euclidean distance between two points y1 and x2.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_nearest_node
def get_nearest_node(G, point, method='haversine', return_dist=False): """ Return the graph node nearest to some specified (lat, lng) or (y, x) point, and optionally the distance between the node and the point. This function can use either a haversine or euclidean distance calculator. Parameters ...
python
def get_nearest_node(G, point, method='haversine', return_dist=False): """ Return the graph node nearest to some specified (lat, lng) or (y, x) point, and optionally the distance between the node and the point. This function can use either a haversine or euclidean distance calculator. Parameters ...
[ "def", "get_nearest_node", "(", "G", ",", "point", ",", "method", "=", "'haversine'", ",", "return_dist", "=", "False", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "if", "not", "G", "or", "(", "G", ".", "number_of_nodes", "(", ")", "=...
Return the graph node nearest to some specified (lat, lng) or (y, x) point, and optionally the distance between the node and the point. This function can use either a haversine or euclidean distance calculator. Parameters ---------- G : networkx multidigraph point : tuple The (lat, lng)...
[ "Return", "the", "graph", "node", "nearest", "to", "some", "specified", "(", "lat", "lng", ")", "or", "(", "y", "x", ")", "point", "and", "optionally", "the", "distance", "between", "the", "node", "and", "the", "point", ".", "This", "function", "can", ...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L426-L498
train
Returns the nearest node in a networkx multidigraph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_nearest_edge
def get_nearest_edge(G, point): """ Return the nearest edge to a pair of coordinates. Pass in a graph and a tuple with the coordinates. We first get all the edges in the graph. Secondly we compute the euclidean distance from the coordinates to the segments determined by each edge. The last step is t...
python
def get_nearest_edge(G, point): """ Return the nearest edge to a pair of coordinates. Pass in a graph and a tuple with the coordinates. We first get all the edges in the graph. Secondly we compute the euclidean distance from the coordinates to the segments determined by each edge. The last step is t...
[ "def", "get_nearest_edge", "(", "G", ",", "point", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "gdf", "=", "graph_to_gdfs", "(", "G", ",", "nodes", "=", "False", ",", "fill_edge_geometry", "=", "True", ")", "graph_edges", "=", "gdf", "[...
Return the nearest edge to a pair of coordinates. Pass in a graph and a tuple with the coordinates. We first get all the edges in the graph. Secondly we compute the euclidean distance from the coordinates to the segments determined by each edge. The last step is to sort the edge segments in ascending order ...
[ "Return", "the", "nearest", "edge", "to", "a", "pair", "of", "coordinates", ".", "Pass", "in", "a", "graph", "and", "a", "tuple", "with", "the", "coordinates", ".", "We", "first", "get", "all", "the", "edges", "in", "the", "graph", ".", "Secondly", "we...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L501-L544
train
Returns the nearest edge to a pair of coordinates.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_nearest_nodes
def get_nearest_nodes(G, X, Y, method=None): """ Return the graph nodes nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest nodes if working in unprojected coordinat...
python
def get_nearest_nodes(G, X, Y, method=None): """ Return the graph nodes nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest nodes if working in unprojected coordinat...
[ "def", "get_nearest_nodes", "(", "G", ",", "X", ",", "Y", ",", "method", "=", "None", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "if", "method", "is", "None", ":", "# calculate nearest node one at a time for each point", "nn", "=", "[", "g...
Return the graph nodes nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest nodes if working in unprojected coordinates like lat-lng (it precisely finds the nearest node ...
[ "Return", "the", "graph", "nodes", "nearest", "to", "a", "list", "of", "points", ".", "Pass", "in", "points", "as", "separate", "vectors", "of", "X", "and", "Y", "coordinates", ".", "The", "kdtree", "method", "is", "by", "far", "the", "fastest", "with", ...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L547-L628
train
Returns the nearest nodes to a list of points.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_nearest_edges
def get_nearest_edges(G, X, Y, method=None, dist=0.0001): """ Return the graph edges nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest edges if working in unprojec...
python
def get_nearest_edges(G, X, Y, method=None, dist=0.0001): """ Return the graph edges nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest edges if working in unprojec...
[ "def", "get_nearest_edges", "(", "G", ",", "X", ",", "Y", ",", "method", "=", "None", ",", "dist", "=", "0.0001", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "if", "method", "is", "None", ":", "# calculate nearest edge one at a time for eac...
Return the graph edges nearest to a list of points. Pass in points as separate vectors of X and Y coordinates. The 'kdtree' method is by far the fastest with large data sets, but only finds approximate nearest edges if working in unprojected coordinates like lat-lng (it precisely finds the nearest edge ...
[ "Return", "the", "graph", "edges", "nearest", "to", "a", "list", "of", "points", ".", "Pass", "in", "points", "as", "separate", "vectors", "of", "X", "and", "Y", "coordinates", ".", "The", "kdtree", "method", "is", "by", "far", "the", "fastest", "with", ...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L631-L753
train
Returns the nearest edges to a list of points.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
redistribute_vertices
def redistribute_vertices(geom, dist): """ Redistribute the vertices on a projected LineString or MultiLineString. The distance argument is only approximate since the total distance of the linestring may not be a multiple of the preferred distance. This function works on only [Multi]LineString geome...
python
def redistribute_vertices(geom, dist): """ Redistribute the vertices on a projected LineString or MultiLineString. The distance argument is only approximate since the total distance of the linestring may not be a multiple of the preferred distance. This function works on only [Multi]LineString geome...
[ "def", "redistribute_vertices", "(", "geom", ",", "dist", ")", ":", "if", "geom", ".", "geom_type", "==", "'LineString'", ":", "num_vert", "=", "int", "(", "round", "(", "geom", ".", "length", "/", "dist", ")", ")", "if", "num_vert", "==", "0", ":", ...
Redistribute the vertices on a projected LineString or MultiLineString. The distance argument is only approximate since the total distance of the linestring may not be a multiple of the preferred distance. This function works on only [Multi]LineString geometry types. This code is adapted from an answer...
[ "Redistribute", "the", "vertices", "on", "a", "projected", "LineString", "or", "MultiLineString", ".", "The", "distance", "argument", "is", "only", "approximate", "since", "the", "total", "distance", "of", "the", "linestring", "may", "not", "be", "a", "multiple"...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L756-L789
train
Redistribute vertices on a projected LineString or MultiLineString.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_bearing
def get_bearing(origin_point, destination_point): """ Calculate the bearing between two lat-long points. Each tuple should represent (lat, lng) as decimal degrees. Parameters ---------- origin_point : tuple destination_point : tuple Returns ------- bearing : float the c...
python
def get_bearing(origin_point, destination_point): """ Calculate the bearing between two lat-long points. Each tuple should represent (lat, lng) as decimal degrees. Parameters ---------- origin_point : tuple destination_point : tuple Returns ------- bearing : float the c...
[ "def", "get_bearing", "(", "origin_point", ",", "destination_point", ")", ":", "if", "not", "(", "isinstance", "(", "origin_point", ",", "tuple", ")", "and", "isinstance", "(", "destination_point", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "'or...
Calculate the bearing between two lat-long points. Each tuple should represent (lat, lng) as decimal degrees. Parameters ---------- origin_point : tuple destination_point : tuple Returns ------- bearing : float the compass bearing in decimal degrees from the origin point ...
[ "Calculate", "the", "bearing", "between", "two", "lat", "-", "long", "points", ".", "Each", "tuple", "should", "represent", "(", "lat", "lng", ")", "as", "decimal", "degrees", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L792-L826
train
Calculate the bearing between two lat - long points. Each tuple should represent ( lat lng ) as decimal degrees. Each tuple should represent ( lat lng ) as decimal degrees.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
add_edge_bearings
def add_edge_bearings(G): """ Calculate the compass bearing from origin node to destination node for each edge in the directed graph then add each bearing as a new edge attribute. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph """ ...
python
def add_edge_bearings(G): """ Calculate the compass bearing from origin node to destination node for each edge in the directed graph then add each bearing as a new edge attribute. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph """ ...
[ "def", "add_edge_bearings", "(", "G", ")", ":", "for", "u", ",", "v", ",", "data", "in", "G", ".", "edges", "(", "keys", "=", "False", ",", "data", "=", "True", ")", ":", "if", "u", "==", "v", ":", "# a self-loop has an undefined compass bearing", "dat...
Calculate the compass bearing from origin node to destination node for each edge in the directed graph then add each bearing as a new edge attribute. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph
[ "Calculate", "the", "compass", "bearing", "from", "origin", "node", "to", "destination", "node", "for", "each", "edge", "in", "the", "directed", "graph", "then", "add", "each", "bearing", "as", "a", "new", "edge", "attribute", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L830-L859
train
Adds the compass bearing from origin node to destination node for each edge in the directed graph G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
geocode
def geocode(query): """ Geocode a query string to (lat, lon) with the Nominatim geocoder. Parameters ---------- query : string the query string to geocode Returns ------- point : tuple the (lat, lon) coordinates returned by the geocoder """ # send the query to ...
python
def geocode(query): """ Geocode a query string to (lat, lon) with the Nominatim geocoder. Parameters ---------- query : string the query string to geocode Returns ------- point : tuple the (lat, lon) coordinates returned by the geocoder """ # send the query to ...
[ "def", "geocode", "(", "query", ")", ":", "# send the query to the nominatim geocoder and parse the json response", "url_template", "=", "'https://nominatim.openstreetmap.org/search?format=json&limit=1&q={}'", "url", "=", "url_template", ".", "format", "(", "query", ")", "respons...
Geocode a query string to (lat, lon) with the Nominatim geocoder. Parameters ---------- query : string the query string to geocode Returns ------- point : tuple the (lat, lon) coordinates returned by the geocoder
[ "Geocode", "a", "query", "string", "to", "(", "lat", "lon", ")", "with", "the", "Nominatim", "geocoder", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L863-L892
train
Geocode a query string to a tuple of lat lon
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
get_route_edge_attributes
def get_route_edge_attributes(G, route, attribute=None, minimize_key='length', retrieve_default=None): """ Get a list of attribute values for each edge in a path. Parameters ---------- G : networkx multidigraph route : list list of nodes in the path attribute : string the na...
python
def get_route_edge_attributes(G, route, attribute=None, minimize_key='length', retrieve_default=None): """ Get a list of attribute values for each edge in a path. Parameters ---------- G : networkx multidigraph route : list list of nodes in the path attribute : string the na...
[ "def", "get_route_edge_attributes", "(", "G", ",", "route", ",", "attribute", "=", "None", ",", "minimize_key", "=", "'length'", ",", "retrieve_default", "=", "None", ")", ":", "attribute_values", "=", "[", "]", "for", "u", ",", "v", "in", "zip", "(", "r...
Get a list of attribute values for each edge in a path. Parameters ---------- G : networkx multidigraph route : list list of nodes in the path attribute : string the name of the attribute to get the value of for each edge. If not specified, the complete data dict is returned...
[ "Get", "a", "list", "of", "attribute", "values", "for", "each", "edge", "in", "a", "path", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L896-L932
train
Get a list of attribute values for each edge in a multidigraph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
count_streets_per_node
def count_streets_per_node(G, nodes=None): """ Count how many street segments emanate from each node (i.e., intersections and dead-ends) in this graph. If nodes is passed, then only count the nodes in the graph with those IDs. Parameters ---------- G : networkx multidigraph nodes : iterabl...
python
def count_streets_per_node(G, nodes=None): """ Count how many street segments emanate from each node (i.e., intersections and dead-ends) in this graph. If nodes is passed, then only count the nodes in the graph with those IDs. Parameters ---------- G : networkx multidigraph nodes : iterabl...
[ "def", "count_streets_per_node", "(", "G", ",", "nodes", "=", "None", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "# to calculate the counts, get undirected representation of the graph. for", "# each node, get the list of the set of unique u,v,key edges, including...
Count how many street segments emanate from each node (i.e., intersections and dead-ends) in this graph. If nodes is passed, then only count the nodes in the graph with those IDs. Parameters ---------- G : networkx multidigraph nodes : iterable the set of node IDs to get counts for Re...
[ "Count", "how", "many", "street", "segments", "emanate", "from", "each", "node", "(", "i", ".", "e", ".", "intersections", "and", "dead", "-", "ends", ")", "in", "this", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L936-L999
train
Counts how many streets emanate from each node in a multi - graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
round_polygon_coords
def round_polygon_coords(p, precision): """ Round the coordinates of a shapely Polygon to some decimal precision. Parameters ---------- p : shapely Polygon the polygon to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- ...
python
def round_polygon_coords(p, precision): """ Round the coordinates of a shapely Polygon to some decimal precision. Parameters ---------- p : shapely Polygon the polygon to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- ...
[ "def", "round_polygon_coords", "(", "p", ",", "precision", ")", ":", "# round the coordinates of the Polygon exterior", "new_exterior", "=", "[", "[", "round", "(", "x", ",", "precision", ")", "for", "x", "in", "c", "]", "for", "c", "in", "p", ".", "exterior...
Round the coordinates of a shapely Polygon to some decimal precision. Parameters ---------- p : shapely Polygon the polygon to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- new_poly : shapely Polygon the polygon w...
[ "Round", "the", "coordinates", "of", "a", "shapely", "Polygon", "to", "some", "decimal", "precision", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1003-L1031
train
Round the coordinates of a shapely Polygon to some decimal precision.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
round_point_coords
def round_point_coords(pt, precision): """ Round the coordinates of a shapely Point to some decimal precision. Parameters ---------- pt : shapely Point the Point to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- Po...
python
def round_point_coords(pt, precision): """ Round the coordinates of a shapely Point to some decimal precision. Parameters ---------- pt : shapely Point the Point to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- Po...
[ "def", "round_point_coords", "(", "pt", ",", "precision", ")", ":", "return", "Point", "(", "[", "round", "(", "x", ",", "precision", ")", "for", "x", "in", "pt", ".", "coords", "[", "0", "]", "]", ")" ]
Round the coordinates of a shapely Point to some decimal precision. Parameters ---------- pt : shapely Point the Point to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- Point
[ "Round", "the", "coordinates", "of", "a", "shapely", "Point", "to", "some", "decimal", "precision", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1055-L1071
train
Round the coordinates of a shapely Point to some decimal precision.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
round_linestring_coords
def round_linestring_coords(ls, precision): """ Round the coordinates of a shapely LineString to some decimal precision. Parameters ---------- ls : shapely LineString the LineString to round the coordinates of precision : int decimal precision to round coordinates to Return...
python
def round_linestring_coords(ls, precision): """ Round the coordinates of a shapely LineString to some decimal precision. Parameters ---------- ls : shapely LineString the LineString to round the coordinates of precision : int decimal precision to round coordinates to Return...
[ "def", "round_linestring_coords", "(", "ls", ",", "precision", ")", ":", "return", "LineString", "(", "[", "[", "round", "(", "x", ",", "precision", ")", "for", "x", "in", "c", "]", "for", "c", "in", "ls", ".", "coords", "]", ")" ]
Round the coordinates of a shapely LineString to some decimal precision. Parameters ---------- ls : shapely LineString the LineString to round the coordinates of precision : int decimal precision to round coordinates to Returns ------- LineString
[ "Round", "the", "coordinates", "of", "a", "shapely", "LineString", "to", "some", "decimal", "precision", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1095-L1111
train
Round the coordinates of a shapely LineString to some decimal precision.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
round_shape_coords
def round_shape_coords(shape, precision): """ Round the coordinates of a shapely geometry to some decimal precision. Parameters ---------- shape : shapely geometry, one of Point, MultiPoint, LineString, MultiLineString, Polygon, or MultiPolygon the geometry to round the coordina...
python
def round_shape_coords(shape, precision): """ Round the coordinates of a shapely geometry to some decimal precision. Parameters ---------- shape : shapely geometry, one of Point, MultiPoint, LineString, MultiLineString, Polygon, or MultiPolygon the geometry to round the coordina...
[ "def", "round_shape_coords", "(", "shape", ",", "precision", ")", ":", "if", "isinstance", "(", "shape", ",", "Point", ")", ":", "return", "round_point_coords", "(", "shape", ",", "precision", ")", "elif", "isinstance", "(", "shape", ",", "MultiPoint", ")", ...
Round the coordinates of a shapely geometry to some decimal precision. Parameters ---------- shape : shapely geometry, one of Point, MultiPoint, LineString, MultiLineString, Polygon, or MultiPolygon the geometry to round the coordinates of precision : int decimal precision t...
[ "Round", "the", "coordinates", "of", "a", "shapely", "geometry", "to", "some", "decimal", "precision", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1135-L1171
train
Round the coordinates of a shapely geometry to some decimal precision.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
overpass_json_from_file
def overpass_json_from_file(filename): """ Read OSM XML from input filename and return Overpass-like JSON. Parameters ---------- filename : string name of file containing OSM XML data Returns ------- OSMContentHandler object """ _, ext = os.path.splitext(filename) ...
python
def overpass_json_from_file(filename): """ Read OSM XML from input filename and return Overpass-like JSON. Parameters ---------- filename : string name of file containing OSM XML data Returns ------- OSMContentHandler object """ _, ext = os.path.splitext(filename) ...
[ "def", "overpass_json_from_file", "(", "filename", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "ext", "==", "'.bz2'", ":", "# Use Python 2/3 compatible BZ2File()", "opener", "=", "lambda", "fn", ":", "bz2",...
Read OSM XML from input filename and return Overpass-like JSON. Parameters ---------- filename : string name of file containing OSM XML data Returns ------- OSMContentHandler object
[ "Read", "OSM", "XML", "from", "input", "filename", "and", "return", "Overpass", "-", "like", "JSON", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1217-L1243
train
Read OSM XML from input filename and return Overpass - like JSON.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/utils.py
bbox_to_poly
def bbox_to_poly(north, south, east, west): """ Convenience function to parse bbox -> poly """ return Polygon([(west, south), (east, south), (east, north), (west, north)])
python
def bbox_to_poly(north, south, east, west): """ Convenience function to parse bbox -> poly """ return Polygon([(west, south), (east, south), (east, north), (west, north)])
[ "def", "bbox_to_poly", "(", "north", ",", "south", ",", "east", ",", "west", ")", ":", "return", "Polygon", "(", "[", "(", "west", ",", "south", ")", ",", "(", "east", ",", "south", ")", ",", "(", "east", ",", "north", ")", ",", "(", "west", ",...
Convenience function to parse bbox -> poly
[ "Convenience", "function", "to", "parse", "bbox", "-", ">", "poly" ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1247-L1252
train
Convert bounding box to polygon
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
parse_poi_query
def parse_poi_query(north, south, east, west, amenities=None, timeout=180, maxsize=''): """ Parse the Overpass QL query based on the list of amenities. Parameters ---------- north : float Northernmost coordinate from bounding box of the search area. south : float Southernmo...
python
def parse_poi_query(north, south, east, west, amenities=None, timeout=180, maxsize=''): """ Parse the Overpass QL query based on the list of amenities. Parameters ---------- north : float Northernmost coordinate from bounding box of the search area. south : float Southernmo...
[ "def", "parse_poi_query", "(", "north", ",", "south", ",", "east", ",", "west", ",", "amenities", "=", "None", ",", "timeout", "=", "180", ",", "maxsize", "=", "''", ")", ":", "if", "amenities", ":", "# Overpass QL template", "query_template", "=", "(", ...
Parse the Overpass QL query based on the list of amenities. Parameters ---------- north : float Northernmost coordinate from bounding box of the search area. south : float Southernmost coordinate from bounding box of the search area. east : float Easternmost coordinate ...
[ "Parse", "the", "Overpass", "QL", "query", "based", "on", "the", "list", "of", "amenities", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L24-L65
train
Parse the Overpass QL query based on the list of amenities.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
osm_poi_download
def osm_poi_download(polygon=None, amenities=None, north=None, south=None, east=None, west=None, timeout=180, max_query_area_size=50*1000*50*1000): """ Get points of interests (POIs) from OpenStreetMap based on selected amenity types. Parameters ---------- poly : shapely.geomet...
python
def osm_poi_download(polygon=None, amenities=None, north=None, south=None, east=None, west=None, timeout=180, max_query_area_size=50*1000*50*1000): """ Get points of interests (POIs) from OpenStreetMap based on selected amenity types. Parameters ---------- poly : shapely.geomet...
[ "def", "osm_poi_download", "(", "polygon", "=", "None", ",", "amenities", "=", "None", ",", "north", "=", "None", ",", "south", "=", "None", ",", "east", "=", "None", ",", "west", "=", "None", ",", "timeout", "=", "180", ",", "max_query_area_size", "="...
Get points of interests (POIs) from OpenStreetMap based on selected amenity types. Parameters ---------- poly : shapely.geometry.Polygon Polygon that will be used to limit the POI search. amenities : list List of amenities that will be used for finding the POIs from the selected area. ...
[ "Get", "points", "of", "interests", "(", "POIs", ")", "from", "OpenStreetMap", "based", "on", "selected", "amenity", "types", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L68-L107
train
Download POIs from OpenStreetMap based on selected amenities.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
parse_nodes_coords
def parse_nodes_coords(osm_response): """ Parse node coordinates from OSM response. Some nodes are standalone points of interest, others are vertices in polygonal (areal) POIs. Parameters ---------- osm_response : string OSM response JSON string Returns ------- ...
python
def parse_nodes_coords(osm_response): """ Parse node coordinates from OSM response. Some nodes are standalone points of interest, others are vertices in polygonal (areal) POIs. Parameters ---------- osm_response : string OSM response JSON string Returns ------- ...
[ "def", "parse_nodes_coords", "(", "osm_response", ")", ":", "coords", "=", "{", "}", "for", "result", "in", "osm_response", "[", "'elements'", "]", ":", "if", "'type'", "in", "result", "and", "result", "[", "'type'", "]", "==", "'node'", ":", "coords", "...
Parse node coordinates from OSM response. Some nodes are standalone points of interest, others are vertices in polygonal (areal) POIs. Parameters ---------- osm_response : string OSM response JSON string Returns ------- coords : dict dict of node IDs and their ...
[ "Parse", "node", "coordinates", "from", "OSM", "response", ".", "Some", "nodes", "are", "standalone", "points", "of", "interest", "others", "are", "vertices", "in", "polygonal", "(", "areal", ")", "POIs", ".", "Parameters", "----------", "osm_response", ":", "...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L110-L132
train
Parse node coordinates from OSM response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
parse_polygonal_poi
def parse_polygonal_poi(coords, response): """ Parse areal POI way polygons from OSM node coords. Parameters ---------- coords : dict dict of node IDs and their lat, lon coordinates Returns ------- dict of POIs containing each's nodes, polygon geometry, and osmid """ i...
python
def parse_polygonal_poi(coords, response): """ Parse areal POI way polygons from OSM node coords. Parameters ---------- coords : dict dict of node IDs and their lat, lon coordinates Returns ------- dict of POIs containing each's nodes, polygon geometry, and osmid """ i...
[ "def", "parse_polygonal_poi", "(", "coords", ",", "response", ")", ":", "if", "'type'", "in", "response", "and", "response", "[", "'type'", "]", "==", "'way'", ":", "nodes", "=", "response", "[", "'nodes'", "]", "try", ":", "polygon", "=", "Polygon", "("...
Parse areal POI way polygons from OSM node coords. Parameters ---------- coords : dict dict of node IDs and their lat, lon coordinates Returns ------- dict of POIs containing each's nodes, polygon geometry, and osmid
[ "Parse", "areal", "POI", "way", "polygons", "from", "OSM", "node", "coords", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L135-L166
train
Parses the areal POI way polygons from OSM node coords.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
parse_osm_node
def parse_osm_node(response): """ Parse points from OSM nodes. Parameters ---------- response : JSON Nodes from OSM response. Returns ------- Dict of vertex IDs and their lat, lon coordinates. """ try: point = Point(response['lon'], response['lat']) ...
python
def parse_osm_node(response): """ Parse points from OSM nodes. Parameters ---------- response : JSON Nodes from OSM response. Returns ------- Dict of vertex IDs and their lat, lon coordinates. """ try: point = Point(response['lon'], response['lat']) ...
[ "def", "parse_osm_node", "(", "response", ")", ":", "try", ":", "point", "=", "Point", "(", "response", "[", "'lon'", "]", ",", "response", "[", "'lat'", "]", ")", "poi", "=", "{", "'osmid'", ":", "response", "[", "'id'", "]", ",", "'geometry'", ":",...
Parse points from OSM nodes. Parameters ---------- response : JSON Nodes from OSM response. Returns ------- Dict of vertex IDs and their lat, lon coordinates.
[ "Parse", "points", "from", "OSM", "nodes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L169-L197
train
Parses OSM nodes and returns a dict of vertex IDs and their lat lon coordinates.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
invalid_multipoly_handler
def invalid_multipoly_handler(gdf, relation, way_ids): """ Handles invalid multipolygon geometries when there exists e.g. a feature without geometry (geometry == NaN) Parameters ---------- gdf : gpd.GeoDataFrame GeoDataFrame with Polygon geometries that should be converted into a Mult...
python
def invalid_multipoly_handler(gdf, relation, way_ids): """ Handles invalid multipolygon geometries when there exists e.g. a feature without geometry (geometry == NaN) Parameters ---------- gdf : gpd.GeoDataFrame GeoDataFrame with Polygon geometries that should be converted into a Mult...
[ "def", "invalid_multipoly_handler", "(", "gdf", ",", "relation", ",", "way_ids", ")", ":", "try", ":", "gdf_clean", "=", "gdf", ".", "dropna", "(", "subset", "=", "[", "'geometry'", "]", ")", "multipoly", "=", "MultiPolygon", "(", "list", "(", "gdf_clean",...
Handles invalid multipolygon geometries when there exists e.g. a feature without geometry (geometry == NaN) Parameters ---------- gdf : gpd.GeoDataFrame GeoDataFrame with Polygon geometries that should be converted into a MultiPolygon object. relation : dict OSM 'relation' diction...
[ "Handles", "invalid", "multipolygon", "geometries", "when", "there", "exists", "e", ".", "g", ".", "a", "feature", "without", "geometry", "(", "geometry", "==", "NaN", ")" ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L200-L224
train
Handles invalid multipolygon geometries when there exists a feature with NaN geometry
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
parse_osm_relations
def parse_osm_relations(relations, osm_way_df): """ Parses the osm relations (multipolygons) from osm ways and nodes. See more information about relations from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation Parameters ---------- relations : list OSM 'rela...
python
def parse_osm_relations(relations, osm_way_df): """ Parses the osm relations (multipolygons) from osm ways and nodes. See more information about relations from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation Parameters ---------- relations : list OSM 'rela...
[ "def", "parse_osm_relations", "(", "relations", ",", "osm_way_df", ")", ":", "gdf_relations", "=", "gpd", ".", "GeoDataFrame", "(", ")", "# Iterate over relations and extract the items", "for", "relation", "in", "relations", ":", "if", "relation", "[", "'tags'", "]"...
Parses the osm relations (multipolygons) from osm ways and nodes. See more information about relations from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation Parameters ---------- relations : list OSM 'relation' items (dictionaries) in a list. osm_way_df : gpd....
[ "Parses", "the", "osm", "relations", "(", "multipolygons", ")", "from", "osm", "ways", "and", "nodes", ".", "See", "more", "information", "about", "relations", "from", "OSM", "documentation", ":", "http", ":", "//", "wiki", ".", "openstreetmap", ".", "org", ...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L226-L286
train
Parses the OSM relations and returns a GeoDataFrame with the MultiPolygon representations of the ways and nodes of those relations.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
create_poi_gdf
def create_poi_gdf(polygon=None, amenities=None, north=None, south=None, east=None, west=None): """ Parse GeoDataFrames from POI json that was returned by Overpass API. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the POIs within amenities: l...
python
def create_poi_gdf(polygon=None, amenities=None, north=None, south=None, east=None, west=None): """ Parse GeoDataFrames from POI json that was returned by Overpass API. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the POIs within amenities: l...
[ "def", "create_poi_gdf", "(", "polygon", "=", "None", ",", "amenities", "=", "None", ",", "north", "=", "None", ",", "south", "=", "None", ",", "east", "=", "None", ",", "west", "=", "None", ")", ":", "responses", "=", "osm_poi_download", "(", "polygon...
Parse GeoDataFrames from POI json that was returned by Overpass API. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the POIs within amenities: list List of amenities that will be used for finding the POIs from the selected area. See av...
[ "Parse", "GeoDataFrames", "from", "POI", "json", "that", "was", "returned", "by", "Overpass", "API", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L289-L361
train
Create a GeoDataFrame from the OSM POI json file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
pois_from_point
def pois_from_point(point, distance=None, amenities=None): """ Get point of interests (POIs) within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters amenities : list...
python
def pois_from_point(point, distance=None, amenities=None): """ Get point of interests (POIs) within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters amenities : list...
[ "def", "pois_from_point", "(", "point", ",", "distance", "=", "None", ",", "amenities", "=", "None", ")", ":", "bbox", "=", "bbox_from_point", "(", "point", "=", "point", ",", "distance", "=", "distance", ")", "north", ",", "south", ",", "east", ",", "...
Get point of interests (POIs) within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters amenities : list List of amenities that will be used for finding the POIs from ...
[ "Get", "point", "of", "interests", "(", "POIs", ")", "within", "some", "distance", "north", "south", "east", "and", "west", "of", "a", "lat", "-", "long", "point", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L364-L386
train
Returns a GeoDataFrame containing all the POIs within some distance north south east and west of a point.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
pois_from_address
def pois_from_address(address, distance, amenities=None): """ Get OSM points of Interests within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric distance in meters ...
python
def pois_from_address(address, distance, amenities=None): """ Get OSM points of Interests within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric distance in meters ...
[ "def", "pois_from_address", "(", "address", ",", "distance", ",", "amenities", "=", "None", ")", ":", "# geocode the address string to a (lat, lon) point", "point", "=", "geocode", "(", "query", "=", "address", ")", "# get POIs within distance of this point", "return", ...
Get OSM points of Interests within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric distance in meters amenities : list List of amenities that will be used for f...
[ "Get", "OSM", "points", "of", "Interests", "within", "some", "distance", "north", "south", "east", "and", "west", "of", "an", "address", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L389-L413
train
Returns a GeoDataFrame containing OSM points of Interests within some distance north south east and west of the address.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/pois.py
pois_from_place
def pois_from_place(place, amenities=None): """ Get points of interest (POIs) within the boundaries of some place. Parameters ---------- place : string the query to geocode to get geojson boundary polygon. amenities : list List of amenities that will be used for finding the POIs...
python
def pois_from_place(place, amenities=None): """ Get points of interest (POIs) within the boundaries of some place. Parameters ---------- place : string the query to geocode to get geojson boundary polygon. amenities : list List of amenities that will be used for finding the POIs...
[ "def", "pois_from_place", "(", "place", ",", "amenities", "=", "None", ")", ":", "city", "=", "gdf_from_place", "(", "place", ")", "polygon", "=", "city", "[", "'geometry'", "]", ".", "iloc", "[", "0", "]", "return", "create_poi_gdf", "(", "polygon", "="...
Get points of interest (POIs) within the boundaries of some place. Parameters ---------- place : string the query to geocode to get geojson boundary polygon. amenities : list List of amenities that will be used for finding the POIs from the selected area. See available amenities...
[ "Get", "points", "of", "interest", "(", "POIs", ")", "within", "the", "boundaries", "of", "some", "place", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L436-L455
train
Returns a GeoDataFrame containing the POIs within the boundaries of some place.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/simplify.py
is_endpoint
def is_endpoint(G, node, strict=True): """ Return True if the node is a "real" endpoint of an edge in the network, \ otherwise False. OSM data includes lots of nodes that exist only as points \ to help streets bend around curves. An end point is a node that either: \ 1) is its own neighbor, ie, it s...
python
def is_endpoint(G, node, strict=True): """ Return True if the node is a "real" endpoint of an edge in the network, \ otherwise False. OSM data includes lots of nodes that exist only as points \ to help streets bend around curves. An end point is a node that either: \ 1) is its own neighbor, ie, it s...
[ "def", "is_endpoint", "(", "G", ",", "node", ",", "strict", "=", "True", ")", ":", "neighbors", "=", "set", "(", "list", "(", "G", ".", "predecessors", "(", "node", ")", ")", "+", "list", "(", "G", ".", "successors", "(", "node", ")", ")", ")", ...
Return True if the node is a "real" endpoint of an edge in the network, \ otherwise False. OSM data includes lots of nodes that exist only as points \ to help streets bend around curves. An end point is a node that either: \ 1) is its own neighbor, ie, it self-loops. \ 2) or, has no incoming edges or no...
[ "Return", "True", "if", "the", "node", "is", "a", "real", "endpoint", "of", "an", "edge", "in", "the", "network", "\\", "otherwise", "False", ".", "OSM", "data", "includes", "lots", "of", "nodes", "that", "exist", "only", "as", "points", "\\", "to", "h...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L20-L88
train
Returns True if the node is a real endpoint of an edge in the network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/simplify.py
build_path
def build_path(G, node, endpoints, path): """ Recursively build a path of nodes until you hit an endpoint node. Parameters ---------- G : networkx multidigraph node : int the current node to start from endpoints : set the set of all nodes in the graph that are endpoints ...
python
def build_path(G, node, endpoints, path): """ Recursively build a path of nodes until you hit an endpoint node. Parameters ---------- G : networkx multidigraph node : int the current node to start from endpoints : set the set of all nodes in the graph that are endpoints ...
[ "def", "build_path", "(", "G", ",", "node", ",", "endpoints", ",", "path", ")", ":", "# for each successor in the passed-in node", "for", "successor", "in", "G", ".", "successors", "(", "node", ")", ":", "if", "successor", "not", "in", "path", ":", "# if thi...
Recursively build a path of nodes until you hit an endpoint node. Parameters ---------- G : networkx multidigraph node : int the current node to start from endpoints : set the set of all nodes in the graph that are endpoints path : list the list of nodes in order in the ...
[ "Recursively", "build", "a", "path", "of", "nodes", "until", "you", "hit", "an", "endpoint", "node", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L91-L131
train
Recursively build a path of nodes that are in the given set of endpoints.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/simplify.py
get_paths_to_simplify
def get_paths_to_simplify(G, strict=True): """ Create a list of all the paths to be simplified between endpoint nodes. The path is ordered from the first endpoint, through the interstitial nodes, to the second endpoint. If your street network is in a rural area with many interstitial nodes between ...
python
def get_paths_to_simplify(G, strict=True): """ Create a list of all the paths to be simplified between endpoint nodes. The path is ordered from the first endpoint, through the interstitial nodes, to the second endpoint. If your street network is in a rural area with many interstitial nodes between ...
[ "def", "get_paths_to_simplify", "(", "G", ",", "strict", "=", "True", ")", ":", "# first identify all the nodes that are endpoints", "start_time", "=", "time", ".", "time", "(", ")", "endpoints", "=", "set", "(", "[", "node", "for", "node", "in", "G", ".", "...
Create a list of all the paths to be simplified between endpoint nodes. The path is ordered from the first endpoint, through the interstitial nodes, to the second endpoint. If your street network is in a rural area with many interstitial nodes between true edge endpoints, you may want to increase your ...
[ "Create", "a", "list", "of", "all", "the", "paths", "to", "be", "simplified", "between", "endpoint", "nodes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L134-L185
train
Returns a list of all the paths to be simplified between endpoint nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/simplify.py
simplify_graph
def simplify_graph(G, strict=True): """ Simplify a graph's topology by removing all nodes that are not intersections or dead-ends. Create an edge directly between the end points that encapsulate them, but retain the geometry of the original edges, saved as attribute in new edge. Parameters...
python
def simplify_graph(G, strict=True): """ Simplify a graph's topology by removing all nodes that are not intersections or dead-ends. Create an edge directly between the end points that encapsulate them, but retain the geometry of the original edges, saved as attribute in new edge. Parameters...
[ "def", "simplify_graph", "(", "G", ",", "strict", "=", "True", ")", ":", "if", "is_simplified", "(", "G", ")", ":", "raise", "Exception", "(", "'This graph has already been simplified, cannot simplify it again.'", ")", "log", "(", "'Begin topologically simplifying the g...
Simplify a graph's topology by removing all nodes that are not intersections or dead-ends. Create an edge directly between the end points that encapsulate them, but retain the geometry of the original edges, saved as attribute in new edge. Parameters ---------- G : networkx multidigraph ...
[ "Simplify", "a", "graph", "s", "topology", "by", "removing", "all", "nodes", "that", "are", "not", "intersections", "or", "dead", "-", "ends", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L207-L299
train
Simplify a networkx graph by removing all nodes that are not intersections and optionally adding all edges that are not intersections or dead - ends.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/simplify.py
clean_intersections
def clean_intersections(G, tolerance=15, dead_ends=False): """ Clean-up intersections comprising clusters of nodes by merging them and returning their centroids. Divided roads are represented by separate centerline edges. The intersection of two divided roads thus creates 4 nodes, representing wher...
python
def clean_intersections(G, tolerance=15, dead_ends=False): """ Clean-up intersections comprising clusters of nodes by merging them and returning their centroids. Divided roads are represented by separate centerline edges. The intersection of two divided roads thus creates 4 nodes, representing wher...
[ "def", "clean_intersections", "(", "G", ",", "tolerance", "=", "15", ",", "dead_ends", "=", "False", ")", ":", "# if dead_ends is False, discard dead-end nodes to only work with edge", "# intersections", "if", "not", "dead_ends", ":", "if", "'streets_per_node'", "in", "...
Clean-up intersections comprising clusters of nodes by merging them and returning their centroids. Divided roads are represented by separate centerline edges. The intersection of two divided roads thus creates 4 nodes, representing where each edge intersects a perpendicular edge. These 4 nodes represen...
[ "Clean", "-", "up", "intersections", "comprising", "clusters", "of", "nodes", "by", "merging", "them", "and", "returning", "their", "centroids", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L302-L357
train
Clean - up intersections comprising clusters of nodes and edges of nodes and edges of nodes and edges of edges.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/projection.py
project_geometry
def project_geometry(geometry, crs=None, to_crs=None, to_latlong=False): """ Project a shapely Polygon or MultiPolygon from lat-long to UTM, or vice-versa Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to project crs : dict the starting coordin...
python
def project_geometry(geometry, crs=None, to_crs=None, to_latlong=False): """ Project a shapely Polygon or MultiPolygon from lat-long to UTM, or vice-versa Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to project crs : dict the starting coordin...
[ "def", "project_geometry", "(", "geometry", ",", "crs", "=", "None", ",", "to_crs", "=", "None", ",", "to_latlong", "=", "False", ")", ":", "if", "crs", "is", "None", ":", "crs", "=", "settings", ".", "default_crs", "gdf", "=", "gpd", ".", "GeoDataFram...
Project a shapely Polygon or MultiPolygon from lat-long to UTM, or vice-versa Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to project crs : dict the starting coordinate reference system of the passed-in geometry, default value (None) will set...
[ "Project", "a", "shapely", "Polygon", "or", "MultiPolygon", "from", "lat", "-", "long", "to", "UTM", "or", "vice", "-", "versa" ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L20-L55
train
Project a shapely geometry to UTM or a shapely polygon or MultiPolygon from lat - long to UTM
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/projection.py
project_gdf
def project_gdf(gdf, to_crs=None, to_latlong=False): """ Project a GeoDataFrame to the UTM zone appropriate for its geometries' centroid. The simple calculation in this function works well for most latitudes, but won't work for some far northern locations like Svalbard and parts of far northern...
python
def project_gdf(gdf, to_crs=None, to_latlong=False): """ Project a GeoDataFrame to the UTM zone appropriate for its geometries' centroid. The simple calculation in this function works well for most latitudes, but won't work for some far northern locations like Svalbard and parts of far northern...
[ "def", "project_gdf", "(", "gdf", ",", "to_crs", "=", "None", ",", "to_latlong", "=", "False", ")", ":", "assert", "len", "(", "gdf", ")", ">", "0", ",", "'You cannot project an empty GeoDataFrame.'", "start_time", "=", "time", ".", "time", "(", ")", "# if...
Project a GeoDataFrame to the UTM zone appropriate for its geometries' centroid. The simple calculation in this function works well for most latitudes, but won't work for some far northern locations like Svalbard and parts of far northern Norway. Parameters ---------- gdf : GeoDataFrame ...
[ "Project", "a", "GeoDataFrame", "to", "the", "UTM", "zone", "appropriate", "for", "its", "geometries", "centroid", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L58-L123
train
Project a GeoDataFrame to the UTM zone appropriate for its geometries.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/projection.py
project_graph
def project_graph(G, to_crs=None): """ Project a graph from lat-long to the UTM zone appropriate for its geographic location. Parameters ---------- G : networkx multidigraph the networkx graph to be projected to_crs : dict if not None, just project to this CRS instead of to ...
python
def project_graph(G, to_crs=None): """ Project a graph from lat-long to the UTM zone appropriate for its geographic location. Parameters ---------- G : networkx multidigraph the networkx graph to be projected to_crs : dict if not None, just project to this CRS instead of to ...
[ "def", "project_graph", "(", "G", ",", "to_crs", "=", "None", ")", ":", "G_proj", "=", "G", ".", "copy", "(", ")", "start_time", "=", "time", ".", "time", "(", ")", "# create a GeoDataFrame of the nodes, name it, convert osmid to str", "nodes", ",", "data", "=...
Project a graph from lat-long to the UTM zone appropriate for its geographic location. Parameters ---------- G : networkx multidigraph the networkx graph to be projected to_crs : dict if not None, just project to this CRS instead of to UTM Returns ------- networkx multi...
[ "Project", "a", "graph", "from", "lat", "-", "long", "to", "the", "UTM", "zone", "appropriate", "for", "its", "geographic", "location", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L126-L214
train
Project a networkx graph to UTM zone appropriate for its geographic location.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_shape
def plot_shape(gdf, fc='#cbe0f0', ec='#999999', linewidth=1, alpha=1, figsize=(6,6), margin=0.02, axis_off=True): """ Plot a GeoDataFrame of place boundary geometries. Parameters ---------- gdf : GeoDataFrame the gdf containing the geometries to plot fc : string or list ...
python
def plot_shape(gdf, fc='#cbe0f0', ec='#999999', linewidth=1, alpha=1, figsize=(6,6), margin=0.02, axis_off=True): """ Plot a GeoDataFrame of place boundary geometries. Parameters ---------- gdf : GeoDataFrame the gdf containing the geometries to plot fc : string or list ...
[ "def", "plot_shape", "(", "gdf", ",", "fc", "=", "'#cbe0f0'", ",", "ec", "=", "'#999999'", ",", "linewidth", "=", "1", ",", "alpha", "=", "1", ",", "figsize", "=", "(", "6", ",", "6", ")", ",", "margin", "=", "0.02", ",", "axis_off", "=", "True",...
Plot a GeoDataFrame of place boundary geometries. Parameters ---------- gdf : GeoDataFrame the gdf containing the geometries to plot fc : string or list the facecolor (or list of facecolors) for the polygons ec : string or list the edgecolor (or list of edgecolors) for the p...
[ "Plot", "a", "GeoDataFrame", "of", "place", "boundary", "geometries", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L37-L97
train
Plots a GeoDataFrame of place boundary geometries.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
rgb_color_list_to_hex
def rgb_color_list_to_hex(color_list): """ Convert a list of RGBa colors to a list of hexadecimal color codes. Parameters ---------- color_list : list the list of RGBa colors Returns ------- color_list_hex : list """ color_list_rgb = [[int(x*255) for x in c[0:3]] for c ...
python
def rgb_color_list_to_hex(color_list): """ Convert a list of RGBa colors to a list of hexadecimal color codes. Parameters ---------- color_list : list the list of RGBa colors Returns ------- color_list_hex : list """ color_list_rgb = [[int(x*255) for x in c[0:3]] for c ...
[ "def", "rgb_color_list_to_hex", "(", "color_list", ")", ":", "color_list_rgb", "=", "[", "[", "int", "(", "x", "*", "255", ")", "for", "x", "in", "c", "[", "0", ":", "3", "]", "]", "for", "c", "in", "color_list", "]", "color_list_hex", "=", "[", "'...
Convert a list of RGBa colors to a list of hexadecimal color codes. Parameters ---------- color_list : list the list of RGBa colors Returns ------- color_list_hex : list
[ "Convert", "a", "list", "of", "RGBa", "colors", "to", "a", "list", "of", "hexadecimal", "color", "codes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L100-L115
train
Convert a list of RGBa colors to a list of hexadecimal color codes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
get_colors
def get_colors(n, cmap='viridis', start=0., stop=1., alpha=1., return_hex=False): """ Return n-length list of RGBa colors from the passed colormap name and alpha. Parameters ---------- n : int number of colors cmap : string name of a colormap start : float where to s...
python
def get_colors(n, cmap='viridis', start=0., stop=1., alpha=1., return_hex=False): """ Return n-length list of RGBa colors from the passed colormap name and alpha. Parameters ---------- n : int number of colors cmap : string name of a colormap start : float where to s...
[ "def", "get_colors", "(", "n", ",", "cmap", "=", "'viridis'", ",", "start", "=", "0.", ",", "stop", "=", "1.", ",", "alpha", "=", "1.", ",", "return_hex", "=", "False", ")", ":", "colors", "=", "[", "cm", ".", "get_cmap", "(", "cmap", ")", "(", ...
Return n-length list of RGBa colors from the passed colormap name and alpha. Parameters ---------- n : int number of colors cmap : string name of a colormap start : float where to start in the colorspace stop : float where to end in the colorspace alpha : flo...
[ "Return", "n", "-", "length", "list", "of", "RGBa", "colors", "from", "the", "passed", "colormap", "name", "and", "alpha", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L118-L145
train
Returns n - length list of RGBa colors from the passed colormap name and alpha.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
get_node_colors_by_attr
def get_node_colors_by_attr(G, attr, num_bins=None, cmap='viridis', start=0, stop=1, na_color='none'): """ Get a list of node colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the attribute ...
python
def get_node_colors_by_attr(G, attr, num_bins=None, cmap='viridis', start=0, stop=1, na_color='none'): """ Get a list of node colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the attribute ...
[ "def", "get_node_colors_by_attr", "(", "G", ",", "attr", ",", "num_bins", "=", "None", ",", "cmap", "=", "'viridis'", ",", "start", "=", "0", ",", "stop", "=", "1", ",", "na_color", "=", "'none'", ")", ":", "if", "num_bins", "is", "None", ":", "num_b...
Get a list of node colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the attribute num_bins : int how many quantiles (default None assigns each node to its own bin) cmap : string ...
[ "Get", "a", "list", "of", "node", "colors", "by", "binning", "some", "continuous", "-", "variable", "attribute", "into", "quantiles", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L148-L180
train
Get a list of node colors by binning some continuous - variable attribute into a random variety of quantiles.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
get_edge_colors_by_attr
def get_edge_colors_by_attr(G, attr, num_bins=5, cmap='viridis', start=0, stop=1, na_color='none'): """ Get a list of edge colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the continuous-va...
python
def get_edge_colors_by_attr(G, attr, num_bins=5, cmap='viridis', start=0, stop=1, na_color='none'): """ Get a list of edge colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the continuous-va...
[ "def", "get_edge_colors_by_attr", "(", "G", ",", "attr", ",", "num_bins", "=", "5", ",", "cmap", "=", "'viridis'", ",", "start", "=", "0", ",", "stop", "=", "1", ",", "na_color", "=", "'none'", ")", ":", "if", "num_bins", "is", "None", ":", "num_bins...
Get a list of edge colors by binning some continuous-variable attribute into quantiles. Parameters ---------- G : networkx multidigraph attr : string the name of the continuous-variable attribute num_bins : int how many quantiles cmap : string name of a colormap ...
[ "Get", "a", "list", "of", "edge", "colors", "by", "binning", "some", "continuous", "-", "variable", "attribute", "into", "quantiles", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L183-L215
train
Get a list of edge colors by binning some continuous - variable attribute into a random network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
save_and_show
def save_and_show(fig, ax, save, show, close, filename, file_format, dpi, axis_off): """ Save a figure to disk and show it, as specified. Parameters ---------- fig : figure ax : axis save : bool whether to save the figure to disk or not show : bool whether to display the...
python
def save_and_show(fig, ax, save, show, close, filename, file_format, dpi, axis_off): """ Save a figure to disk and show it, as specified. Parameters ---------- fig : figure ax : axis save : bool whether to save the figure to disk or not show : bool whether to display the...
[ "def", "save_and_show", "(", "fig", ",", "ax", ",", "save", ",", "show", ",", "close", ",", "filename", ",", "file_format", ",", "dpi", ",", "axis_off", ")", ":", "# save the figure if specified", "if", "save", ":", "start_time", "=", "time", ".", "time", ...
Save a figure to disk and show it, as specified. Parameters ---------- fig : figure ax : axis save : bool whether to save the figure to disk or not show : bool whether to display the figure or not close : bool close the figure (only if show equals False) to prevent d...
[ "Save", "a", "figure", "to", "disk", "and", "show", "it", "as", "specified", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L218-L281
train
Save a figure to disk and show it as specified.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_graph
def plot_graph(G, bbox=None, fig_height=6, fig_width=None, margin=0.02, axis_off=True, equal_aspect=False, bgcolor='w', show=True, save=False, close=True, file_format='png', filename='temp', dpi=300, annotate=False, node_color='#66ccff', node_size=15, node_alp...
python
def plot_graph(G, bbox=None, fig_height=6, fig_width=None, margin=0.02, axis_off=True, equal_aspect=False, bgcolor='w', show=True, save=False, close=True, file_format='png', filename='temp', dpi=300, annotate=False, node_color='#66ccff', node_size=15, node_alp...
[ "def", "plot_graph", "(", "G", ",", "bbox", "=", "None", ",", "fig_height", "=", "6", ",", "fig_width", "=", "None", ",", "margin", "=", "0.02", ",", "axis_off", "=", "True", ",", "equal_aspect", "=", "False", ",", "bgcolor", "=", "'w'", ",", "show",...
Plot a networkx spatial graph. Parameters ---------- G : networkx multidigraph bbox : tuple bounding box as north,south,east,west - if None will calculate from spatial extents of data. if passing a bbox, you probably also want to pass margin=0 to constrain it. fig_height : i...
[ "Plot", "a", "networkx", "spatial", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L284-L444
train
Plots a networkx spatial graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
node_list_to_coordinate_lines
def node_list_to_coordinate_lines(G, node_list, use_geom=True): """ Given a list of nodes, return a list of lines that together follow the path defined by the list of nodes. Parameters ---------- G : networkx multidigraph route : list the route as a list of nodes use_geom : bool...
python
def node_list_to_coordinate_lines(G, node_list, use_geom=True): """ Given a list of nodes, return a list of lines that together follow the path defined by the list of nodes. Parameters ---------- G : networkx multidigraph route : list the route as a list of nodes use_geom : bool...
[ "def", "node_list_to_coordinate_lines", "(", "G", ",", "node_list", ",", "use_geom", "=", "True", ")", ":", "edge_nodes", "=", "list", "(", "zip", "(", "node_list", "[", ":", "-", "1", "]", ",", "node_list", "[", "1", ":", "]", ")", ")", "lines", "="...
Given a list of nodes, return a list of lines that together follow the path defined by the list of nodes. Parameters ---------- G : networkx multidigraph route : list the route as a list of nodes use_geom : bool if True, use the spatial geometry attribute of the edges to draw ...
[ "Given", "a", "list", "of", "nodes", "return", "a", "list", "of", "lines", "that", "together", "follow", "the", "path", "defined", "by", "the", "list", "of", "nodes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L447-L486
train
Given a list of nodes return a list of lines that together follow the path .
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_graph_route
def plot_graph_route(G, route, bbox=None, fig_height=6, fig_width=None, margin=0.02, bgcolor='w', axis_off=True, show=True, save=False, close=True, file_format='png', filename='temp', dpi=300, annotate=False, node_color='#999999', node_...
python
def plot_graph_route(G, route, bbox=None, fig_height=6, fig_width=None, margin=0.02, bgcolor='w', axis_off=True, show=True, save=False, close=True, file_format='png', filename='temp', dpi=300, annotate=False, node_color='#999999', node_...
[ "def", "plot_graph_route", "(", "G", ",", "route", ",", "bbox", "=", "None", ",", "fig_height", "=", "6", ",", "fig_width", "=", "None", ",", "margin", "=", "0.02", ",", "bgcolor", "=", "'w'", ",", "axis_off", "=", "True", ",", "show", "=", "True", ...
Plot a route along a networkx spatial graph. Parameters ---------- G : networkx multidigraph route : list the route as a list of nodes bbox : tuple bounding box as north,south,east,west - if None will calculate from spatial extents of data. if passing a bbox, you probably al...
[ "Plot", "a", "route", "along", "a", "networkx", "spatial", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L488-L620
train
Plot a route along a networkx spatial graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
make_folium_polyline
def make_folium_polyline(edge, edge_color, edge_width, edge_opacity, popup_attribute=None): """ Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with attributes. Parameters ---------- edge : GeoSeries a row from the gdf_edges GeoDataFrame edge_color : string ...
python
def make_folium_polyline(edge, edge_color, edge_width, edge_opacity, popup_attribute=None): """ Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with attributes. Parameters ---------- edge : GeoSeries a row from the gdf_edges GeoDataFrame edge_color : string ...
[ "def", "make_folium_polyline", "(", "edge", ",", "edge_color", ",", "edge_width", ",", "edge_opacity", ",", "popup_attribute", "=", "None", ")", ":", "# check if we were able to import folium successfully", "if", "not", "folium", ":", "raise", "ImportError", "(", "'Th...
Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with attributes. Parameters ---------- edge : GeoSeries a row from the gdf_edges GeoDataFrame edge_color : string color of the edge lines edge_width : numeric width of the edge lines edge_opacity : num...
[ "Turn", "a", "row", "from", "the", "gdf_edges", "GeoDataFrame", "into", "a", "folium", "PolyLine", "with", "attributes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L763-L809
train
Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with optional attributes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_graph_folium
def plot_graph_folium(G, graph_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, edge_color='#333333', edge_width=5, edge_opacity=1): """ Plot a graph on an interactive folium web map. Note that anything larger than a small city ca...
python
def plot_graph_folium(G, graph_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, edge_color='#333333', edge_width=5, edge_opacity=1): """ Plot a graph on an interactive folium web map. Note that anything larger than a small city ca...
[ "def", "plot_graph_folium", "(", "G", ",", "graph_map", "=", "None", ",", "popup_attribute", "=", "None", ",", "tiles", "=", "'cartodbpositron'", ",", "zoom", "=", "1", ",", "fit_bounds", "=", "True", ",", "edge_color", "=", "'#333333'", ",", "edge_width", ...
Plot a graph on an interactive folium web map. Note that anything larger than a small city can take a long time to plot and create a large web map file that is very slow to load as JavaScript. Parameters ---------- G : networkx multidigraph graph_map : folium.folium.Map if not None, pl...
[ "Plot", "a", "graph", "on", "an", "interactive", "folium", "web", "map", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L812-L874
train
Plot a graph on an interactive folium web map.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_route_folium
def plot_route_folium(G, route, route_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, route_color='#cc0000', route_width=5, route_opacity=1): """ Plot a route on an interactive folium web map. Parameters ---------- G : ne...
python
def plot_route_folium(G, route, route_map=None, popup_attribute=None, tiles='cartodbpositron', zoom=1, fit_bounds=True, route_color='#cc0000', route_width=5, route_opacity=1): """ Plot a route on an interactive folium web map. Parameters ---------- G : ne...
[ "def", "plot_route_folium", "(", "G", ",", "route", ",", "route_map", "=", "None", ",", "popup_attribute", "=", "None", ",", "tiles", "=", "'cartodbpositron'", ",", "zoom", "=", "1", ",", "fit_bounds", "=", "True", ",", "route_color", "=", "'#cc0000'", ","...
Plot a route on an interactive folium web map. Parameters ---------- G : networkx multidigraph route : list the route as a list of nodes route_map : folium.folium.Map if not None, plot the route on this preexisting folium map object popup_attribute : string edge attribut...
[ "Plot", "a", "route", "on", "an", "interactive", "folium", "web", "map", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L877-L941
train
Plots a route on an interactive folium web map.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/plot.py
plot_figure_ground
def plot_figure_ground(G=None, address=None, point=None, dist=805, network_type='drive_service', street_widths=None, default_width=4, fig_length=8, edge_color='w', bgcolor='#333333', smooth_joints=True, filename=None, file_forma...
python
def plot_figure_ground(G=None, address=None, point=None, dist=805, network_type='drive_service', street_widths=None, default_width=4, fig_length=8, edge_color='w', bgcolor='#333333', smooth_joints=True, filename=None, file_forma...
[ "def", "plot_figure_ground", "(", "G", "=", "None", ",", "address", "=", "None", ",", "point", "=", "None", ",", "dist", "=", "805", ",", "network_type", "=", "'drive_service'", ",", "street_widths", "=", "None", ",", "default_width", "=", "4", ",", "fig...
Plot a figure-ground diagram of a street network, defaulting to one square mile. Parameters ---------- G : networkx multidigraph address : string the address to geocode as the center point if G is not passed in point : tuple the center point if address and G are not passed in ...
[ "Plot", "a", "figure", "-", "ground", "diagram", "of", "a", "street", "network", "defaulting", "to", "one", "square", "mile", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L944-L1100
train
Plot a figure - ground diagram of a street network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
save_to_cache
def save_to_cache(url, response_json): """ Save an HTTP response json object to the cache. If the request was sent to server via POST instead of GET, then URL should be a GET-style representation of request. Users should always pass OrderedDicts instead of dicts of parameters into request functions...
python
def save_to_cache(url, response_json): """ Save an HTTP response json object to the cache. If the request was sent to server via POST instead of GET, then URL should be a GET-style representation of request. Users should always pass OrderedDicts instead of dicts of parameters into request functions...
[ "def", "save_to_cache", "(", "url", ",", "response_json", ")", ":", "if", "settings", ".", "use_cache", ":", "if", "response_json", "is", "None", ":", "log", "(", "'Saved nothing to cache because response_json is None'", ")", "else", ":", "# create the folder on the d...
Save an HTTP response json object to the cache. If the request was sent to server via POST instead of GET, then URL should be a GET-style representation of request. Users should always pass OrderedDicts instead of dicts of parameters into request functions, so that the parameters stay in the same order...
[ "Save", "an", "HTTP", "response", "json", "object", "to", "the", "cache", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L67-L108
train
Save a response json object to the cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_from_cache
def get_from_cache(url): """ Retrieve a HTTP response json object from the cache. Parameters ---------- url : string the url of the request Returns ------- response_json : dict """ # if the tool is configured to use the cache if settings.use_cache: # determi...
python
def get_from_cache(url): """ Retrieve a HTTP response json object from the cache. Parameters ---------- url : string the url of the request Returns ------- response_json : dict """ # if the tool is configured to use the cache if settings.use_cache: # determi...
[ "def", "get_from_cache", "(", "url", ")", ":", "# if the tool is configured to use the cache", "if", "settings", ".", "use_cache", ":", "# determine the filename by hashing the url", "filename", "=", "hashlib", ".", "md5", "(", "url", ".", "encode", "(", "'utf-8'", ")...
Retrieve a HTTP response json object from the cache. Parameters ---------- url : string the url of the request Returns ------- response_json : dict
[ "Retrieve", "a", "HTTP", "response", "json", "object", "from", "the", "cache", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L111-L136
train
Retrieve a HTTP response json object from the cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_http_headers
def get_http_headers(user_agent=None, referer=None, accept_language=None): """ Update the default requests HTTP headers with OSMnx info. Parameters ---------- user_agent : str the user agent string, if None will set with OSMnx default referer : str the referer string, if None wi...
python
def get_http_headers(user_agent=None, referer=None, accept_language=None): """ Update the default requests HTTP headers with OSMnx info. Parameters ---------- user_agent : str the user agent string, if None will set with OSMnx default referer : str the referer string, if None wi...
[ "def", "get_http_headers", "(", "user_agent", "=", "None", ",", "referer", "=", "None", ",", "accept_language", "=", "None", ")", ":", "if", "user_agent", "is", "None", ":", "user_agent", "=", "settings", ".", "default_user_agent", "if", "referer", "is", "No...
Update the default requests HTTP headers with OSMnx info. Parameters ---------- user_agent : str the user agent string, if None will set with OSMnx default referer : str the referer string, if None will set with OSMnx default accept_language : str make accept-language explic...
[ "Update", "the", "default", "requests", "HTTP", "headers", "with", "OSMnx", "info", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L139-L166
train
Returns the HTTP headers for the current OSMnx server.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
nominatim_request
def nominatim_request(params, type = "search", pause_duration=1, timeout=30, error_pause_duration=180): """ Send a request to the Nominatim API via HTTP GET and return the JSON response. Parameters ---------- params : dict or OrderedDict key-value pairs of parameters type : string ...
python
def nominatim_request(params, type = "search", pause_duration=1, timeout=30, error_pause_duration=180): """ Send a request to the Nominatim API via HTTP GET and return the JSON response. Parameters ---------- params : dict or OrderedDict key-value pairs of parameters type : string ...
[ "def", "nominatim_request", "(", "params", ",", "type", "=", "\"search\"", ",", "pause_duration", "=", "1", ",", "timeout", "=", "30", ",", "error_pause_duration", "=", "180", ")", ":", "known_requests", "=", "{", "\"search\"", ",", "\"reverse\"", ",", "\"lo...
Send a request to the Nominatim API via HTTP GET and return the JSON response. Parameters ---------- params : dict or OrderedDict key-value pairs of parameters type : string Type of Nominatim query. One of the following: search, reverse or lookup pause_duration : int how...
[ "Send", "a", "request", "to", "the", "Nominatim", "API", "via", "HTTP", "GET", "and", "return", "the", "JSON", "response", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L224-L296
train
Send a request to the Nominatim API and return the JSON response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
overpass_request
def overpass_request(data, pause_duration=None, timeout=180, error_pause_duration=None): """ Send a request to the Overpass API via HTTP POST and return the JSON response. Parameters ---------- data : dict or OrderedDict key-value pairs of parameters to post to the API pause_duratio...
python
def overpass_request(data, pause_duration=None, timeout=180, error_pause_duration=None): """ Send a request to the Overpass API via HTTP POST and return the JSON response. Parameters ---------- data : dict or OrderedDict key-value pairs of parameters to post to the API pause_duratio...
[ "def", "overpass_request", "(", "data", ",", "pause_duration", "=", "None", ",", "timeout", "=", "180", ",", "error_pause_duration", "=", "None", ")", ":", "# define the Overpass API URL, then construct a GET-style URL as a string to", "# hash to look up/save to cache", "url"...
Send a request to the Overpass API via HTTP POST and return the JSON response. Parameters ---------- data : dict or OrderedDict key-value pairs of parameters to post to the API pause_duration : int how long to pause in seconds before requests, if None, will query API status ...
[ "Send", "a", "request", "to", "the", "Overpass", "API", "via", "HTTP", "POST", "and", "return", "the", "JSON", "response", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L299-L372
train
Send a request to the Overpass API and return the JSON response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
osm_polygon_download
def osm_polygon_download(query, limit=1, polygon_geojson=1): """ Geocode a place and download its boundary geometry from OSM's Nominatim API. Parameters ---------- query : string or dict query string or structured query dict to geocode/download limit : int max number of results ...
python
def osm_polygon_download(query, limit=1, polygon_geojson=1): """ Geocode a place and download its boundary geometry from OSM's Nominatim API. Parameters ---------- query : string or dict query string or structured query dict to geocode/download limit : int max number of results ...
[ "def", "osm_polygon_download", "(", "query", ",", "limit", "=", "1", ",", "polygon_geojson", "=", "1", ")", ":", "# define the parameters", "params", "=", "OrderedDict", "(", ")", "params", "[", "'format'", "]", "=", "'json'", "params", "[", "'limit'", "]", ...
Geocode a place and download its boundary geometry from OSM's Nominatim API. Parameters ---------- query : string or dict query string or structured query dict to geocode/download limit : int max number of results to return polygon_geojson : int request the boundary geometry...
[ "Geocode", "a", "place", "and", "download", "its", "boundary", "geometry", "from", "OSM", "s", "Nominatim", "API", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L375-L413
train
Geocode a place and download its boundary geometry from OSM s Nominatim API.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
gdf_from_place
def gdf_from_place(query, gdf_name=None, which_result=1, buffer_dist=None): """ Create a GeoDataFrame from a single place name query. Parameters ---------- query : string or dict query string or structured query dict to geocode/download gdf_name : string name attribute metadata ...
python
def gdf_from_place(query, gdf_name=None, which_result=1, buffer_dist=None): """ Create a GeoDataFrame from a single place name query. Parameters ---------- query : string or dict query string or structured query dict to geocode/download gdf_name : string name attribute metadata ...
[ "def", "gdf_from_place", "(", "query", ",", "gdf_name", "=", "None", ",", "which_result", "=", "1", ",", "buffer_dist", "=", "None", ")", ":", "# if no gdf_name is passed, just use the query", "assert", "(", "isinstance", "(", "query", ",", "dict", ")", "or", ...
Create a GeoDataFrame from a single place name query. Parameters ---------- query : string or dict query string or structured query dict to geocode/download gdf_name : string name attribute metadata for GeoDataFrame (this is used to save shapefile later) which_result : int ...
[ "Create", "a", "GeoDataFrame", "from", "a", "single", "place", "name", "query", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L416-L486
train
Create a GeoDataFrame from a single place name query.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
gdf_from_places
def gdf_from_places(queries, gdf_name='unnamed', buffer_dist=None): """ Create a GeoDataFrame from a list of place names to query. Parameters ---------- queries : list list of query strings or structured query dicts to geocode/download, one at a time gdf_name : string na...
python
def gdf_from_places(queries, gdf_name='unnamed', buffer_dist=None): """ Create a GeoDataFrame from a list of place names to query. Parameters ---------- queries : list list of query strings or structured query dicts to geocode/download, one at a time gdf_name : string na...
[ "def", "gdf_from_places", "(", "queries", ",", "gdf_name", "=", "'unnamed'", ",", "buffer_dist", "=", "None", ")", ":", "# create an empty GeoDataFrame then append each result as a new row", "gdf", "=", "gpd", ".", "GeoDataFrame", "(", ")", "for", "query", "in", "qu...
Create a GeoDataFrame from a list of place names to query. Parameters ---------- queries : list list of query strings or structured query dicts to geocode/download, one at a time gdf_name : string name attribute metadata for GeoDataFrame (this is used to save shapefile l...
[ "Create", "a", "GeoDataFrame", "from", "a", "list", "of", "place", "names", "to", "query", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L489-L520
train
Create a GeoDataFrame from a list of query strings or structured query dicts to geocode and download them.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_osm_filter
def get_osm_filter(network_type): """ Create a filter to query OSM for the specified network type. Parameters ---------- network_type : string {'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'} what type of street or other network to get Returns ------...
python
def get_osm_filter(network_type): """ Create a filter to query OSM for the specified network type. Parameters ---------- network_type : string {'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'} what type of street or other network to get Returns ------...
[ "def", "get_osm_filter", "(", "network_type", ")", ":", "filters", "=", "{", "}", "# driving: filter out un-drivable roads, service roads, private ways, and", "# anything specifying motor=no. also filter out any non-service roads that", "# are tagged as providing parking, driveway, private, ...
Create a filter to query OSM for the specified network type. Parameters ---------- network_type : string {'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'} what type of street or other network to get Returns ------- string
[ "Create", "a", "filter", "to", "query", "OSM", "for", "the", "specified", "network", "type", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L523-L585
train
Returns a filter to query OSM for the specified network type.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
osm_net_download
def osm_net_download(polygon=None, north=None, south=None, east=None, west=None, network_type='all_private', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, infrastructure='way["highway"]', custom_filter=None): """ Download OSM ways a...
python
def osm_net_download(polygon=None, north=None, south=None, east=None, west=None, network_type='all_private', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, infrastructure='way["highway"]', custom_filter=None): """ Download OSM ways a...
[ "def", "osm_net_download", "(", "polygon", "=", "None", ",", "north", "=", "None", ",", "south", "=", "None", ",", "east", "=", "None", ",", "west", "=", "None", ",", "network_type", "=", "'all_private'", ",", "timeout", "=", "180", ",", "memory", "=",...
Download OSM ways and nodes within some bounding box from the Overpass API. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the street network within north : float northern latitude of bounding box south : float southern latitude of ...
[ "Download", "OSM", "ways", "and", "nodes", "within", "some", "bounding", "box", "from", "the", "Overpass", "API", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L588-L710
train
Download OSM ways and nodes within some bounding box from Overpass API.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_polygons_coordinates
def get_polygons_coordinates(geometry): """ Extract exterior coordinates from polygon(s) to pass to OSM in a query by polygon. Ignore the interior ("holes") coordinates. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to extract exterior coordinates from ...
python
def get_polygons_coordinates(geometry): """ Extract exterior coordinates from polygon(s) to pass to OSM in a query by polygon. Ignore the interior ("holes") coordinates. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to extract exterior coordinates from ...
[ "def", "get_polygons_coordinates", "(", "geometry", ")", ":", "# extract the exterior coordinates of the geometry to pass to the API later", "polygons_coords", "=", "[", "]", "if", "isinstance", "(", "geometry", ",", "Polygon", ")", ":", "x", ",", "y", "=", "geometry", ...
Extract exterior coordinates from polygon(s) to pass to OSM in a query by polygon. Ignore the interior ("holes") coordinates. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to extract exterior coordinates from Returns ------- polygon_coord_strs : list
[ "Extract", "exterior", "coordinates", "from", "polygon", "(", "s", ")", "to", "pass", "to", "OSM", "in", "a", "query", "by", "polygon", ".", "Ignore", "the", "interior", "(", "holes", ")", "coordinates", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L753-L792
train
Extract exterior coordinates from polygon or multiPolygons and return a list of strings
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_node
def get_node(element): """ Convert an OSM node element into the format for a networkx node. Parameters ---------- element : dict an OSM node element Returns ------- dict """ node = {} node['y'] = element['lat'] node['x'] = element['lon'] node['osmid'] = ele...
python
def get_node(element): """ Convert an OSM node element into the format for a networkx node. Parameters ---------- element : dict an OSM node element Returns ------- dict """ node = {} node['y'] = element['lat'] node['x'] = element['lon'] node['osmid'] = ele...
[ "def", "get_node", "(", "element", ")", ":", "node", "=", "{", "}", "node", "[", "'y'", "]", "=", "element", "[", "'lat'", "]", "node", "[", "'x'", "]", "=", "element", "[", "'lon'", "]", "node", "[", "'osmid'", "]", "=", "element", "[", "'id'", ...
Convert an OSM node element into the format for a networkx node. Parameters ---------- element : dict an OSM node element Returns ------- dict
[ "Convert", "an", "OSM", "node", "element", "into", "the", "format", "for", "a", "networkx", "node", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L795-L817
train
Convert an OSM node element into the format for a networkx node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
get_path
def get_path(element): """ Convert an OSM way element into the format for a networkx graph path. Parameters ---------- element : dict an OSM way element Returns ------- dict """ path = {} path['osmid'] = element['id'] # remove any consecutive duplicate element...
python
def get_path(element): """ Convert an OSM way element into the format for a networkx graph path. Parameters ---------- element : dict an OSM way element Returns ------- dict """ path = {} path['osmid'] = element['id'] # remove any consecutive duplicate element...
[ "def", "get_path", "(", "element", ")", ":", "path", "=", "{", "}", "path", "[", "'osmid'", "]", "=", "element", "[", "'id'", "]", "# remove any consecutive duplicate elements in the list of nodes", "grouped_list", "=", "groupby", "(", "element", "[", "'nodes'", ...
Convert an OSM way element into the format for a networkx graph path. Parameters ---------- element : dict an OSM way element Returns ------- dict
[ "Convert", "an", "OSM", "way", "element", "into", "the", "format", "for", "a", "networkx", "graph", "path", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L820-L845
train
Convert an OSM way element into a networkx graph path.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
parse_osm_nodes_paths
def parse_osm_nodes_paths(osm_data): """ Construct dicts of nodes and paths with key=osmid and value=dict of attributes. Parameters ---------- osm_data : dict JSON response from from the Overpass API Returns ------- nodes, paths : tuple """ nodes = {} paths = {...
python
def parse_osm_nodes_paths(osm_data): """ Construct dicts of nodes and paths with key=osmid and value=dict of attributes. Parameters ---------- osm_data : dict JSON response from from the Overpass API Returns ------- nodes, paths : tuple """ nodes = {} paths = {...
[ "def", "parse_osm_nodes_paths", "(", "osm_data", ")", ":", "nodes", "=", "{", "}", "paths", "=", "{", "}", "for", "element", "in", "osm_data", "[", "'elements'", "]", ":", "if", "element", "[", "'type'", "]", "==", "'node'", ":", "key", "=", "element",...
Construct dicts of nodes and paths with key=osmid and value=dict of attributes. Parameters ---------- osm_data : dict JSON response from from the Overpass API Returns ------- nodes, paths : tuple
[ "Construct", "dicts", "of", "nodes", "and", "paths", "with", "key", "=", "osmid", "and", "value", "=", "dict", "of", "attributes", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L848-L873
train
Parses the Osm nodes and paths from the Overpass API response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
remove_isolated_nodes
def remove_isolated_nodes(G): """ Remove from a graph all the nodes that have no incident edges (ie, node degree = 0). Parameters ---------- G : networkx multidigraph the graph from which to remove nodes Returns ------- networkx multidigraph """ isolated_nodes = [n...
python
def remove_isolated_nodes(G): """ Remove from a graph all the nodes that have no incident edges (ie, node degree = 0). Parameters ---------- G : networkx multidigraph the graph from which to remove nodes Returns ------- networkx multidigraph """ isolated_nodes = [n...
[ "def", "remove_isolated_nodes", "(", "G", ")", ":", "isolated_nodes", "=", "[", "node", "for", "node", ",", "degree", "in", "dict", "(", "G", ".", "degree", "(", ")", ")", ".", "items", "(", ")", "if", "degree", "<", "1", "]", "G", ".", "remove_nod...
Remove from a graph all the nodes that have no incident edges (ie, node degree = 0). Parameters ---------- G : networkx multidigraph the graph from which to remove nodes Returns ------- networkx multidigraph
[ "Remove", "from", "a", "graph", "all", "the", "nodes", "that", "have", "no", "incident", "edges", "(", "ie", "node", "degree", "=", "0", ")", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L876-L894
train
Removes isolated nodes from a networkx multidigraph G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
truncate_graph_dist
def truncate_graph_dist(G, source_node, max_distance=1000, weight='length', retain_all=False): """ Remove everything further than some network distance from a specified node in graph. Parameters ---------- G : networkx multidigraph source_node : int the node in the graph from which ...
python
def truncate_graph_dist(G, source_node, max_distance=1000, weight='length', retain_all=False): """ Remove everything further than some network distance from a specified node in graph. Parameters ---------- G : networkx multidigraph source_node : int the node in the graph from which ...
[ "def", "truncate_graph_dist", "(", "G", ",", "source_node", ",", "max_distance", "=", "1000", ",", "weight", "=", "'length'", ",", "retain_all", "=", "False", ")", ":", "# get the shortest distance between the node and every other node, then", "# remove every node further t...
Remove everything further than some network distance from a specified node in graph. Parameters ---------- G : networkx multidigraph source_node : int the node in the graph from which to measure network distances to other nodes max_distance : int remove every node in the...
[ "Remove", "everything", "further", "than", "some", "network", "distance", "from", "a", "specified", "node", "in", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L897-L937
train
Truncate a networkx graph by weighted network distance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
truncate_graph_bbox
def truncate_graph_bbox(G, north, south, east, west, truncate_by_edge=False, retain_all=False): """ Remove every node in graph that falls outside a bounding box. Needed because overpass returns entire ways that also include nodes outside the bbox if the way (that is, a way with a single OSM ID) has a n...
python
def truncate_graph_bbox(G, north, south, east, west, truncate_by_edge=False, retain_all=False): """ Remove every node in graph that falls outside a bounding box. Needed because overpass returns entire ways that also include nodes outside the bbox if the way (that is, a way with a single OSM ID) has a n...
[ "def", "truncate_graph_bbox", "(", "G", ",", "north", ",", "south", ",", "east", ",", "west", ",", "truncate_by_edge", "=", "False", ",", "retain_all", "=", "False", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "G", "=", "G", ".", "cop...
Remove every node in graph that falls outside a bounding box. Needed because overpass returns entire ways that also include nodes outside the bbox if the way (that is, a way with a single OSM ID) has a node inside the bbox at some point. Parameters ---------- G : networkx multidigraph nort...
[ "Remove", "every", "node", "in", "graph", "that", "falls", "outside", "a", "bounding", "box", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L940-L1007
train
This function truncates a networkx graph by removing every node in graph that falls outside a bounding box.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
quadrat_cut_geometry
def quadrat_cut_geometry(geometry, quadrat_width, min_num=3, buffer_amount=1e-9): """ Split a Polygon or MultiPolygon up into sub-polygons of a specified size, using quadrats. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to split up into smaller sub-poly...
python
def quadrat_cut_geometry(geometry, quadrat_width, min_num=3, buffer_amount=1e-9): """ Split a Polygon or MultiPolygon up into sub-polygons of a specified size, using quadrats. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to split up into smaller sub-poly...
[ "def", "quadrat_cut_geometry", "(", "geometry", ",", "quadrat_width", ",", "min_num", "=", "3", ",", "buffer_amount", "=", "1e-9", ")", ":", "# create n evenly spaced points between the min and max x and y bounds", "west", ",", "south", ",", "east", ",", "north", "=",...
Split a Polygon or MultiPolygon up into sub-polygons of a specified size, using quadrats. Parameters ---------- geometry : shapely Polygon or MultiPolygon the geometry to split up into smaller sub-polygons quadrat_width : numeric the linear width of the quadrats with which to cut up...
[ "Split", "a", "Polygon", "or", "MultiPolygon", "up", "into", "sub", "-", "polygons", "of", "a", "specified", "size", "using", "quadrats", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1010-L1052
train
Splits a shapely Polygon or MultiPolygon into smaller sub - polygons of a specified size and buffer them into smaller quadrats.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
intersect_index_quadrats
def intersect_index_quadrats(gdf, geometry, quadrat_width=0.05, min_num=3, buffer_amount=1e-9): """ Intersect points with a polygon, using an r-tree spatial index and cutting the polygon up into smaller sub-polygons for r-tree acceleration. Parameters ---------- gdf : GeoDataFrame the s...
python
def intersect_index_quadrats(gdf, geometry, quadrat_width=0.05, min_num=3, buffer_amount=1e-9): """ Intersect points with a polygon, using an r-tree spatial index and cutting the polygon up into smaller sub-polygons for r-tree acceleration. Parameters ---------- gdf : GeoDataFrame the s...
[ "def", "intersect_index_quadrats", "(", "gdf", ",", "geometry", ",", "quadrat_width", "=", "0.05", ",", "min_num", "=", "3", ",", "buffer_amount", "=", "1e-9", ")", ":", "# create an empty dataframe to append matches to", "points_within_geometry", "=", "pd", ".", "D...
Intersect points with a polygon, using an r-tree spatial index and cutting the polygon up into smaller sub-polygons for r-tree acceleration. Parameters ---------- gdf : GeoDataFrame the set of points to intersect geometry : shapely Polygon or MultiPolygon the geometry to intersect w...
[ "Intersect", "points", "with", "a", "polygon", "using", "an", "r", "-", "tree", "spatial", "index", "and", "cutting", "the", "polygon", "up", "into", "smaller", "sub", "-", "polygons", "for", "r", "-", "tree", "acceleration", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1055-L1121
train
Intersects points with a polygon using an r - tree spatial index and cutting the polygon up into smaller sub - polygons for r - tree acceleration
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
truncate_graph_polygon
def truncate_graph_polygon(G, polygon, retain_all=False, truncate_by_edge=False, quadrat_width=0.05, min_num=3, buffer_amount=1e-9): """ Remove every node in graph that falls outside some shapely Polygon or MultiPolygon. Parameters ---------- G : networkx multidigraph polygon : Polygon or M...
python
def truncate_graph_polygon(G, polygon, retain_all=False, truncate_by_edge=False, quadrat_width=0.05, min_num=3, buffer_amount=1e-9): """ Remove every node in graph that falls outside some shapely Polygon or MultiPolygon. Parameters ---------- G : networkx multidigraph polygon : Polygon or M...
[ "def", "truncate_graph_polygon", "(", "G", ",", "polygon", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ",", "quadrat_width", "=", "0.05", ",", "min_num", "=", "3", ",", "buffer_amount", "=", "1e-9", ")", ":", "start_time", "=", ...
Remove every node in graph that falls outside some shapely Polygon or MultiPolygon. Parameters ---------- G : networkx multidigraph polygon : Polygon or MultiPolygon only retain nodes in graph that lie within this geometry retain_all : bool if True, return the entire graph even ...
[ "Remove", "every", "node", "in", "graph", "that", "falls", "outside", "some", "shapely", "Polygon", "or", "MultiPolygon", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1124-L1180
train
Removes every node in graph that lie outside the polygon or MultiPolygon.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
add_edge_lengths
def add_edge_lengths(G): """ Add length (meters) attribute to each edge by great circle distance between nodes u and v. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph """ start_time = time.time() # first load all the edges' o...
python
def add_edge_lengths(G): """ Add length (meters) attribute to each edge by great circle distance between nodes u and v. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph """ start_time = time.time() # first load all the edges' o...
[ "def", "add_edge_lengths", "(", "G", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "# first load all the edges' origin and destination coordinates as a", "# dataframe indexed by u, v, key", "coords", "=", "np", ".", "array", "(", "[", "[", "u", ",", "v...
Add length (meters) attribute to each edge by great circle distance between nodes u and v. Parameters ---------- G : networkx multidigraph Returns ------- G : networkx multidigraph
[ "Add", "length", "(", "meters", ")", "attribute", "to", "each", "edge", "by", "great", "circle", "distance", "between", "nodes", "u", "and", "v", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1183-L1217
train
Adds length attribute to each edge in the graph G by great circle distance between nodes u and v.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
add_path
def add_path(G, data, one_way): """ Add a path to the graph. Parameters ---------- G : networkx multidigraph data : dict the attributes of the path one_way : bool if this path is one-way or if it is bi-directional Returns ------- None """ # extract the ...
python
def add_path(G, data, one_way): """ Add a path to the graph. Parameters ---------- G : networkx multidigraph data : dict the attributes of the path one_way : bool if this path is one-way or if it is bi-directional Returns ------- None """ # extract the ...
[ "def", "add_path", "(", "G", ",", "data", ",", "one_way", ")", ":", "# extract the ordered list of nodes from this path element, then delete it", "# so we don't add it as an attribute to the edge later", "path_nodes", "=", "data", "[", "'nodes'", "]", "del", "data", "[", "'...
Add a path to the graph. Parameters ---------- G : networkx multidigraph data : dict the attributes of the path one_way : bool if this path is one-way or if it is bi-directional Returns ------- None
[ "Add", "a", "path", "to", "the", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1220-L1256
train
Adds a path to the multidigraph G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...