diff --git a/cityseer/algos/centrality.py b/cityseer/algos/centrality.py index 705fa407..9b9b2c99 100644 --- a/cityseer/algos/centrality.py +++ b/cityseer/algos/centrality.py @@ -15,7 +15,7 @@ def shortest_path_tree(edge_data: np.ndarray, node_edge_map: Dict, src_idx: int, max_dist: float = np.inf, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False) -> Tuple[np.ndarray, np.ndarray]: """ All shortest paths to max network distance from source node @@ -139,7 +139,7 @@ def shortest_path_tree(edge_data: np.ndarray, # this will also happen for the first nodes that overshoot the boundary # they will not be explored further because they have not been added to active # jitter injects a small amount of stochasticity for rectlinear grids - jitter = np.random.normal(loc=0, scale=jitter_sdev) + jitter = np.random.normal(loc=0, scale=jitter_scale) # shortest path heuristic differs for angular vs. not if (angular and simpl_dist + jitter < tree_simpl_dist[nb_nd_idx]) or \ (not angular and short_dist + jitter < tree_short_dist[nb_nd_idx]): @@ -255,7 +255,7 @@ def local_node_centrality(node_data: np.ndarray, distances: np.ndarray, betas: np.ndarray, measure_keys: tuple, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False, progress_proxy=None) -> np.ndarray: # integrity checks @@ -344,7 +344,7 @@ def local_node_centrality(node_data: np.ndarray, node_edge_map, src_idx, max_dist=global_max_dist, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular) tree_nodes = np.where(tree_map[:, 0])[0] tree_preds = tree_map[:, 1] @@ -437,7 +437,7 @@ def local_segment_centrality(node_data: np.ndarray, distances: np.ndarray, betas: np.ndarray, measure_keys: tuple, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False, progress_proxy=None) -> np.ndarray: # integrity checks @@ -516,7 +516,7 @@ def local_segment_centrality(node_data: np.ndarray, node_edge_map, src_idx, max_dist=global_max_dist, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular) tree_nodes = np.where(tree_map[:, 0])[0] tree_preds = tree_map[:, 1] diff --git a/cityseer/algos/data.py b/cityseer/algos/data.py index 286a7df0..f4efde1e 100644 --- a/cityseer/algos/data.py +++ b/cityseer/algos/data.py @@ -291,7 +291,7 @@ def aggregate_to_src_idx(netw_src_idx: int, node_edge_map: Dict, data_map: np.ndarray, max_dist: float, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False): # this function is typically called iteratively, so do type checks from parent methods netw_x_arr = node_data[:, 0] @@ -311,7 +311,7 @@ def aggregate_to_src_idx(netw_src_idx: int, node_edge_map, netw_src_idx, max_dist=max_dist, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular) ''' Shortest tree dijkstra @@ -380,7 +380,7 @@ def aggregate_landuses(node_data: np.ndarray, mixed_use_other_keys: np.ndarray = np.array([]), accessibility_keys: np.ndarray = np.array([]), cl_disparity_wt_matrix: np.ndarray = np.array(np.full((0, 0), np.nan)), - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False, progress_proxy=None) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: """ @@ -498,7 +498,7 @@ def disp_check(disp_matrix): node_edge_map, data_map, global_max_dist, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular) # LANDUSES mu_max_unique_cl = int(landuse_encodings.max() + 1) @@ -587,7 +587,7 @@ def aggregate_stats(node_data: np.ndarray, distances: np.ndarray, betas: np.ndarray, numerical_arrays: np.ndarray = np.array(np.full((0, 0), np.nan)), - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False, progress_proxy=None) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]: @@ -655,7 +655,7 @@ def aggregate_stats(node_data: np.ndarray, node_edge_map, data_map, global_max_dist, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular) # IDW # the order of the loops matters because the nested aggregations happen per distance per numerical array diff --git a/cityseer/metrics/layers.py b/cityseer/metrics/layers.py index 9cf6d228..b735ca18 100644 --- a/cityseer/metrics/layers.py +++ b/cityseer/metrics/layers.py @@ -368,7 +368,7 @@ def compute_landuses(self, accessibility_keys: list | tuple = None, cl_disparity_wt_matrix: list | tuple | np.ndarray = None, qs: list | tuple | np.ndarray = None, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False): """ This method wraps the underlying `numba` optimised functions for aggregating and computing various mixed-use and @@ -464,6 +464,9 @@ def compute_landuses(self, qs The values of `q` for which to compute Hill diversity. This parameter is only required if computing one of the Hill diversity mixed-use measures, by default None. + jitter_scale + The scale of random jitter to add to shortest path calculations, useful for situations with highly + rectilinear grids. `jitter_scale` is passed to the `scale` parameter of `np.random.normal`. Default of zero. angular Whether to use a simplest-path heuristic in-lieu of a shortest-path heuristic when calculating aggregations and distances, by default False @@ -648,7 +651,7 @@ def compute_landuses(self, mixed_use_other_keys=np.array(mu_other_keys), accessibility_keys=np.array(acc_keys), cl_disparity_wt_matrix=np.array(cl_disparity_wt_matrix), - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular, progress_proxy=progress_proxy) if progress_proxy is not None: @@ -760,7 +763,7 @@ def compute_stats(self, stats_data_arrs: list | tuple | np.ndarray | list[list | tuple | np.ndarray] | tuple[list | tuple | np.ndarray], - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False): """ This method wraps the underlying `numba` optimised functions for computing statistical measures. The data is @@ -837,6 +840,9 @@ def compute_stats(self, [420, 300, 220, 250, 600] # occupants ] ``` + jitter_scale + The scale of random jitter to add to shortest path calculations, useful for situations with highly + rectilinear grids. `jitter_scale` is passed to the `scale` parameter of `np.random.normal`. Default of zero. angular Whether to use a simplest-path heuristic in-lieu of a shortest-path heuristic when calculating aggregations and distances, by default False @@ -932,7 +938,7 @@ def compute_stats(self, distances=np.array(self.Network.distances), betas=np.array(self.Network.betas), numerical_arrays=stats_data_arrs, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular, progress_proxy=progress_proxy) if progress_proxy is not None: diff --git a/cityseer/metrics/networks.py b/cityseer/metrics/networks.py index 145d42ca..035653f5 100644 --- a/cityseer/metrics/networks.py +++ b/cityseer/metrics/networks.py @@ -736,7 +736,7 @@ def compute_centrality(self, **kwargs): # provides access to the underlying centrality.local_centrality method def node_centrality(self, measures: list | tuple = None, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False): """ Parameters @@ -744,9 +744,9 @@ def node_centrality(self, measures A list or tuple of strings, containing any combination of the following `key` values, computed within the respective distance thresholds of $d_{max}$. - jitter_sdev - The standard deviation for the amount of random jitter to add to shortest path calculations, useful for - situations with highly rectilinear grids. Set to zero to remove all jitter. + jitter_scale + The scale of random jitter to add to shortest path calculations, useful for situations with highly + rectilinear grids. `jitter_scale` is passed to the `scale` parameter of `np.random.normal`. Default of zero. angular A boolean indicating whether to use shortest or simplest path heuristics, by default False @@ -827,7 +827,7 @@ def node_centrality(self, np.array(self._distances), np.array(self._betas), measure_keys, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular, progress_proxy=progress_proxy) if progress_proxy is not None: @@ -844,7 +844,7 @@ def node_centrality(self, # provides access to the underlying centrality.local_centrality method def segment_centrality(self, measures: list | tuple = None, - jitter_sdev: float = 1.0, + jitter_scale: float = 0.0, angular: bool = False): """ A list or tuple of strings, containing any combination of the following `key` values, computed within the @@ -855,9 +855,9 @@ def segment_centrality(self, measures A list or tuple of strings, containing any combination of the following `key` values, computed within the respective distance thresholds of $d_{max}$. - jitter_sdev - The standard deviation for the amount of random jitter to add to shortest path calculations, useful for - situations with highly rectilinear grids. Set to zero to remove all jitter. + jitter_scale + The scale of random jitter to add to shortest path calculations, useful for situations with highly + rectilinear grids. `jitter_scale` is passed to the `scale` parameter of `np.random.normal`. Default of zero. angular A boolean indicating whether to use shortest or simplest path heuristics, by default False @@ -925,7 +925,7 @@ def segment_centrality(self, np.array(self._distances), np.array(self._betas), measure_keys, - jitter_sdev=jitter_sdev, + jitter_scale=jitter_scale, angular=angular, progress_proxy=progress_proxy) if progress_proxy is not None: diff --git a/setup.py b/setup.py index 30138bce..1ab435f5 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='cityseer', - version='1.1.7', + version='1.2.0', packages=['cityseer', 'cityseer.algos', 'cityseer.metrics', 'cityseer.tools'], description='Computational tools for urban analysis', url='https://github.com/benchmark-urbanism/cityseer-api', diff --git a/tests/algos/test_centrality.py b/tests/algos/test_centrality.py index 904cbfce..e0031a72 100644 --- a/tests/algos/test_centrality.py +++ b/tests/algos/test_centrality.py @@ -40,7 +40,6 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_p, src_idx, max_dist=max_dist, - jitter_sdev=0, angular=False) tree_preds_p = tree_map[:, 1] tree_short_dists_p = tree_map[:, 2] @@ -67,14 +66,12 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_p, p_source_idx, max_dist=max_dist, - jitter_sdev=0, angular=True) tree_simpl_dists_p = tree_map_p[:, 3] tree_map_d, tree_edges_d = centrality.shortest_path_tree(edge_data_d, node_edge_map_d, d_source_idx, max_dist=max_dist, - jitter_sdev=0, angular=True) tree_simpl_dists_d = tree_map_d[:, 3] assert np.allclose(tree_simpl_dists_p[p_target_idx], tree_simpl_dists_d[d_target_idx], atol=0.001, rtol=0) @@ -87,7 +84,6 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_d, src_idx, max_dist=np.inf, - jitter_sdev=0, angular=True) # ANGULAR = TRUE # find path tree_preds = tree_map[:, 1] @@ -102,7 +98,6 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_d, src_idx, max_dist=np.inf, - jitter_sdev=0, angular=False) # ANGULAR = FALSE # find path tree_preds = tree_map[:, 1] @@ -119,7 +114,6 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_d, src_idx, max_dist=np.inf, - jitter_sdev=0, angular=True) # find path tree_preds = tree_map[:, 1] @@ -137,7 +131,6 @@ def test_shortest_path_tree(primal_graph, dual_graph): node_edge_map_d, src_idx, max_dist=np.inf, - jitter_sdev=0, angular=False) # find path tree_preds = tree_map[:, 1] @@ -178,8 +171,7 @@ def test_local_node_centrality(primal_graph): node_edge_map, distances, betas, - measure_keys, - jitter_sdev=0) + measure_keys) node_density = measures_data[measure_keys.index('node_density')] node_farness = measures_data[measure_keys.index('node_farness')] node_cycles = measures_data[measure_keys.index('node_cycles')] @@ -235,7 +227,6 @@ def test_local_node_centrality(primal_graph): node_edge_map, src_idx, max(distances), - jitter_sdev=0, angular=False) tree_nodes = np.where(tree_map[:, 0])[0] tree_preds = tree_map[:, 1] @@ -302,8 +293,7 @@ def test_local_node_centrality(primal_graph): node_edge_map, distances, betas, - ('typo_key',), - jitter_sdev=0) + ('typo_key',)) def test_local_centrality(diamond_graph): @@ -338,8 +328,7 @@ def test_local_centrality(diamond_graph): node_edge_map, distances, betas, - measure_keys, - jitter_sdev=0) + measure_keys) # node density # additive nodes m_idx = node_keys.index('node_density') @@ -402,7 +391,6 @@ def test_local_centrality(diamond_graph): distances, betas, measure_keys, - jitter_sdev=0, angular=True) # node harmonic angular # additive 1 / (1 + (to_imp / 180)) @@ -430,7 +418,6 @@ def test_local_centrality(diamond_graph): distances, betas, measure_keys, - jitter_sdev=0, angular=True) # node_uids_dual = ('0_1', '0_2', '1_2', '1_3', '2_3') # node harmonic angular @@ -461,7 +448,6 @@ def test_local_centrality(diamond_graph): distances, betas, measure_keys, - jitter_sdev=0, angular=False) # segment density # additive segment lengths @@ -508,7 +494,6 @@ def test_local_centrality(diamond_graph): distances, betas, measure_keys, - jitter_sdev=0, angular=True) # segment density # additive segment lengths divided through angular impedance @@ -559,7 +544,6 @@ def test_decomposed_local_centrality(primal_graph): distances, betas, node_measure_keys, - jitter_sdev=0, angular=False) # decomposed case node_measures_data_decomposed = centrality.local_node_centrality(node_data_decomp, @@ -568,7 +552,6 @@ def test_decomposed_local_centrality(primal_graph): distances, betas, node_measure_keys, - jitter_sdev=0, angular=False) # node d_range = len(distances) @@ -586,7 +569,6 @@ def test_decomposed_local_centrality(primal_graph): distances, betas, segment_measure_keys, - jitter_sdev=0, angular=False) segment_measures_data_decomposed = centrality.local_segment_centrality(node_data_decomp, edge_data_decomp, @@ -594,7 +576,6 @@ def test_decomposed_local_centrality(primal_graph): distances, betas, segment_measure_keys, - jitter_sdev=0, angular=False) m_range = len(segment_measure_keys) assert segment_measures_data.shape == (m_range, d_range, len(primal_graph)) @@ -653,7 +634,6 @@ def node_cent_wrapper(): distances, betas, ('node_harmonic', 'node_betweenness'), - jitter_sdev=0, angular=False, progress_proxy=None) # prime the function @@ -671,7 +651,6 @@ def segment_cent_wrapper(): distances, betas, ('segment_harmonic', 'segment_betweenness'), - jitter_sdev=0, angular=False, progress_proxy=None) # prime the function diff --git a/tests/algos/test_checks.py b/tests/algos/test_checks.py index 0132f453..bbcfe286 100644 --- a/tests/algos/test_checks.py +++ b/tests/algos/test_checks.py @@ -7,12 +7,6 @@ from cityseer.tools.mock import primal_graph -def test_progress_bar(): - for n in [1, 11, 27, 101, 271, 5521]: - for i in range(n + 1): - checks.progress_bar(i, n) - - def test_check_numerical_data(): mock_numerical = mock.mock_numerical_data(50) diff --git a/tests/algos/test_data.py b/tests/algos/test_data.py index cef321ce..3ecb545a 100644 --- a/tests/algos/test_data.py +++ b/tests/algos/test_data.py @@ -156,7 +156,6 @@ def test_aggregate_to_src_idx(primal_graph): node_edge_map, data_map_temp, max_dist, - jitter_sdev=0, angular=angular) # for debugging # from cityseer.tools import plot @@ -171,7 +170,6 @@ def test_aggregate_to_src_idx(primal_graph): node_edge_map, netw_src_idx, max_dist=max_dist, - jitter_sdev=0, angular=angular) tree_dists = tree_map[:, 2] # verify distances vs. the max @@ -241,8 +239,7 @@ def test_aggregate_landuses_signatures(primal_graph): data_map, distances, betas, - mixed_use_hill_keys=np.array([0]), - jitter_sdev=0) + mixed_use_hill_keys=np.array([0])) # check that unequal land_use encodings vs data map lengths are caught with pytest.raises(ValueError): data.aggregate_landuses(node_data, @@ -252,8 +249,7 @@ def test_aggregate_landuses_signatures(primal_graph): distances, betas, landuse_encodings=landuse_encodings[:-1], - mixed_use_other_keys=np.array([0]), - jitter_sdev=0) + mixed_use_other_keys=np.array([0])) # check that no provided metrics flags with pytest.raises(ValueError): data.aggregate_landuses(node_data, @@ -262,8 +258,7 @@ def test_aggregate_landuses_signatures(primal_graph): data_map, distances, betas, - landuse_encodings=landuse_encodings, - jitter_sdev=0) + landuse_encodings=landuse_encodings) # check that missing qs flags with pytest.raises(ValueError): data.aggregate_landuses(node_data, @@ -273,8 +268,7 @@ def test_aggregate_landuses_signatures(primal_graph): distances, betas, mixed_use_hill_keys=np.array([0]), - landuse_encodings=landuse_encodings, - jitter_sdev=0) + landuse_encodings=landuse_encodings) # check that problematic mixed use and accessibility keys are caught for mu_h_key, mu_o_key, ac_key in [ # negatives @@ -300,8 +294,7 @@ def test_aggregate_landuses_signatures(primal_graph): qs=qs, mixed_use_hill_keys=np.array(mu_h_key), mixed_use_other_keys=np.array(mu_o_key), - accessibility_keys=np.array(ac_key), - jitter_sdev=0) + accessibility_keys=np.array(ac_key)) for h_key, o_key in (([3], []), ([], [2])): # check that missing matrix is caught for disparity weighted indices with pytest.raises(ValueError): @@ -314,8 +307,7 @@ def test_aggregate_landuses_signatures(primal_graph): landuse_encodings=landuse_encodings, qs=qs, mixed_use_hill_keys=np.array(h_key), - mixed_use_other_keys=np.array(o_key), - jitter_sdev=0) + mixed_use_other_keys=np.array(o_key)) # check that non-square disparity matrix is caught mock_matrix = np.full((len(landuse_classes), len(landuse_classes)), 1) with pytest.raises(ValueError): @@ -329,8 +321,7 @@ def test_aggregate_landuses_signatures(primal_graph): qs=qs, mixed_use_hill_keys=np.array(h_key), mixed_use_other_keys=np.array(o_key), - cl_disparity_wt_matrix=mock_matrix[:-1], - jitter_sdev=0) + cl_disparity_wt_matrix=mock_matrix[:-1]) def test_aggregate_landuses_categorical_components(primal_graph): @@ -367,7 +358,6 @@ def test_aggregate_landuses_categorical_components(primal_graph): mixed_use_other_keys=non_hill_keys, accessibility_keys=ac_keys, cl_disparity_wt_matrix=mock_matrix, - jitter_sdev=0, angular=False) # hill hill = mu_data_hill[np.where(hill_keys == 0)][0] @@ -398,8 +388,7 @@ def test_aggregate_landuses_categorical_components(primal_graph): edge_data, node_edge_map, data_map, - dist_cutoff, - jitter_sdev=0) + dist_cutoff) # counts of each class type (array length per max unique classes - not just those within max distance) cl_counts = np.full(mu_max_unique, 0) # nearest of each class type (likewise) @@ -497,7 +486,6 @@ def test_aggregate_landuses_categorical_components(primal_graph): mixed_use_other_keys=non_hill_keys, accessibility_keys=ac_keys, cl_disparity_wt_matrix=mock_matrix, - jitter_sdev=0, angular=True) mu_hill_dual_sidestep, mu_other_dual_sidestep, ac_dual_sidestep, ac_wt_dual_sidestep = \ @@ -513,7 +501,6 @@ def test_aggregate_landuses_categorical_components(primal_graph): mixed_use_other_keys=non_hill_keys, accessibility_keys=ac_keys, cl_disparity_wt_matrix=mock_matrix, - jitter_sdev=0, angular=False) assert not np.allclose(mu_hill_dual, mu_hill_dual_sidestep, atol=0.001, rtol=0) @@ -545,7 +532,6 @@ def test_local_aggregator_numerical_components(primal_graph): distances, betas, numerical_arrays=mock_numerical, - jitter_sdev=0, angular=False) # non connected portions of the graph will have different stats # used manual data plots from test_assign_to_network() to see which nodes the data points are assigned to @@ -645,7 +631,6 @@ def landuse_agg_wrapper(): mixed_use_hill_keys=np.array([0, 1]), landuse_encodings=landuse_encodings, qs=qs, - jitter_sdev=0, angular=False) # prime the function @@ -665,7 +650,6 @@ def stats_agg_wrapper(): distances, betas, numerical_arrays=mock_numerical, - jitter_sdev=0, angular=False) # prime the function diff --git a/tests/metrics/test_layers.py b/tests/metrics/test_layers.py index ae6d96c3..fa7f4fcd 100644 --- a/tests/metrics/test_layers.py +++ b/tests/metrics/test_layers.py @@ -131,8 +131,7 @@ def test_compute_landuses(primal_graph): betas, landuse_encodings, qs=qs, - mixed_use_hill_keys=np.array([1]), - jitter_sdev=0) + mixed_use_hill_keys=np.array([1])) for q_idx, q_key in enumerate(qs): for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['mixed_uses']['hill_branch_wt'][q_key][d_key], @@ -148,8 +147,7 @@ def test_compute_landuses(primal_graph): distances, betas, landuse_encodings, - mixed_use_other_keys=np.array([1]), - jitter_sdev=0) + mixed_use_other_keys=np.array([1])) for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['mixed_uses']['gini_simpson'][d_key], mu_data_other[0][d_idx], atol=0.001, rtol=0) # accessibilities @@ -164,8 +162,7 @@ def test_compute_landuses(primal_graph): betas, landuse_encodings, accessibility_keys=np.array( - [landuse_classes.index('c')]), - jitter_sdev=0) + [landuse_classes.index('c')])) for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['accessibility']['non_weighted']['c'][d_key], ac_data[0][d_idx], atol=0.001, rtol=0) @@ -214,19 +211,19 @@ def test_compute_landuses(primal_graph): cl_disparity_wt_matrix=mock_disparity_wt_matrix, qs=qs) # test against underlying method - mu_data_hill, mu_data_other, ac_data, ac_data_wt = data.aggregate_landuses(node_map, - edge_map, - node_edge_map, - data_map, - distances, - betas, - landuse_encodings, - qs=qs, - mixed_use_hill_keys=mu_h_keys, - mixed_use_other_keys=mu_o_keys, - accessibility_keys=ac_keys, - cl_disparity_wt_matrix=mock_disparity_wt_matrix, - jitter_sdev=0) + mu_data_hill, mu_data_other, ac_data, ac_data_wt = \ + data.aggregate_landuses(node_map, + edge_map, + node_edge_map, + data_map, + distances, + betas, + landuse_encodings, + qs=qs, + mixed_use_hill_keys=mu_h_keys, + mixed_use_other_keys=mu_o_keys, + accessibility_keys=ac_keys, + cl_disparity_wt_matrix=mock_disparity_wt_matrix) for mu_h_idx, mu_h_met in enumerate(mu_h_metrics): for q_idx, q_key in enumerate(qs): for d_idx, d_key in enumerate(distances): @@ -349,14 +346,11 @@ def test_compute_stats(primal_graph): mock_numeric = mock.mock_numerical_data(len(data_dict), num_arrs=2) # generate stats D_single.compute_stats(stats_keys='boo', - stats_data_arrs=mock_numeric[0], - jitter_sdev=0) + stats_data_arrs=mock_numeric[0]) D_single.compute_stats(stats_keys='baa', - stats_data_arrs=mock_numeric[1], - jitter_sdev=0) + stats_data_arrs=mock_numeric[1]) D_multi.compute_stats(stats_keys=['boo', 'baa'], - stats_data_arrs=mock_numeric, - jitter_sdev=0) + stats_data_arrs=mock_numeric) # test against underlying method data_map = D_single._data stats_sum, stats_sum_wt, stats_mean, stats_mean_wt, stats_variance, stats_variance_wt, stats_max, stats_min = \ @@ -366,8 +360,7 @@ def test_compute_stats(primal_graph): data_map, distances, betas, - numerical_arrays=mock_numeric, - jitter_sdev=0) + numerical_arrays=mock_numeric) stats_keys = ['max', 'min', 'sum', 'sum_weighted', 'mean', 'mean_weighted', 'variance', 'variance_weighted'] stats_data = [stats_max, stats_min, stats_sum, stats_sum_wt, diff --git a/tests/metrics/test_networks.py b/tests/metrics/test_networks.py index a4cedff5..e7f19da5 100644 --- a/tests/metrics/test_networks.py +++ b/tests/metrics/test_networks.py @@ -256,8 +256,7 @@ def test_metrics_to_dict(primal_graph): dict_check(metrics_dict, N) # check with centrality metrics - N.node_centrality(measures=['node_harmonic'], - jitter_sdev=0) + N.node_centrality(measures=['node_harmonic']) metrics_dict = N.metrics_to_dict() dict_check(metrics_dict, N) @@ -295,8 +294,7 @@ def test_to_networkX(primal_graph): # test with metrics N = networks.NetworkLayerFromNX(G, distances=[500]) - N.node_centrality(measures=['node_harmonic'], - jitter_sdev=0) + N.node_centrality(measures=['node_harmonic']) metrics_dict = N.metrics_to_dict() G_round_trip = N.to_networkX() for n, d in G.nodes(data=True): @@ -339,16 +337,14 @@ def test_compute_centrality(primal_graph): # check measures against underlying method N = networks.NetworkLayerFromNX(primal_graph, distances=distances) - N.node_centrality(measures=['node_density'], - jitter_sdev=0) + N.node_centrality(measures=['node_density']) # test against underlying method measures_data = centrality.local_node_centrality(node_data, edge_data, node_edge_map, distances, betas, - measure_keys=('node_density',), - jitter_sdev=0) + measure_keys=('node_density',)) for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['centrality']['node_density'][d_key], measures_data[0][d_idx]) # also check the number of returned types for a few assortments of metrics @@ -357,16 +353,14 @@ def test_compute_centrality(primal_graph): for min_idx in range(3): measure_keys = np.array(node_measures[min_idx:]) N = networks.NetworkLayerFromNX(primal_graph, distances=distances) - N.node_centrality(measures=node_measures, - jitter_sdev=0) + N.node_centrality(measures=node_measures) # test against underlying method measures_data = centrality.local_node_centrality(node_data, edge_data, node_edge_map, distances, betas, - measure_keys=tuple(measure_keys), - jitter_sdev=0) + measure_keys=tuple(measure_keys)) for m_idx, measure_name in enumerate(measure_keys): for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['centrality'][measure_name][d_key], @@ -374,11 +368,9 @@ def test_compute_centrality(primal_graph): # check that angular gets passed through N_ang = networks.NetworkLayerFromNX(primal_graph, distances=[2000]) N_ang.node_centrality(measures=['node_harmonic_angular'], - jitter_sdev=0, angular=True) N = networks.NetworkLayerFromNX(primal_graph, distances=[2000]) N.node_centrality(measures=['node_harmonic'], - jitter_sdev=0, angular=False) assert not np.allclose(N_ang.metrics['centrality']['node_harmonic_angular'][2000], N.metrics['centrality']['node_harmonic'][2000], atol=0.001, rtol=0) @@ -402,16 +394,14 @@ def test_compute_centrality(primal_graph): # check measures against underlying method N = networks.NetworkLayerFromNX(primal_graph, distances=distances) - N.segment_centrality(measures=['segment_density'], - jitter_sdev=0) + N.segment_centrality(measures=['segment_density']) # test against underlying method measures_data = centrality.local_segment_centrality(node_data, edge_data, node_edge_map, distances, betas, - measure_keys=('segment_density',), - jitter_sdev=0) + measure_keys=('segment_density',)) for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['centrality']['segment_density'][d_key], measures_data[0][d_idx]) # also check the number of returned types for a few assortments of metrics @@ -421,16 +411,14 @@ def test_compute_centrality(primal_graph): measure_keys = np.array(segment_measures[min_idx:]) N = networks.NetworkLayerFromNX(primal_graph, distances=distances) - N.segment_centrality(measures=segment_measures, - jitter_sdev=0) + N.segment_centrality(measures=segment_measures) # test against underlying method measures_data = centrality.local_segment_centrality(node_data, edge_data, node_edge_map, distances, betas, - measure_keys=tuple(measure_keys), - jitter_sdev=0) + measure_keys=tuple(measure_keys)) for m_idx, measure_name in enumerate(measure_keys): for d_idx, d_key in enumerate(distances): assert np.allclose(N.metrics['centrality'][measure_name][d_key], @@ -438,11 +426,9 @@ def test_compute_centrality(primal_graph): # check that angular gets passed through N_ang = networks.NetworkLayerFromNX(primal_graph, distances=[2000]) N_ang.segment_centrality(measures=['segment_harmonic_hybrid'], - jitter_sdev=0, angular=True) N = networks.NetworkLayerFromNX(primal_graph, distances=[2000]) N.segment_centrality(measures=['segment_harmonic'], - jitter_sdev=0, angular=False) assert not np.allclose(N_ang.metrics['centrality']['segment_harmonic_hybrid'][2000], N.metrics['centrality']['segment_harmonic'][2000], atol=0.001, rtol=0)