ajdawson / eofs

EOF analysis in Python
http://ajdawson.github.io/eofs/
GNU General Public License v3.0
199 stars 60 forks source link

reconstructedField broken because of reliance on now non-existent collections.Iterable #139

Closed rebeccaherman1 closed 8 months ago

rebeccaherman1 commented 1 year ago

when I try to run solver.reconstructedField(1), I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[221], line 1
----> 1 solver.reconstructedField(1)

File /home/b/b382109/miniconda3/envs/rebecca/lib/python3.10/site-packages/eofs/iris.py:574, in Eof.reconstructedField(self, neofs)
    539 def reconstructedField(self, neofs):
    540     """Reconstructed data field based on a subset of EOFs.
    541 
    542     If weights were passed to the `Eof` instance the returned
   (...)
    572 
    573     """
--> 574     rfield = self._solver.reconstructedField(neofs)
    575     coords = [copy(self._time)] + [copy(coord) for coord in self._coords]
    576     if isinstance(neofs, collections.Iterable):

File /home/b/b382109/miniconda3/envs/rebecca/lib/python3.10/site-packages/eofs/standard.py:638, in Eof.reconstructedField(self, neofs)
    603 """Reconstructed data field based on a subset of EOFs.
    604 
    605 If weights were passed to the `Eof` instance the returned
   (...)
    635 
    636 """
    637 # Determine how the PCs and EOFs will be selected.
--> 638 if isinstance(neofs, collections.Iterable):
    639     modes = [m - 1 for m in neofs]
    640 else:

AttributeError: module 'collections' has no attribute 'Iterable'

Perhaps an 'Iterable' is now called a 'Counter'? Could this be updated?

bbuzz31 commented 1 year ago

just change collections.Iterable to collections.abc.Iterable. And see #131

ajdawson commented 8 months ago

I believe this is fixed in 1.4.1