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

182 read logger files from solinst levelogger as obs #184

Merged

Conversation

HMEUW
Copy link
Collaborator

@HMEUW HMEUW commented Jan 11, 2024

Code and tests included.

Github suggested @dbrakenhoff as reviewer. Is that okay?

dbrakenhoff and others added 3 commits November 3, 2023 17:14
First phase of programming. Function can import an existing file now. Next step to test also other files (with other frequency, without x-y-location); and tests.
Update typo in brandname, should be Solinst (thanks @MattBrst)
@HMEUW HMEUW requested a review from dbrakenhoff January 11, 2024 15:26

return cls(
df,
name=meta.pop("name"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

add full metadata dict first, then pop the items?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied this working order from an other read package.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably also be changed there then, I think :). But i modified the order, so it should be fine now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you want to change the order Davíd? I used this order because I don't want the metadata that is added as attributes in the 'meta' dictionary. But now that I think about it I think the order does not even matter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought you would want the metadata to be available both in the Obs object and as columns in the ObsCollection?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But you say it doesn't matter? Does the dictionary get emptied regardless of the order you provide the keyword arguments?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to be sure we have the same idea of what is happening: When we use x = meta.pop('x') we remove x from the meta dict and add x as an attribute to the obs object. Then we use meta=meta at the end to add the meta dict as the attribute meta to the Obs object. When we do it in this order the meta attribute of an Obs object does not have any keys that are also attributes of that Obs object.

I like this approach because I don't like to store the same information in multiple places. If we would change the order we might end up with an Obs object that has a meta attribute which is a dictionary with a key x and an attribute x which have the same value.

But then I am not sure what happens if you use a dictionary as the first function argument. I think a reference to that dictionary is passed to the function and not a copy so if you modify the dictionary in other function arguments (by popping items) I think it will have an influence the first argument. This should be easy to test.

I hope this makes it more clear. For now I think we can leave it as is and I can pick this up later

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough, I somehow thought it would be nice to have both metadata available as a single dictionary containing everything, and certain attributes for easy quick access. But I get that storing the same data in multiple locations is a bit redundant and maybe more confusing. So all good to keep things as they are, and maybe add a comment why the data is being popped :). For future me, or future someone else.

- black formatting
- move import to top
- zip one test file to test zip file read
Copy link
Collaborator

@dbrakenhoff dbrakenhoff 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 to me 👍 ! I made a few minor changes (see my commit message) and black formatted the code. If tests pass this is good to go.

@dbrakenhoff
Copy link
Collaborator

test fails unrelated to this PR

@dbrakenhoff dbrakenhoff merged commit b636a99 into dev Jan 15, 2024
7 checks passed
@dbrakenhoff dbrakenhoff deleted the 182-read-logger-files-from-soilinst-levelogger-as-obs branch January 15, 2024 08:52
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