HeloiseS / hoki

Bridging the gap between observation and theory
https://heloises.github.io/hoki/intro.html
BSD 3-Clause "New" or "Revised" License
47 stars 8 forks source link

Fixes the conflict with Astropy v6.0.0 #100

Closed WillJRoper closed 7 months ago

WillJRoper commented 9 months ago

This PR simply removes _astropy_init.py and the related import in __init__.py. This closes #99.

As far as I can tell from your source code this was all that was required to be compliant with v6.0.0 and keep things working.

All tests run locally but note there are lots of deprecation warnings in the output (admittedly this is with one of my environments) so you could get stung down the line when the deprecation warnings are fulfilled. I'll post the output in a comment.

WillJRoper commented 9 months ago

Local pytest output:

============================================================================================================================= test session starts ==============================================================================================================================
platform darwin -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0
rootdir: /Users/willroper/Research/hoki
configfile: setup.cfg
testpaths: hoki, docs
plugins: asdf-3.0.1, nbmake-1.4.6
collected 151 items

hoki/age/tests/test_utils.py ..................                                                                                                                                                                                                                          [ 11%]
hoki/age/tests/test_wizard.py ........                                                                                                                                                                                                                                   [ 17%]
hoki/csp/tests/test_csp.py ..                                                                                                                                                                                                                                            [ 18%]
hoki/csp/tests/test_eventrate.py ............                                                                                                                                                                                                                            [ 26%]
hoki/csp/tests/test_sfh.py .............                                                                                                                                                                                                                                 [ 35%]
hoki/csp/tests/test_utils.py ....................                                                                                                                                                                                                                        [ 48%]
hoki/stats/tests/test_starcounts.py ......                                                                                                                                                                                                                               [ 52%]
hoki/tests/test_aging.py ......................                                                                                                                                                                                                                          [ 66%]
hoki/tests/test_cmd.py ...                                                                                                                                                                                                                                               [ 68%]
hoki/tests/test_data_compilers.py .......                                                                                                                                                                                                                                [ 73%]
hoki/tests/test_eve.py ..                                                                                                                                                                                                                                                [ 74%]
hoki/tests/test_hrdiagrams.py ......                                                                                                                                                                                                                                     [ 78%]
hoki/tests/test_load.py .......................                                                                                                                                                                                                                          [ 94%]
hoki/tests/test_spec.py .........                                                                                                                                                                                                                                        [100%]

=============================================================================================================================== warnings summary ===============================================================================================================================
../../envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373
  /Users/willroper/envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: astropy_header

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

../../envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373
  /Users/willroper/envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: doctest_plus

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

../../envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373
  /Users/willroper/envs/synthesizer-env/lib/python3.10/site-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: text_file_format

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

hoki/__init__.py:18
hoki/__init__.py:18
  /Users/willroper/Research/hoki/hoki/__init__.py:18: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(sys.version) < LooseVersion(__minimum_python_version__):

hoki/age_utils.py:21
  /Users/willroper/Research/hoki/hoki/age_utils.py:21: HokiDeprecationWarning:

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  Deprecated since hoki v1.6
  PLEASE USE THE hoki.age SUBPACKAGE AND MODULES WITHIN.
  e.g. from hoki.age.wizard import AgeWizard
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    warnings.warn(HokiDeprecationWarning(deprecation))

hoki/age/tests/test_utils.py: 422 warnings
hoki/age/tests/test_wizard.py: 821 warnings
  /Users/willroper/Research/hoki/hoki/age/utils.py:171: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    T_i.append(int((np.where(abs(myhrd.T_coord - T) == abs(myhrd.T_coord - T).min()))[0]))

hoki/age/tests/test_utils.py: 424 warnings
hoki/age/tests/test_wizard.py: 821 warnings
  /Users/willroper/Research/hoki/hoki/age/utils.py:183: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    L_i.append(int((np.where(abs(myhrd.L_coord - L) == abs(myhrd.L_coord - L).min()))[0]))

hoki/age/tests/test_utils.py: 6 warnings
hoki/age/tests/test_wizard.py: 6 warnings
  /Users/willroper/Research/hoki/hoki/age/utils.py:236: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    col_i.append(int((np.where(abs(mycmd.col_range - col) == abs(mycmd.col_range - col).min()))[0]))

hoki/age/tests/test_utils.py: 7 warnings
hoki/age/tests/test_wizard.py: 6 warnings
  /Users/willroper/Research/hoki/hoki/age/utils.py:248: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    mag_i.append(int((np.where(abs(mycmd.mag_range - mag) == abs(mycmd.mag_range - mag).min()))[0]))

hoki/age/tests/test_utils.py::TestFindCMDCoordinates::test_bad_input_2
  /Users/willroper/Research/hoki/hoki/age/utils.py:242: HokiUserWarning: Colour=bla cannot be converted to a float
    warnings.warn("Colour=" + str(col) + " cannot be converted to a float", HokiUserWarning)

hoki/age/tests/test_utils.py::TestFindHRDCoordinates::test_bad_input
hoki/age/tests/test_utils.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age/utils.py:177: HokiUserWarning: T=bla cannot be converted to a float
    warnings.warn("T=" + str(T) + " cannot be converted to a float", HokiUserWarning)

hoki/age/tests/test_utils.py::TestCalculatePDFs::test_input_without_name
hoki/age/tests/test_utils.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age/utils.py:421: HokiUserWarning: No source names given so I'll make my own
    warnings.warn("No source names given so I'll make my own", HokiUserWarning)

hoki/age/tests/test_utils.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age/utils.py:327: HokiUserWarning: NaN Value encountered in coordinates for source: s1
    warnings.warn("NaN Value encountered in coordinates for source: " + name, HokiUserWarning)

hoki/age/tests/test_utils.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age/utils.py:28: RuntimeWarning: divide by zero encountered in divide
    return distribution / area

hoki/age/tests/test_utils.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age/utils.py:28: RuntimeWarning: invalid value encountered in divide
    return distribution / area

hoki/age/tests/test_utils.py::TestCalculateSamplePDF::test_drop_bad
  /Users/willroper/Research/hoki/hoki/age/utils.py:476: HokiUserWarning: FEATURE DISABLED
  KeyError'[3] not found in axis'
  HOKI DIALOGUE: Your labels could not be dropped -- all pdfs will be combined
  DEBUGGING ASSISTANT: Make sure the labels you listed are spelled correctly:)
    warnings.warn(message, HokiUserWarning)

hoki/age/tests/test_wizard.py::TestAgeWizardBasic::test_most_likely_age
  /Users/willroper/Research/hoki/hoki/age/wizard.py:103: HokiUserWarning: self.multiplied_pdf is not yet defined -- running AgeWizard.combined_pdfs()
    warnings.warn('self.multiplied_pdf is not yet defined -- running AgeWizard.combined_pdfs()',

hoki/age/tests/test_wizard.py::TestAgeWizardBasic::test_calculate_p_given_age_range
  /Users/willroper/Research/hoki/hoki/age/tests/test_wizard.py:85: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
    assert np.sum(np.isclose([probas[0], probas[1], probas[2]],

hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_input_functions_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_event_rate_at_time
hoki/csp/tests/test_eventrate.py::TestCSPEventRate::test_vector_input
  /Users/willroper/Research/hoki/hoki/csp/eventrate.py:160: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    event_rates[counter][count] = utils._at_time(

hoki/csp/tests/test_sfh.py::TestSFHParametric::test_intialisation_dpl
  /Users/willroper/Research/hoki/hoki/csp/sfh.py:159: RuntimeWarning: divide by zero encountered in reciprocal
    self.sfh = self.params['constant'] / ((self.time_axis / self.params['tau']) ** self.params['alpha'] + (

hoki/csp/tests/test_sfh.py::TestSFHParametric::test_intialisation_ln
  /Users/willroper/Research/hoki/hoki/csp/sfh.py:166: RuntimeWarning: divide by zero encountered in log
    - ((np.log(self.time_axis/1e9) - self.params['T0']) ** 2) / (2 * self.params['tau'] ** 2)))

hoki/tests/test_aging.py: 64 warnings
  /Users/willroper/Research/hoki/hoki/age_utils.py:205: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    T_i.append(int((np.where(abs(myhrd.T_coord - T) == abs(myhrd.T_coord - T).min()))[0]))

hoki/tests/test_aging.py: 66 warnings
  /Users/willroper/Research/hoki/hoki/age_utils.py:217: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    L_i.append(int((np.where(abs(myhrd.L_coord - L) == abs(myhrd.L_coord - L).min()))[0]))

hoki/tests/test_aging.py: 18 warnings
  /Users/willroper/Research/hoki/hoki/age_utils.py:270: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    col_i.append(int((np.where(abs(mycmd.col_range - col) == abs(mycmd.col_range - col).min()))[0]))

hoki/tests/test_aging.py: 19 warnings
  /Users/willroper/Research/hoki/hoki/age_utils.py:282: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    mag_i.append(int((np.where(abs(mycmd.mag_range - mag) == abs(mycmd.mag_range - mag).min()))[0]))

hoki/tests/test_aging.py::TestAgeWizard::test_most_likely_age
  /Users/willroper/Research/hoki/hoki/age_utils.py:99: HokiUserWarning: self.multiplied_pdf is not yet defined -- running AgeWizard.combined_pdfs()
    warnings.warn('self.multiplied_pdf is not yet defined -- running AgeWizard.combined_pdfs()',

hoki/tests/test_aging.py::TestAgeWizard::test_calculate_p_given_age_range
  /Users/willroper/Research/hoki/hoki/tests/test_aging.py:81: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
    assert np.sum(np.isclose([probas[0], probas[1], probas[2]],

hoki/tests/test_aging.py::TestFindCMDCoordinates::test_bad_input_2
  /Users/willroper/Research/hoki/hoki/age_utils.py:276: HokiUserWarning: Colour=bla cannot be converted to a float
    warnings.warn("Colour=" + str(col) + " cannot be converted to a float", HokiUserWarning)

hoki/tests/test_aging.py::TestFindHRDCoordinates::test_bad_input
hoki/tests/test_aging.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age_utils.py:211: HokiUserWarning: T=bla cannot be converted to a float
    warnings.warn("T=" + str(T) + " cannot be converted to a float", HokiUserWarning)

hoki/tests/test_aging.py::TestCalculatePDFs::test_input_without_name
hoki/tests/test_aging.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age_utils.py:424: HokiUserWarning: No source names given so I'll make my own
    warnings.warn("No source names given so I'll make my own", HokiUserWarning)

hoki/tests/test_aging.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age_utils.py:435: HokiUserWarning: NaN Value encountered in coordinates for source: s1
    warnings.warn("NaN Value encountered in coordinates for source: " + name, HokiUserWarning)

hoki/tests/test_aging.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age_utils.py:302: RuntimeWarning: divide by zero encountered in divide
    return distribution / area

hoki/tests/test_aging.py::TestCalculatePDFs::test_bad_input
  /Users/willroper/Research/hoki/hoki/age_utils.py:302: RuntimeWarning: invalid value encountered in divide
    return distribution / area

hoki/tests/test_aging.py::TestCalculateSamplePDF::test_drop_bad
  /Users/willroper/Research/hoki/hoki/age_utils.py:490: HokiUserWarning: FEATURE DISABLED
  KeyError'[3] not found in axis'
  HOKI DIALOGUE: Your labels could not be dropped -- all pdfs will be combined
  DEBUGGING ASSISTANT: Make sure the labels you listed are spelled correctly:)
    warnings.warn(message, HokiUserWarning)

hoki/tests/test_cmd.py::TestCMD::test_plot_pickle
  /Users/willroper/Research/hoki/hoki/cmd.py:323: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    single_cmd_grid = self.grid[int(index)]

hoki/tests/test_cmd.py::TestCMD::test_plot_pickle
  /Users/willroper/Research/hoki/hoki/cmd.py:357: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.
    colMap = cm.get_cmap(cmap)

hoki/tests/test_hrdiagrams.py: 12 warnings
  /Users/willroper/Research/hoki/hoki/hrdiagrams.py:444: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.
    colMap = copy.copy(cm.get_cmap(cmap))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

My environment has the following versions of note:

Python: 3.10.13
Astropy: 6.0.0
Matplotlib: 3.8.2
Numpy: 1.26.2
Pandas: 2.1.4