lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

Automated test fails on new install: module 'collections' has no attribute 'Callable' #474

Closed jpmvferreira closed 2 years ago

jpmvferreira commented 2 years ago

Hi there,

On a new installation of CLASS, the automated tests fails, while running other tests work fine.

Here's my procedure to replicate the issue. (Note: I'm using micromamba, an alternative package manager which is fully compatible with the conda package manager, using the same repository (conda-forge), which is available under the alias mm)

  1. Clone the repository locally:
    $ git clone --depth 1 https://github.com/lesgourg/class_public
  2. Install Python from conda-forge using micromamba on a clean virtual environment:
    $ mm install python
  3. Install all the dependencies from PyPI:
    $ pip install numpy scipy matplotlib six nose cython parameterized
  4. Change directory and compile CLASS:
    $ cd class_public
    $ make
  5. Running the automated tests:
    $ nosetests test_class.py
    Traceback (most recent call last):
    File "/home/undercover/.micromamba/envs/class/bin/nosetests", line 8, in <module>
    sys.exit(run_exit())
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/core.py", line 118, in __init__
    unittest.TestProgram.__init__(
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/core.py", line 179, in parseArgs
    self.createTests()
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/core.py", line 193, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames)
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/loader.py", line 481, in loadTestsFromNames
    return unittest.TestLoader.loadTestsFromNames(self, names, module)
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/unittest/loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/unittest/loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/loader.py", line 431, in loadTestsFromName
    return self.loadTestsFromModule(
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/loader.py", line 359, in loadTestsFromModule
    return self.suiteClass(ContextList(tests, context=module))
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/suite.py", line 428, in __call__
    return self.makeSuite(tests, context, **kw)
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/suite.py", line 475, in makeSuite
    suite = self.suiteClass(
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/suite.py", line 159, in __init__
    super(ContextSuite, self).__init__(tests)
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/suite.py", line 53, in __init__
    super(LazySuite, self).__init__()
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/unittest/suite.py", line 22, in __init__
    self._tests = []
    File "/home/undercover/.micromamba/envs/class/lib/python3.10/site-packages/nose/suite.py", line 106, in _set_tests
    if isinstance(tests, collections.Callable) and not is_suite:
    AttributeError: module 'collections' has no attribute 'Callable'

Running ./class explanatory.ini or import classy from inside the Python REPL and the file temp.py suggested in the Wiki of this repository (after adapting it to Python3 as it is written in Python2) works fine.

I should state that I am completely new to CLASS, and I have no idea whether I should be worried about this or not, as it doesn't look like an error from CLASS, since it fails rather quickly, but rather something in the automated testing which is failing. Any help will be greatly appreciated!

System:

JCGoran commented 2 years ago

I think your Python version is, ironically, too new for nose:

>>> import sys
>>> print(sys.version)
3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
>>> from collections import Callable
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

This shouldn't come as a surprise since nose is apparently unmaintained. I don't think it it's a cause for worry though, CLASS itself (or rather, its Python equivalent, classy) should work fine (maybe modulo some Python 2 → 3 migration bugs) without nose.

jpmvferreira commented 2 years ago

Ah, thanks. That message should have showed in the traceback, it would save an issue!

Anyways, since this is a virtual environment, I will downgrade my Python to version 3.9 where it should still get it working, just to be sure everything is alright.