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

[TEP014] Added HDFWriter class + Unit Tests #744

Merged
merged 6 commits into from
Jun 20, 2017

Conversation

vg3095
Copy link
Contributor

@vg3095 vg3095 commented Jun 14, 2017

No description provided.

@vg3095
Copy link
Contributor Author

vg3095 commented Jun 14, 2017

@wkerzendorf . Please review

Copy link
Contributor

@yeganer yeganer left a comment

Choose a reason for hiding this comment

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

Looks good, only some small remarks

return data

@staticmethod
def convert_to_camel_case(s):
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand it, what we are doing here is converting to snake_case. Please rename the function accordingly.


@staticmethod
def convert_to_camel_case(s):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain to me why we need two substitutions?
Additionally I don't understand why you added a [a-z]+ at the end of the capture group. This prevents AB from being converted to a_b, which I think we want?

Copy link
Contributor Author

@vg3095 vg3095 Jun 14, 2017

Choose a reason for hiding this comment

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

@yeganer I used this regex from this thread->Stackoverflow

@staticmethod
def convert_to_camel_case(s):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, I don't understand why we need this second substitution as the first seems to cover everything?

Maybe you can add some simple tests for some strings like CamelCase, ABC, ABcdefG, snake_Case?

@vg3095
Copy link
Contributor Author

vg3095 commented Jun 15, 2017

I have used regex to convert from CamelCase to snake_case from here --> Stackoverflow



def test_snake_case():
obj = MockHDF(None)
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this line because convert_to_snake_case is a static method. You can simply write MockHDF.convert_to_snake_case(...)


arrays = [['L1', 'L1', 'L2', 'L2', 'L3', 'L3', 'L4', 'L4'],
['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']]
tuples = list(zip(*arrays))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a very complicated way to create these arrays. I'd suggest you use np.array(...) and then simply transpose it.

@vg3095
Copy link
Contributor Author

vg3095 commented Jun 19, 2017

@wkerzendorf This PR consists of both HDFWriter class and its unit tests. Please review.

@vg3095 vg3095 changed the title [TEP014] Added HDFWriter class [TEP014] Added HDFWriter class + Unit Tests Jun 19, 2017
@wkerzendorf wkerzendorf merged commit a5dbaef into tardis-sn:master Jun 20, 2017
@vg3095 vg3095 deleted the HDFWriter branch June 20, 2017 08:05
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.

3 participants