-1

I have a script which utilizes the Py-ART package to read in airborne weather radar data and then perform quality control on said data. I'll note that I suspect this is not an issue with that package, otherwise I'd just post an issue to that repo...

The confusing aspect of this issue is that the code runs flawlessly on my machine, in both Python 2.x and 3.x, though it fails with the following error on a colleague's machine in Python 2.x:

TypeError: cannot concatenate 'str' and 'int' objects

The error is triggered upon trying to execute the final line of this block of code:

az_raw = radar.azimuth['data'].data
roll = radar.roll['data'].data
azmth = az_raw + roll
azmth[azmth < 0] += 360

Some potential clues I've deduced from investigating the issue:

  1. On my machine, where the code runs properly, the az_raw and roll variables are read in as arrays of type float32, whereas on my colleague's machine, these variables have a Buffer type. Upon adding the contents of roll to az_raw (element-by-element), azmth remains as an array of float32 on my machine, and becomes an array of str on the other machine.

  2. Py-ART uses the netCDF4 package to read in the data from the netCDF input files - perhaps there is a machine and/or version related issue here?

  3. The issue persists regardless of the input file (i.e., we've tried several, and from different data collection periods/projects with the same results.

So ultimately, my question comes down to what would cause a TypeError like this on one machine but not another when all else appears to be the same? I suppose there could be a dependency version difference (of Py-ART, netCDF4, etc.) between the two machines, but it's not clear to me how that would cause such an issue. Has anyone seen anything similar to this before?

dstex
  • 1
  • 1
    The simplest explanation is a difference in dependency versions: try comparing the output of `pip freeze` (assuming the packages are set up through pip). As to why, well APIs can change (and sometime in a not-backwards-compatible way), and if you were not careful enough when setting up your application (you didn't fix your dependencies etc), you might have ended up with different environments on different machines. – Norrius Jun 06 '19 at 15:48
  • https://meta.stackoverflow.com/a/385640/1394393 – jpmc26 Jun 06 '19 at 17:22

1 Answers1

1

Agree with Norrius. There is a dependency issue. How was Py-ART installed on each machine? The best way to ensure things work is to use a Conda Environment so you can control (and isolate) dependancies.

Actually now I look at the error (Buffer versus float) I know your colleague's machine has outdated packages including Numpy. If he updates numpy (this is an issue in the IO area, I think https://docs.scipy.org/doc/numpy/reference/generated/numpy.frombuffer.html, versus fromstring )

Please also note Py-ART support for Python 2.x will be dropped very soon. The next version we release, by October, will see our CI for 2.x turned off.

Scott Collis
  • 111
  • 5