Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid underscore replacement empty prefixes. #951

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

kbruegge
Copy link
Member

@kbruegge kbruegge commented Feb 5, 2019

The underscore replacment would match every string when the prefix was empty.

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #951 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #951   +/-   ##
=======================================
  Coverage   78.86%   78.86%           
=======================================
  Files         191      191           
  Lines       10966    10966           
=======================================
  Hits         8648     8648           
  Misses       2318     2318
Impacted Files Coverage Δ
ctapipe/io/hdf5tableio.py 94.63% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37f70ce...f005d63. Read the comment docs.

@@ -151,7 +151,7 @@ class Schema(tables.IsDescription):
continue

if isinstance(value, Quantity):
if self.add_prefix:
if self.add_prefix and container.prefix:
key = col_name.replace(container.prefix + '_', '')
Copy link
Member

Choose a reason for hiding this comment

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

I think what we really want to do here (and there might be other places where this is needed) is:

import re

key = re.sub(f'^{prefix}_', '', col_name)

This makes sure, prefix_ is only removed at the beginning of the column name.

@kbruegge kbruegge merged commit ee0edf5 into cta-observatory:master Feb 11, 2019
@kbruegge kbruegge deleted the fix_empty_prefix branch February 11, 2019 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants