-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fix for issue 126: Add 'TD' str_to_none to location funcs #134
Fix for issue 126: Add 'TD' str_to_none to location funcs #134
Conversation
Added test coverage for the change. |
Thank you very much for looking at this! There's a bit of risk here because if a user tries to pass in a function to transform TD, it will be overwritten. (I see there's the same pattern for location; I guess I did that but I can't remember why.) Maybe it would be smarter not to touch the function dictionary, but instead to add another one that is always used in the same way... Or to check for the issue explicitly. What do you think? I'd value your opinion. |
Yes, That is a good point. See if this is a good way to go or can be improved? For this pull-request (iteration), the user should be allowed to override the local funcs['TD'].
Your idea about a separate function dictionary suggests a more resilient design solution. This would be a significant change and should be separate issue/pull-request. There is a set of fields/mnemonics like 'TD', that Welly uses. It would be good to have routing tables for field specific code both for non-overridable code (run before Making sure 'TD' is set to None or a number is something that should happen every time regardless of a passed in funcs['TD'], so its str_to_none() function would be non-overridable function. This routing table could be added to either defaults.py or to fields.py. It looks like fields.py is the natural location for it. Then location.py::from_lasio() could be changed to process any field specific non-over-ritable functions before calling the user's |
- Move local funcs to default_funcs in location.from_lasio - Allow passed in funcs to override default_funcs - Display message if a default func
commit 710bf15 has these changes.
from our earlier comments so you could see and evaluate whether this is a good way to go. |
Continuing the discussion on alternative solutions for this, here a couple more ideas. I've implemented these and posted them for consideration as a possible solution.
This could be good because it would be a general rule applied to all fields/mnemonic and any changes in subsequent code to handle this would be consistent across Welly. There may be other impacts that are less favorable if processing of other fields/mnemonics expect a str object. A draft implementation could be interesting.
elif extents == 'td':
try:
# example code
if isinstance(self.location.td, str):
self.location.td = None
# end example code
upper, lower = 0, self.location.td
except: The benefits of this solution are that it is seems simple and it is right at the location of the issue. The drawbacks are that it clutters the processing code with data formatting code and that it might (but unlikely to) impact other code using self.location.td in other parts of the code. Initially I tried to stay away from this solution because applying this approach to many problems can fill an application with many local special cases rather than having a consistent way and central place for special case configuration. ... All that said, it is so simple to implement, I'll make a draft branch of it and post it so you have the option. |
Just checking in on this and the related alternative solutions in #136 and #137. Of these 3 approaches, it may be good to close the pull-requests for the options that aren't right for Welly. If there is an option that look like a good direction but needs some changes let me know and I can work on it further. Thanks, DC |
As you suggest, I'd rather fix the root cause. Cheers! |
This pull request addresses issue 126 "TypeError 0 is not a string (plotting well imported from welly-generated LAS)"
It handles the cases where 'TD' (Total Depth) is set to a non-numeric string either because it wasn't in the LAS file or 'TD' was in the las file but with a character value. In these cases it sets well.location.td to the python NoneType object.
Let me know if this change could be accepted (or rejected) or
needs some additional changes before being approved and merged.
Thank you,
DC