Skip to content

Commit

Permalink
importlib.resources
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Jan 8, 2025
1 parent 8ea8ce4 commit 5655eaf
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/update_iers_frozen
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""Update the iers_frozen file.
"""
from importlib_resources import files
from importlib.resources import files
from desiutil.iers import update_iers

frozen = str(files('desiutil') / 'data' / 'iers_frozen.ecsv')
Expand Down
7 changes: 7 additions & 0 deletions py/desiutil/bitmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ def names(self, mask=None):
for bitnum in sorted(bitnums):
names.append(self._bits[bitnum].name)
else:
# The line below throws a lot of warnings:
# 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.)
# It's not obvious where this is coming from though, since `mask`
# clearly should not be an array.
# https://github.com/numpy/numpy/issues/2955 was likely fixed in 2022.
mask = int(mask) # workaround numpy issue #2955 for uint64
bitnum = 0
while 2**bitnum <= mask:
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/census.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_options(test_args=None):
from sys import argv
from os.path import basename
from argparse import ArgumentParser
from importlib_resources import files
from importlib.resources import files
parser = ArgumentParser(description="Count number and size of DESI data files.",
prog=basename(argv[0]))
parser.add_argument('-c', '--config-file', action='store', dest='config',
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from io import BytesIO
from subprocess import Popen, PIPE
from types import MethodType
from importlib_resources import files
from importlib.resources import files
from .git import last_tag
from .log import get_logger, DEBUG, INFO
from .modules import (init_modules, configure_module,
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from shutil import which
from stat import S_IRUSR, S_IRGRP, S_IROTH
from configparser import ConfigParser
from importlib_resources import files
from importlib.resources import files
from . import __version__ as desiutilVersion
from .io import unlock_file
from .log import log
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/test/test_dust.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from .. import dust
# import desiutil.dust as dust
from importlib_resources import files
from importlib.resources import files
from astropy.coordinates import SkyCoord
from astropy import units as u

Expand Down
4 changes: 2 additions & 2 deletions py/desiutil/test/test_iers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import shutil
import tempfile
from unittest.mock import call, patch, MagicMock
from importlib_resources import files
from importlib.resources import files
from astropy import __version__ as AstropyVersion
import astropy.units as u
import astropy.utils.iers
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_update_iers_file(self, mock_logger):
def test_update_iers(self, mock_logger, mock_iers, mock_time):
"""Test updating the IERS table.
"""
real_name = str(files('desiutil'), 'data' / 'iers_frozen.ecsv')
real_name = str(files('desiutil') / 'data' / 'iers_frozen.ecsv')
t = QTable.read(real_name, format='ascii.ecsv')
mock_iers.return_value = t
d = MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/test/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from argparse import Namespace
from tempfile import mkdtemp
from logging import getLogger
from importlib_resources import files
from importlib.resources import files
from ..log import DEBUG
from ..install import DesiInstall, DesiInstallException, dependencies
from .test_log import NullMemoryHandler
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sys import version_info
from shutil import rmtree
from tempfile import mkdtemp
from importlib_resources import files
from importlib.resources import files
from ..modules import (init_modules, configure_module, process_module,
default_module, _write_module_data)

Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/test/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
import unittest
from tempfile import NamedTemporaryFile
from importlib_resources import files
from importlib.resources import files
import numpy as np
from astropy.io import fits
from ..sklearn import GaussianMixtureModel as GMM
Expand Down

0 comments on commit 5655eaf

Please sign in to comment.