Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in the test_prims_layer #344

Open
aguspesce opened this issue Aug 25, 2022 · 1 comment
Open

Error in the test_prims_layer #344

aguspesce opened this issue Aug 25, 2022 · 1 comment

Comments

@aguspesce
Copy link
Member

I'm making the tesseroid_layer test and reading the test_prims_leyer.
So, I think that I noted an error when check if a layer of prisms is property constructed in line 96.
The original line is:

expected_top[1, 1], expected_bottom[1, 1] = reference, surface[1, 1]

But I think that it should be:

expected_top[1, 1], expected_bottom[1, 1] = reference[1, 1], surface[1, 1]

@santisoler... am I right?

@aguspesce aguspesce added the bug Report a problem that needs to be fixed label Aug 25, 2022
@santisoler
Copy link
Member

Thanks for opening this issue @aguspesce.

For the record, you are talking about this line:

expected_top[1, 1], expected_bottom[1, 1] = reference, surface[1, 1]

The reference variable is defined in line 82:

(easting, northing), surface, reference, _ = dummy_layer

And the dummy_layer is the return of the dummy_layer fixture:

@pytest.fixture(params=("numpy", "xarray"))
def dummy_layer(request):
"""
Generate dummy arrays for defining prism layers
"""
easting = np.linspace(-1, 3, 5)
northing = np.linspace(7, 13, 4)
shape = (northing.size, easting.size)
reference = 0
surface = np.arange(20, dtype=float).reshape(*shape)
density = 2670 * np.ones(shape)
if request.param == "xarray":
easting = xr.DataArray(easting, dims=("easting",))
northing = xr.DataArray(northing, dims=("northing",))
reference, surface = xr.DataArray(reference), xr.DataArray(surface)
density = xr.DataArray(density)
return (easting, northing), surface, reference, density

As you can see, the reference variable is either a float or an xarray.DataArray with a single value, so line 96 is actually ok. If I would made your proposed change, I would get an error because the float doesn't have a [1, 1] element, it cannot be indexed.

Maybe defining the reference as an xarray.DataArray with a single value is confusing and misleading. We could change that if that's make the tests more readable.


Since this is not an actual bug, I'm removing the bug label from it.

@santisoler santisoler removed the bug Report a problem that needs to be fixed label Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants