question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: float 4 IBM format support as part of the basic types (such as 'f4')

See original GitHub issue

I’m aware that there are some ufunctions which convert float4ibm to ieee float and inverse. The point of this enhancement request that there are many file formats (mostly in Earth Science) dealing with float4ibm and doing something like:

#assuming that 'w4' is format for float4ibm
mytype=numpy.dtype([('integer','>i4'),('float4ibm','>w4'),('string','S5')])
...
a=numpy.fromfile(fd,dtype=mytype,count=100)
...
a.tofile('updated.data',dtype=mytype)

looks much cleaner (and possibly closer to the user) than

#implement ufunc or cython or python version of **float4ieee** and **float4ibm**
mytype=numpy.dtype([('integer','>i4'),('float4ibm','i4'),('string','S5')])
...
a=numpy.fromfile(fd,dtype=mytype,count=100)
b=float4ieee(a['float4ibm'][:])
...
a['float4ibm'][:]=float4ibm(b)
a.tofile('chnaged.data',dtype=mytype)

My point is that ibm float is the same thing as ieee 4 byte and having one implemented and not another is unfair.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
mhvkcommented, Oct 13, 2015

@thoth291 - I don’t think I was trying to diminish the importance, but really just argue where things belong. Surely, if one runs large jobs on supercomputers, one has standard seismic python packages that one uses (with hopefully numpy under the hood). Separation of concerns suggests those should those take care of the conversion.

And yes, astronomy is also a large user of supercompuers, and at least on my blue gene jobs here in Toronto, I combine packages I wrote myself with astropy + numpy. If an equivalent to astropy does not exist for seismic studies, perhaps it should be made to?

Anyway, since I will neither be writing the code nor deciding the fate of any pull request to implement it, I’ll shut up now.

2reactions
rkerncommented, Oct 13, 2015

It’s certainly fair to only implement IEEE floats since none of the CPU architectures that we support implement native IBM float arithmetic.

You will always have to convert to a native float somewhere along the line. The conversions could be made more convenient, certainly, and it might be useful to implement these conversion functions in numpy (@njsmith, yes these are quite common in the geosciences. The standards date from the 70s when VAXes ruled the Earth). One could imagine a function that takes a structured array and converts specified fields in-place and returns a view on the converted data with the native dtypes and another to go the other way.

It might also be reasonable to implement an arithmetic-less dtype for this purpose, so you just need to use .astype(). However, that approach encourages (requires) memory-copying while the explicit conversions above can be written to avoid that, which is often desirable since you only need to do these conversions upon I/O.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Principles of Operation - IBM
When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes...
Read more >
CREATE EXTERNAL TABLE statement - IBM
A decimal floating-point number. The precision integer specifies the total number of digits, which can be either 16 or 34. The default is...
Read more >
CREATE EXTERNAL TABLE statement - IBM
A decimal floating-point number. The precision integer specifies the total number of digits, which can be either 16 or 34. The default is...
Read more >
XL C/C++ Language Reference - IBM
This document describes the syntax, semantics, and IBM® z/OS® XL C/C++ implementation of the C and C. ++ programming languages.
Read more >
The z/Architecture Principles of Operation - IBM
A form for reader's comments is provided at the back of this publication. ... Floating-Point-Support-Sign- Handling Facility1-10. FPR-GR-Transfer Facility .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found