Skip to content

Commit

Permalink
Fix and cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Jan 15, 2024
1 parent 46c0633 commit a2d292e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
1 change: 0 additions & 1 deletion stingray/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pickle
import warnings
import copy
import os
import logging

import numpy as np
Expand Down
30 changes: 6 additions & 24 deletions stingray/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
import os
import importlib
import copy
import pytest
import numpy as np
import matplotlib.pyplot as plt
from stingray.base import StingrayObject, StingrayTimeseries

_HAS_XARRAY = _HAS_PANDAS = _HAS_H5PY = _HAS_YAML = True

try:
import xarray
from xarray import Dataset
except ImportError:
_HAS_XARRAY = False

try:
import pandas
from pandas import DataFrame
except ImportError:
_HAS_PANDAS = False

try:
import h5py
except ImportError:
_HAS_H5PY = False

try:
import yaml
except ImportError:
_HAS_YAML = False
_HAS_XARRAY = importlib.util.find_spec("xarray") is not None
_HAS_PANDAS = importlib.util.find_spec("pandas") is not None
_HAS_H5PY = importlib.util.find_spec("h5py") is not None
_HAS_YAML = importlib.util.find_spec("yaml") is not None


class DummyStingrayObj(StingrayObject):
Expand Down Expand Up @@ -975,7 +957,7 @@ def test_file_roundtrip(self, fmt, highprec):
so.guefus = np.random.randint(0, 4, 3)
so.panesapa = np.random.randint(5, 9, (6, 2))
with pytest.warns(
UserWarning, match=f".* output does not serialize the metadata at the moment"
UserWarning, match=".* output does not serialize the metadata at the moment"
):
so.write(f"dummy.{fmt}", fmt=fmt)
new_so = StingrayTimeseries.read(f"dummy.{fmt}", fmt=fmt)
Expand Down

0 comments on commit a2d292e

Please sign in to comment.