Skip to content

Commit

Permalink
Drop optional xarray import from gini
Browse files Browse the repository at this point in the history
  • Loading branch information
zbruick committed Oct 24, 2019
1 parent 602d30f commit 4ccb2c9
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/metpy/io/gini.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
import re

import numpy as np
from xarray import Variable
from xarray.backends.common import AbstractDataStore
try:
from xarray import Variable
from xarray.backends.common import AbstractDataStore
try:
from xarray.core.utils import FrozenDict
except ImportError:
from xarray.core.utils import FrozenOrderedDict as FrozenDict
from xarray.core.utils import FrozenDict
except ImportError:
# This way GiniFile is still usable without xarray
AbstractDataStore = object
from xarray.core.utils import FrozenOrderedDict as FrozenDict

from ._tools import Bits, IOBuffer, NamedStruct, open_as_needed, zlib_decompress_all_frames
from ..package_tools import Exporter
Expand All @@ -32,7 +28,6 @@

def _make_datetime(s):
r"""Convert 7 bytes from a GINI file to a `datetime` instance."""
s = bytearray(s) # For Python 2
year, month, day, hour, minute, second, cs = s
if year < 70:
year += 100
Expand All @@ -41,8 +36,6 @@ def _make_datetime(s):

def _scaled_int(s):
r"""Convert a 3 byte string to a signed integer value."""
s = bytearray(s) # For Python 2

# Get leftmost bit (sign) as 1 (if 0) or -1 (if 1)
sign = 1 - ((s[0] & 0x80) >> 6)

Expand Down

0 comments on commit 4ccb2c9

Please sign in to comment.