Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate the scatter method of BaseGridder (#357)
The method is a bit useless since we rarely want to predict on random points. Copy the code to the `CheckerBoard` function since that's where it is most useful. Issue a `FutureWarning` from the base `scatter` method.
- Loading branch information
Showing
5 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2017 The Verde Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# This code is part of the Fatiando a Terra project (https://www.fatiando.org) | ||
# | ||
""" | ||
Test the synthetic data generation functions and classes. | ||
""" | ||
import numpy.testing as npt | ||
|
||
from ..synthetic import CheckerBoard | ||
|
||
|
||
def test_checkerboard_scatter_projection(): | ||
"Test generating scattered points when passing in a projection" | ||
|
||
# Lets say the projection is doubling the coordinates | ||
def proj(lon, lat, inverse=False): | ||
"Project from the new coordinates to the original" | ||
if inverse: | ||
return (lon / 2, lat / 2) | ||
return (lon * 2, lat * 2) | ||
|
||
region = (0, 10, -10, -5) | ||
region_proj = (0, 5, -5, -2.5) | ||
checker = CheckerBoard(region=region) | ||
checker_proj = CheckerBoard(region=region_proj) | ||
scatter = checker.scatter(region, 1000, random_state=0, projection=proj) | ||
scatter_proj = checker_proj.scatter(region, 1000, random_state=0) | ||
npt.assert_allclose(scatter.scalars, scatter_proj.scalars) | ||
npt.assert_allclose(scatter.easting, scatter_proj.easting) | ||
npt.assert_allclose(scatter.northing, scatter_proj.northing) |