Skip to content

Commit

Permalink
Merge pull request #213 from dstansby/varattsget-arg
Browse files Browse the repository at this point in the history
Make varattsget arg required
  • Loading branch information
dstansby committed Jun 5, 2023
2 parents 188312a + f152ed1 commit d522d3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cdflib/cdfread.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,14 @@ def globalattsget(self) -> Dict[str, List[Union[str, np.ndarray]]]:

return return_dict

def varattsget(self, variable: Optional[str] = None) -> Dict[str, Union[None, str, np.ndarray]]:
def varattsget(self, variable: Union[str, int]) -> Dict[str, Union[None, str, np.ndarray]]:
"""
Gets all variable attributes.
Unlike attget, which returns a single attribute entry value,
this function returns all of the variable attribute entries,
in a dictionary (in the form of 'attribute': value pair) for
a variable. If there is no entry found, None is returned.
a variable.
"""
if isinstance(variable, int) and self._num_zvariable > 0 and self._num_rvariable > 0:
raise ValueError("This CDF has both r and z variables. Use variable name")
Expand All @@ -551,8 +551,6 @@ def varattsget(self, variable: Optional[str] = None) -> Dict[str, Union[None, st
if variable < 0 or variable >= num_variable:
raise ValueError(f"No variable by this number: {variable}")
return self._read_varatts(variable, zVar)
else:
raise ValueError("Please set variable keyword equal to " "the name or number of an variable")

def _uncompress_rle(self, data: bytes) -> bytearray:
result = bytearray()
Expand Down
5 changes: 5 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

1.0.3
=====
- The ``variable`` parameter to `cdflib.cdfread.CDF.varattsget` is no longer optional.
Not specifying it raised an error anyway in previous versions of cdflib.

1.0.2
=====
To make the ``xarray`` functionality easier to discover and import, a new
Expand Down

0 comments on commit d522d3c

Please sign in to comment.