NuGrid / NuGridPy

Python tools to access and analyse NuGrid output data (including from MESA)
http://nugrid.github.io/NuGridPy
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

problem with numpy array axis with python3 #20

Closed mrawls closed 8 years ago

mrawls commented 8 years ago

I am running python 3.5.1 installed via astroconda on OS X 10.11. This is what happens when I try to use NuGridPy's mesa module to load a history.datasa file. I suspect numpy and/or python3 changed how the user should specify the axis of an array that you want to calculate the maximum of? But I'm not sure. Thank you for any help!

> from NuGridpy import mesa as ms
> import numpy as np
> sysname = '8702921'
> modeldir =  '../../RG_ELCmodeling/'+sysname+'/mesa/LOGS_1.59'
> model = ms.history_data(modeldir)
Using old history.datasa file ...
Traceback (most recent call last):
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 2255, in amax
   amax = a.max
AttributeError: 'int' object has no attribute 'max'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/NuGridpy/mesa.py", line 873, in __init__
   self._read_starlog()
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/NuGridpy/mesa.py", line 903, in _read_starlog
   header_attr,cols,data = _read_mesafile(filename,data_rows=num_cycles)
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/NuGridpy/mesa.py", line 3762, in _read_mesafile
   percent = int(i*100/np.max(1, data_rows-1))
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 2258, in amax
   out=out, keepdims=keepdims)
 File "/Users/Meredith/anaconda/envs/astroconda/lib/python3.5/site-packages/numpy/core/_methods.py", line 26, in _amax
   return umr_maximum(a, axis, None, out, keepdims)
ValueError: 'axis' entry is out of bounds
chritter commented 8 years ago

@mrawls Thank you for your detailed bug report. I have updated mesa.py. Please let me know if there are any further issues.

mrawls commented 8 years ago

Thank you so much, this appears to solve the problem!