Ticket #157 (closed defect: fixed)

Opened 3 years ago

Last modified 16 months ago

Possible problem in napi.h documentation

Reported by: Stuart Campbell Owned by: Paul Kienzle
Priority: minor Milestone: NeXus 4.2 Ready
Component: documentation Version: trunk
Keywords: getgroupinfo Cc:

Description

I was just looking at the openpath routine in the python bindings and I noticed the use of the NXgetgroupinfo function to return the number of child elements (line 493).

I thought that this function returned the number of attributes rather than the number of elements.

This might not be a problem, but I thought it was worth pointing it out.

Change History

comment:1 Changed 3 years ago by Paul Kienzle

  • Status changed from new to closed
  • Resolution set to invalid

The docs say that getgroupinfo returns number of elements and getattrinfo returns the number of attributes. This is how it works in practice as well, otherwise NXinstrument would never be able to load.

I will close this ticket until someone can demonstrate failure.

Note: HDF4 files can have a bogus group at the root level that is not part of the nexus file. The entries iterator suppresses it. Since the doc string on NeXus.entries for more details.

comment:2 Changed 3 years ago by Peter Peterson

  • Status changed from closed to reopened
  • Resolution invalid deleted

The documentation in napi.h disagrees with you. Quoting that directly lines 501-511.

  /**
   * Retrieve information about the currently open group.
   * \param handle A NeXus file handle as initialized by NXopen.
   * \param no_items A pointer to an integer which will be set to the count of group attributes 
   * available.
   * \param name The name of the group.
   * \param nxclass The NeXus class name of the group.
   * \return NX_OK on success, NX_ERROR in the case of an error.   
   */
extern  NXstatus  NXgetgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);

The integer is the number of attributes on the group. NXgetattrinfo returns the number of attributes for the current field. I don't believe it returns any information for group attributes.

To get all of the groups/fields at the current level you should use NXgetnextentry until NX_EOD is returned.

comment:3 Changed 3 years ago by Paul Kienzle

  • Keywords getgroupinfo added; python removed
  • Priority changed from major to minor
  • Component changed from bindings to documentation
  • Summary changed from Possible problem in python openpath() to Possible problem in napi.h documentation

http://www.nexusformat.org/NAPI_Routines#NXgetgroupinfo

Quoting:

NXgetgroupinfo Returns the number of items in the current group, and the name and class of the current group. ... Output Arguments

item_number int * Number of NeXus data items in the current group group_name char * Name of currently open NeXus group group_class char * Class of currently open NeXus group

Looking in the source:

HDF4: Vntagrefs returns the number of objects in a vgroup identified by the parameter vgroup_id. HDF5: iteratate over groups with group_info1: increments iNX if type is H5G_GROUP or H5G_DATASET XML: loop over child incrementing childCount

And more importantly my code would fail if the getgroupinfo were returning the wrong thing.

I'll leave this open until the doc issues are resolved, and rename it to a napi.h problem.

comment:4 Changed 16 months ago by Mark Koennecke

  • Status changed from reopened to closed
  • Resolution set to fixed

The documentation in napi.h has been fixed.

Note: See TracTickets for help on using tickets.