Skip to content

Commit

Permalink
renaming PROVENANCE_HISTORY to PROVHISTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver committed May 28, 2021
1 parent dfc5ff7 commit db8258d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions astrodata/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def add_provenance_history(ad, timestamp_start, timestamp_stop, primitive, args)
--------
none
"""
if hasattr(ad, 'PROVENANCE_HISTORY'):
for row in ad.PROVENANCE_HISTORY:
if hasattr(ad, 'PROVHISTORY'):
for row in ad.PROVHISTORY:
if timestamp_start == row[0] and \
timestamp_stop == row[1] and \
primitive == row[2] and \
Expand All @@ -75,13 +75,13 @@ def add_provenance_history(ad, timestamp_start, timestamp_stop, primitive, args)
return

colsize = len(args)+1
if hasattr(ad, 'PROVENANCE_HISTORY'):
colsize = max(colsize, max(len(ph[3]) for ph in ad.PROVENANCE_HISTORY) + 1)
if hasattr(ad, 'PROVHISTORY'):
colsize = max(colsize, max(len(ph[3]) for ph in ad.PROVHISTORY) + 1)

timestamp_start_arr = [ph[0] for ph in ad.PROVENANCE_HISTORY]
timestamp_stop_arr = [ph[1] for ph in ad.PROVENANCE_HISTORY]
primitive_arr = [ph[2] for ph in ad.PROVENANCE_HISTORY]
args_arr = [ph[3] for ph in ad.PROVENANCE_HISTORY]
timestamp_start_arr = [ph[0] for ph in ad.PROVHISTORY]
timestamp_stop_arr = [ph[1] for ph in ad.PROVHISTORY]
primitive_arr = [ph[2] for ph in ad.PROVHISTORY]
args_arr = [ph[3] for ph in ad.PROVHISTORY]
else:
timestamp_start_arr = []
timestamp_stop_arr = []
Expand All @@ -97,7 +97,7 @@ def add_provenance_history(ad, timestamp_start, timestamp_stop, primitive, args)
ad.append(Table([timestamp_start_arr, timestamp_stop_arr, primitive_arr, args_arr],
names=('timestamp_start', 'timestamp_stop',
'primitive', 'args'),
dtype=dtype), name="PROVENANCE_HISTORY")
dtype=dtype), name="PROVHISTORY")


def clone_provenance(provenance_data, ad):
Expand Down
18 changes: 9 additions & 9 deletions astrodata/tests/test_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ def test_add_get_provenance_history(ad):
args = "args"

add_provenance_history(ad, timestamp_start, timestamp_end, primitive, args)
assert len(ad.PROVENANCE_HISTORY) == 1
assert tuple(ad.PROVENANCE_HISTORY[0]) == (timestamp_start, timestamp_end,
assert len(ad.PROVHISTORY) == 1
assert tuple(ad.PROVHISTORY[0]) == (timestamp_start, timestamp_end,
primitive, args)

add_provenance_history(ad, timestamp_start, timestamp_end,
'another primitive', args)
assert len(ad.PROVENANCE_HISTORY) == 2
assert tuple(ad.PROVENANCE_HISTORY[0]) == (timestamp_start, timestamp_end,
assert len(ad.PROVHISTORY) == 2
assert tuple(ad.PROVHISTORY[0]) == (timestamp_start, timestamp_end,
primitive, args)
assert tuple(ad.PROVENANCE_HISTORY[1]) == (timestamp_start, timestamp_end,
assert tuple(ad.PROVHISTORY[1]) == (timestamp_start, timestamp_end,
'another primitive', args)


Expand All @@ -97,7 +97,7 @@ def test_add_dupe_provenance_history(ad):
add_provenance_history(ad, timestamp_start, timestamp_end, primitive, args)

# was a dupe, should have skipped 2nd add
assert len(ad.PROVENANCE_HISTORY) == 1
assert len(ad.PROVHISTORY) == 1


def test_clone_provenance(ad, ad2):
Expand All @@ -124,8 +124,8 @@ def test_clone_provenance_history(ad, ad2):

add_provenance_history(ad, timestamp_start, timestamp_end, primitive, args)

clone_provenance_history(ad.PROVENANCE_HISTORY, ad2)
clone_provenance_history(ad.PROVHISTORY, ad2)

assert len(ad2.PROVENANCE_HISTORY) == 1
assert tuple(ad2.PROVENANCE_HISTORY[0]) == (timestamp_start, timestamp_end,
assert len(ad2.PROVHISTORY) == 1
assert tuple(ad2.PROVHISTORY[0]) == (timestamp_start, timestamp_end,
primitive, args)
6 changes: 3 additions & 3 deletions recipe_system/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def _get_provenance_inputs(adinputs):
provenance = ad.PROVENANCE.copy()
else:
provenance = []
if hasattr(ad, 'PROVENANCE_HISTORY'):
provenance_history = ad.PROVENANCE_HISTORY.copy()
if hasattr(ad, 'PROVHISTORY'):
provenance_history = ad.PROVHISTORY.copy()
else:
provenance_history = []
retval[ad.data_label()] = \
Expand Down Expand Up @@ -255,7 +255,7 @@ def _capture_provenance(provenance_inputs, ret_value, timestamp_start, fn, args)
clone_provenance(provenance_inputs[ad.data_label()]['provenance'], ad)
clone_provenance_history(provenance_inputs[ad.data_label()]['provenance_history'], ad)
else:
if hasattr(ad, 'PROVENANCE_HISTORY'):
if hasattr(ad, 'PROVHISTORY'):
clone_hist = False
else:
clone_hist = True
Expand Down

1 comment on commit db8258d

@chris-simpson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't approve of this. Let's not mangle the names of things just to be beholden to IRAF's limitations, especially when nobody is going to be using IRAF to inspect the PROVENANCE_HISTORY table.

Please sign in to comment.