Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Aug 31, 2023
1 parent f9d3d69 commit 466159f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 3 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Change Log
3.4.0 (unreleased)
------------------

* Add tools for adding units to FITS table columns.
* Add tools for adding units to table columns: FITS and :class:`~astropy.table.Table` (PR `#199`_).

.. _`#199`: https://github.com/desihub/desiutil/pull/199

3.3.1 (2023-06-13)
------------------
Expand Down
2 changes: 1 addition & 1 deletion py/desiutil/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def load_yml_units(filename):
A tuple containing two :class:`dict` objects for units and comments.
If no comments are detected, the comments :class:`dict` will be empty.
"""
log=get_logger()
log = get_logger()
comments = dict()
# log.debug("y = yaml.safe_load('%s')", filename)
with open(filename, newline='') as f:
Expand Down
36 changes: 18 additions & 18 deletions py/desiutil/test/test_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def test_annotate_table(self, mock_log):
self.assertEqual(tt['a'].unit, 'm')
self.assertEqual(tt['b'].unit, 'deg')
mock_log().debug.assert_has_calls([call("t['%s'].unit = '%s'", 'a', 'm'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
mock_log().info.assert_called_once_with("Column '%s' not found in units argument.", 'f')

@patch('desiutil.annotate.get_logger')
Expand Down Expand Up @@ -215,10 +215,10 @@ def test_annotate_qtable(self, mock_log):
self.assertEqual(tt['a'].unit, 'm')
self.assertEqual(tt['b'].unit, 'deg')
mock_log().debug.assert_has_calls([call("t['%s'].unit = '%s'", 'a', 'm'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
mock_log().info.assert_called_once_with("Column '%s' not found in units argument.", 'f')

@patch('desiutil.annotate.get_logger')
Expand All @@ -236,11 +236,11 @@ def test_annotate_qtable_with_units_present(self, mock_log):
self.assertEqual(tt['a'].unit, 'cm')
self.assertEqual(tt['b'].unit, 'deg')
mock_log().debug.assert_has_calls([call("t['%s'].unit = '%s'", 'a', 'cm'),
call("t.replace_column('%s', t['%s'].to('%s'))", 'a', 'a', 'cm'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
call("t.replace_column('%s', t['%s'].to('%s'))", 'a', 'a', 'cm'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
mock_log().info.assert_not_called()

@patch('desiutil.annotate.get_logger')
Expand All @@ -258,10 +258,10 @@ def test_annotate_qtable_with_units_present_bad_conversion(self, mock_log):
self.assertEqual(tt['a'].unit, 'm')
self.assertEqual(tt['b'].unit, 'deg')
mock_log().debug.assert_has_calls([call("t['%s'].unit = '%s'", 'a', 'A'),
call("t.replace_column('%s', t['%s'].to('%s'))", 'a', 'a', 'A'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
call("t.replace_column('%s', t['%s'].to('%s'))", 'a', 'a', 'A'),
call("t['%s'].unit = '%s'", 'b', 'deg'),
call("Not setting blank unit for column '%s'.", 'c'),
call("Not setting blank unit for column '%s'.", 'd'),
call("Column '%s' not present in table.", 'e')])
mock_log().info.assert_not_called()
mock_log().error.assert_has_calls([call("Cannot add or replace unit '%s' to column '%s'!", 'A', 'a')])

0 comments on commit 466159f

Please sign in to comment.