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

check_endian code in _get_filled_data is buggy #66

Merged
merged 6 commits into from
Aug 27, 2014

Conversation

keflavich
Copy link
Contributor

the check_endian branch creates a data variable that is never used. It also uses astype which copies the array.

I'm not sure what the intended behavior is here

@astrofrog
Copy link
Member

cc @keflavich

@keflavich
Copy link
Contributor

Right, @astrofrog and I were digging into this at one point and tried using view instead of astype, but that led to problems. The data variable is used, though, in the united branch. I'll PR it here.

@keflavich
Copy link
Contributor

OK... I see data being used on master, but I admit some serious git confusion here, as the last time I looked at master it was being treated incorrectly.

@ChrisBeaumont
Copy link
Author

I might have clobbered this during a careless rebase -- my bad. In any event, can you add a test that would catch that?

@ChrisBeaumont ChrisBeaumont added this to the 0.1 milestone Apr 23, 2014
@keflavich
Copy link
Contributor

FYI, there is still a possible bug here: numpy doesn't seem to respect <f4 as a dtype; it immediately converts it to =f4. The tests will fail on a big-endian architecture (if all is correct)

@ChrisBeaumont
Copy link
Author

Hrmm I'm getting confused here

What are the situations in which the check_endian kwarg in get_filled_data becomes important? Can we get this issue more directly with two temporary files with the same contents but different endianness, and assert that get_filled_data does the right thing in both cases?

I have to admit I don't fully understand what the warning in the test means, practically speaking

@keflavich
Copy link
Contributor

Your confusion is justified.

If you create (I think even by reading from disk? Not sure here!) a little-endian array on a little endian system, e.g. a mac, numpy interprets it as 'native':

>>> x = np.array([1], dtype='<f4')
>>> x.dtype.byteorder
'='

whereas a big endian array will keep its type

>>> x = np.array([1], dtype='>f4')
>>> x.dtype.byteorder
'>'

Really, what we want to do is check that the type changes when appropriate and check is turned on. To make that test work right, and importantly check that the change is not made when the check is turned off, we need to force numpy to not use =. For all I know this is well documented somewhere but I'm off on other tasks...

@ChrisBeaumont
Copy link
Author

In what situations does the endianness matter? You mention non-numpy functions... should we just directly test that those functions operate properly regardless of the underlying endianness?

@keflavich
Copy link
Contributor

This was specifically for the bottleneck package; it requires native-endian arrays.

@ChrisBeaumont
Copy link
Author

Ok, how about a test of bottleneck on a non-native endian array? The intent of such a test is more obvious, and should exercise the same functionality, right?

@astrofrog
Copy link
Member

Note that bottleneck is not currently installed on Travis, so this functionality is not getting tested properly on Travis. However, you can add it to the pip install line.

@ChrisBeaumont
Copy link
Author

Either way, we should probably make such a test optional, and skipped if bottleneck isn't present

@astrofrog
Copy link
Member

@keflavich - can you add bottleneck to Travis and also make sure the test gets skipped if bottleneck is not installed? (also we should make sure the test is set up so as to fail if bottleneck is not installed and not skipped).

@astrofrog
Copy link
Member

@keflavich - do you think you can realistically do this in the next couple of days? If not, maybe we should re-schedule to 0.2?

@keflavich
Copy link
Contributor

let's skip it for now; it is non-urgent

@astrofrog astrofrog modified the milestones: 0.2, 0.1 May 6, 2014
@keflavich
Copy link
Contributor

@astrofrog I've now added the bottleneck install on travis

keflavich added a commit that referenced this pull request Aug 27, 2014
check_endian code in _get_filled_data is buggy
@keflavich keflavich merged commit 049005f into radio-astro-tools:master Aug 27, 2014
@keflavich keflavich deleted the issue66 branch August 27, 2014 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants