-
Notifications
You must be signed in to change notification settings - Fork 29
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
Merge Hooke's igorbinarywave with igor.py, adding fancy structure parsing to both projects. #3
Open
wking
wants to merge
77
commits into
reflectometry:master
Choose a base branch
from
wking:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
It's a utility for the MFP3D driver, not a driver in its own right.
…h non-empty padding).
Otherwise an earier switch to a non-native byte ordering will confuse the current load.
I'm confident in the bytes -> strings conversion, but not entirely sure how the strings get mapped into multidimensional arrays.
Samples are from TN003.zip, downloaded from ftp://www.wavemetrics.net/IgorPro/Technical_Notes/TN003.zip
Also moved byte_order to the util module and renamed a few functions internal to the binarywave module so they start with an underscore. The loadibw -> load (and saveibw -> save) change is because from igor.binarywave import load gives you enough of an idea about what you're importing. If you want to keep it explicit in your client module, use from igor.binarywave import load as loadibw which we do in the test.py module.
We'll be needing it for packed.load, so it's not binarywave-specific.
This makes more sense than storing them as a tuple. Also, use wave_record.wave_info['bname'] as the name for storing the wave in the filesystem view returned by packed.load.
…ount. In Python 3, the floating point division lead to: Traceback (most recent call last): ... File ".../igor/struct.py", line 255, in unpack_data items = [next(iterator) for i in range(self.arg_count)] TypeError: 'numpy.float64' object cannot be interpreted as an integer
…lity. Python 3 exceptions no longer have a .message attribute.
I don't know if encoding information is embedded in the IGOR files or not. Currently the stock parser just leaves everything it reads in in bytes. For compatibility, the igorpy module attempts to convert those byte strings to Unicode, but it just assumes that the encoding used in the file matches the locale or default encoding used by your system. This could be a portability issue. Until commit commit fe7006e Author: W. Trevor King <wking@tremily.us> Date: Sat Jul 21 07:50:09 2012 -0400 Replace igor.igorpy parsing with translations from igor.packed.load. The igorpy parser used sys.getfilesystemencoding() to guess the encoding, but that encoding is actually used to encode file names, not file contents. locale.getpreferredencoding is a better guess, but it's still just a guess.
The tests pass on Python 2.7, and all the failures on Python 3.2 are string/bytes display issues.
This improves on the old method of assuming they were scalar if .item_count was 1.
Your .py files are licensed as LGPL but the overall project is listed as GPL. Much of the python numerics world is BSD licensed, so LGPL is a closer match to the community. Do you mind changing the project to LGPL? Note that some test files just list "Copyright" as the copyright notice. |
On Thu, Jul 26, 2012 at 09:25:20AM -0700, Paul Kienzle wrote: > Your .py files are licensed as LGPL but the overall project is > listed as GPL. Much of the python numerics world is BSD licensed, > so LGPL is a closer match to the community. Do you mind changing > the project to LGPL?
The old algorithm collapsed null bytes early on. The new algorithm keeps the null bytes until the 32-byte chunks have been read. Parsing hooke/test/data/vclamp_mfp3d/Line0004Point0001.ibw with the old algorithm gave labels as [[], ['RawDeflLVDT'], [], []] The new algorithm gives [[], ['', 'Raw', 'Defl', 'LVDT'], [], []]
Catch up with 551d9bc (Fix DynamicLabelsField parsing algorithm., 2012-08-20).
ArgumentParser lost its undocumented version argument in 3.3.0 [1,2,3]. The version action is the documented way to do this [4]. [1]: http://bugs.python.org/issue13248 [2]: https://hg.python.org/cpython/rev/5393382c1b1d [3]: https://hg.python.org/cpython/file/374f501f4567/Misc/HISTORY#l477 [4]: https://docs.python.org/3/library/argparse.html#action
I haven't actually tested all of these, but I doubt I did anything so magical that support has been dropped in the meantime ;). It would be nice to drop the doctests [1], but until then testing Python 3 is going to be difficult. [1]: #1 (comment)
Changes since 0.2: * Add igor.packed.walk for traversing a packed experiment filesystem. * Add igorpackedexperiment.py to setup.py script list. * Add -p/--plot option so scripts will plot waves. * Adjust copyright to LGPLv3+ * Assorted bugfixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pretty major restructuring for both projects, but I believe it's worth it. I think Structure, Field, and their Dynamic* subclasses make it much easier to understand how the parsing is going on. There are also new tests based on examples distributed in the technical notes. I've also added some rough matplotlib plotting.