-
Notifications
You must be signed in to change notification settings - Fork 3
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
nxopen() failure with __enter__ #21
Comments
Is this object supposed to be an NXentry or NXfile? |
Ah- maybe this is supposed to be an NXroot. So is this a case where my file is malformed? It is generated with: |
The context manager returns an NXroot object.
It's not normally necessary to ever invoke a NXfile object. |
Is it possible a broken file format is causing this object type to be wrong? I get:
=>
|
Are you actually opening the file twice? Could that be the problem? |
With that debugging output, yes, it is being opened twice, but I was getting this issue before that. |
What file are you opening? Here is what I get with one of my files:
|
It is created with this script from the new test suite: |
chopper.nxs works for me: |
I haven't exactly worked out what is going on with your example, but it's best not to use the NXFile functions directly. There are two ways of saving a file without invoking the
or
I think you were working from the doctoring examples, which should be updated to reflect best practices. |
Yes, it is based on the online docs. That produces a structure like:
A good structure looks like:
So, I suggest nxinspect checks for the |
Ok- the root issue is that test 0001 has top-level attribute NX_class=NXentry , where test 0003 has no top-level attribute, so the nxclass defaults to 'NXroot' in tree.py:812 . This value is used to reassign the object class by assigning to |
Here is the proposed fix: It works with the test suite here: |
In this code: if ('NX_class' in fp.attrs
and fp.attrs['NX_class'] == 'NXentry'):
raise NeXusError(
'top-level class is NXentry: '
'must be NXroot or unset') The only allowed value is attr = fp.attrs.get("NX_class", "NXroot")
if attr != "NXroot":
raise NeXusError(f'top-level class is {attr}: must be NXroot or unset') |
Whether or not the |
I just noticed that the I don't know how the C-API handled this; perhaps it expected to find a |
I probably have this misconfigured somehow- nxopen() is returning an object that cannot be used by the Python context manager:
Example here:
https://github.com/j-woz/nxvalidate/actions/runs/11167580273/job/31044090443
The text was updated successfully, but these errors were encountered: