pozo-bugfix-fork 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. pozo_bugfix_fork-1.0/LICENSE.txt +22 -0
  2. pozo_bugfix_fork-1.0/PKG-INFO +181 -0
  3. pozo_bugfix_fork-1.0/README.md +136 -0
  4. pozo_bugfix_fork-1.0/pozo_bugfix_fork/__init__.py +73 -0
  5. pozo_bugfix_fork-1.0/pozo_bugfix_fork/annotations.py +22 -0
  6. pozo_bugfix_fork-1.0/pozo_bugfix_fork/axes.py +89 -0
  7. pozo_bugfix_fork-1.0/pozo_bugfix_fork/drawable.py +103 -0
  8. pozo_bugfix_fork-1.0/pozo_bugfix_fork/graphs.py +527 -0
  9. pozo_bugfix_fork-1.0/pozo_bugfix_fork/renderers/__init__.py +8 -0
  10. pozo_bugfix_fork-1.0/pozo_bugfix_fork/renderers/hacks/__init__.py +26 -0
  11. pozo_bugfix_fork-1.0/pozo_bugfix_fork/renderers/plotly.py +1284 -0
  12. pozo_bugfix_fork-1.0/pozo_bugfix_fork/renderers/tree_table.py +152 -0
  13. pozo_bugfix_fork-1.0/pozo_bugfix_fork/themes/__init__.py +207 -0
  14. pozo_bugfix_fork-1.0/pozo_bugfix_fork/themes/mnemonic_tables.py +68 -0
  15. pozo_bugfix_fork-1.0/pozo_bugfix_fork/themes/theme_tools.py +153 -0
  16. pozo_bugfix_fork-1.0/pozo_bugfix_fork/traces.py +233 -0
  17. pozo_bugfix_fork-1.0/pozo_bugfix_fork/tracks.py +94 -0
  18. pozo_bugfix_fork-1.0/pozo_bugfix_fork/units/__init__.py +145 -0
  19. pozo_bugfix_fork-1.0/pozo_bugfix_fork/units/units.py +111 -0
  20. pozo_bugfix_fork-1.0/pozo_bugfix_fork.egg-info/PKG-INFO +181 -0
  21. pozo_bugfix_fork-1.0/pozo_bugfix_fork.egg-info/SOURCES.txt +28 -0
  22. pozo_bugfix_fork-1.0/pozo_bugfix_fork.egg-info/dependency_links.txt +1 -0
  23. pozo_bugfix_fork-1.0/pozo_bugfix_fork.egg-info/requires.txt +14 -0
  24. pozo_bugfix_fork-1.0/pozo_bugfix_fork.egg-info/top_level.txt +1 -0
  25. pozo_bugfix_fork-1.0/pyproject.toml +33 -0
  26. pozo_bugfix_fork-1.0/setup.cfg +4 -0
  27. pozo_bugfix_fork-1.0/tests/test_axes.py +113 -0
  28. pozo_bugfix_fork-1.0/tests/test_data.py +71 -0
  29. pozo_bugfix_fork-1.0/tests/test_graphs.py +9 -0
  30. pozo_bugfix_fork-1.0/tests/test_tracks.py +117 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: pozo_bugfix_fork
3
+ Version: 1.0
4
+ Summary: Help visualizing well log data - Herramienta para visualizar registros de pozo_bugfix_forks
5
+ License: MIT License
6
+
7
+ Copyright (c) [year] [fullname]
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE.txt
31
+ Requires-Dist: ood>=1.0.9
32
+ Requires-Dist: plotly>=5.18.0
33
+ Requires-Dist: colour>=0.1.5
34
+ Requires-Dist: pint>=0.23
35
+ Requires-Dist: pandas>=2.0.0
36
+ Requires-Dist: numpy>=1.26.0
37
+ Requires-Dist: kaleido>=0.2.1
38
+ Requires-Dist: ipywidgets
39
+ Requires-Dist: nbformat
40
+ Requires-Dist: lasio
41
+ Requires-Dist: anywidget
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ [para español](https://github.com/geopozo_bugfix_fork/pozo_bugfix_fork-py/blob/main/docs/es/L%C3%89ANME.md)
47
+
48
+ # NOTE 2026
49
+
50
+ pozo_bugfix_fork was forked from [pozo](https://github.com/geopozo/pozo-py) on 30 March 2026, in order to fix a number of minor bugs
51
+ which prevented the use of the current version and release of pozo. The reason it was created was
52
+ that there was no released version of pozo which worked with current major dependencies, particularly
53
+ IPython.
54
+
55
+ pozo_bugfix_fork was created from the last licensed release of pozo (June 21 2024: [f2a9c5d](https://github.com/geopozo/pozo-py/tree/f2a9c5dd8d5b54802813d0e3e0839f3b48e5b4ab)). The MIT license was removed in the following commit [b8951f8](https://github.com/geopozo/pozo-py/commit/b8951f8a696c38dfab9466628c38e6e46af06379). Subsequent commits made here were to fix the bugs described above
56
+ and create a renamed release "pozo_bugfix_fork". No further development is expected to occur on
57
+ pozo_bugfix_fork other than for support (if even that); please refer back to the original pozo repository.
58
+
59
+ # 🐰 pozo_bugfix_fork Well Visualizer
60
+
61
+ pozo_bugfix_fork is an open source, intuitive api for visualizing well logs. It uses [plotly](https://github.com/plotly/plotly.py) to render interactive graphs.
62
+
63
+ ```bash
64
+ $ pip install pozo_bugfix_fork
65
+ ```
66
+
67
+ Don't forget `pip install lasio` if you're using lasio! If you're using jupyter, `pip install ipywidgets nbformat` as well.
68
+
69
+ ## Simplest Usage
70
+
71
+ ```python
72
+ import pozo_bugfix_fork
73
+ import lasio
74
+ las = lasio.read("SALADIN.LAS")
75
+
76
+ # You can specify the data you are interested in
77
+ myGraph = pozo_bugfix_fork.Graph(las, include=["CALI", "CGR", "LLS", "ILD", "LLD", "NPH", "RHOB"])
78
+
79
+ # This is a good theme
80
+ myGraph.set_theme("cangrejo") # recommended theme!
81
+
82
+ myGraph.render(height=800, depth=[1080, 1180])
83
+
84
+ ```
85
+ <p align="center"><img src="docs/images/log_example2.png" /> </p>
86
+
87
+ <br />
88
+
89
+ Notice the tracks are in the same order as your list `include=[...]`.
90
+
91
+ **We have a new feature! [learn about crossplots](docs/en/users/CROSSPLOTS.md)**
92
+
93
+ ### Combining Tracks
94
+ ```
95
+ # Before you render
96
+
97
+ graph1.combine_tracks("CGR", "CALI") # Also maintains order!
98
+
99
+ graph1.combine_tracks("LLD","ILD","LLS")
100
+
101
+ graph1.combine_tracks("RHOB", "NPHI")
102
+
103
+ # Notice we change position of depth axis with `depth_position=1`
104
+ graph1.render(height=800, depth_position=1, depth=[1080, 1180])
105
+ ```
106
+ <p align="center"><img src="docs/images/log_example.png" /> </p>
107
+
108
+
109
+ A `pozo_bugfix_fork.Graph` is made up of `pozo_bugfix_fork.Track`, which is made up of `pozo_bugfix_fork.Axis`, which is made up of `pozo_bugfix_fork.Trace`, which contains `data` and `depth`.
110
+
111
+ #### Theming
112
+
113
+ ```
114
+ # Some possible settings:
115
+ # "color": "blue"
116
+ # "scale": "log"
117
+ # "range": [0, 10]
118
+ # "range_unit": "meter"
119
+ ```
120
+
121
+ Themes on more specific items (like `Axis`) override more general items (like `Track`). Calling `set_theme({})` on a `Trace` will override any theme on the `Axis`. If the theme on `Trace` lacks a key, the renderer will look in the `Axis` and so on and so forth.
122
+
123
+ *Note: Setting themes on `Trace` only works for certain keys, e.g. `Trace` doesn't decide color, `Axis` or above does*
124
+
125
+ The `"cangrejo"` theme above is a built-in `mnemonic` theme, it changes depending on the mnemonic.
126
+ ```
127
+ # Option One: Set a fallback for everything (only works if theme is set to "cangrejo")
128
+ graph.get_theme().set_fallback({"track_width":200})
129
+
130
+
131
+ # Option Two: Set a specific theme on a specific track:
132
+ graph.get_tracks("CGR")[0].set_theme({"track_width":200})
133
+
134
+ ```
135
+
136
+ [learn more about themeing](docs/en/users/THEMING.md)
137
+
138
+ #### Selecting Tracks
139
+
140
+ ```
141
+ # Returns list of Track objects
142
+ tracks = graph1.get_tracks("CGR", "MDP") # by name
143
+ other_tracks = graph1.get_tracks(0, 2) # by position
144
+
145
+ # Removes AND returns list of Track of objects
146
+ popped_tracks = graph1.pop_tracks("CGR", 3) # by name or position
147
+
148
+ # Note: The name is often the mnemonic. But not always, like in combined tracks.
149
+ # To search explicitly by mnemonic:
150
+ popped_tracks2 = graph1.pop_tracks(pozo_bugfix_fork.HasLog("CGR"))
151
+ ```
152
+
153
+ ## Adding Data Manually
154
+
155
+ #### Sometimes you want to do your own math and construct your own data:
156
+
157
+ ```
158
+ data = [1, 2, 3]
159
+ depth = [1010, 1020, 1030]
160
+
161
+ new_data=Data(data, depth=depth, mnemonic="LOL!")
162
+ graph.add_tracks(new_data)
163
+ # all data must have either a mnemonic or a name
164
+
165
+ ```
166
+ You can now call `graph.add_tracks(new_data)`
167
+
168
+ But maybe you want to theme it first. Don't theme the "Data" directly, it won't impact much. Instead:
169
+
170
+ ```
171
+ new_tracks = graph.add_tracks(new_data)
172
+ new_tracks[0].set_theme({"color":"red", range=[0, 1], range_unit="fraction"})
173
+ ```
174
+
175
+ [learn more about internals](docs/en/users/INTERNALS.md)
176
+
177
+ ## Sanitizing Data
178
+
179
+ ### Units
180
+
181
+ `pozo_bugfix_fork.units.check_las(las_object)` is a function that can help you verify the validy of LAS data. It will list the units it thinks it is and the ranges of values and number of NaNs.
@@ -0,0 +1,136 @@
1
+ [para español](https://github.com/geopozo_bugfix_fork/pozo_bugfix_fork-py/blob/main/docs/es/L%C3%89ANME.md)
2
+
3
+ # NOTE 2026
4
+
5
+ pozo_bugfix_fork was forked from [pozo](https://github.com/geopozo/pozo-py) on 30 March 2026, in order to fix a number of minor bugs
6
+ which prevented the use of the current version and release of pozo. The reason it was created was
7
+ that there was no released version of pozo which worked with current major dependencies, particularly
8
+ IPython.
9
+
10
+ pozo_bugfix_fork was created from the last licensed release of pozo (June 21 2024: [f2a9c5d](https://github.com/geopozo/pozo-py/tree/f2a9c5dd8d5b54802813d0e3e0839f3b48e5b4ab)). The MIT license was removed in the following commit [b8951f8](https://github.com/geopozo/pozo-py/commit/b8951f8a696c38dfab9466628c38e6e46af06379). Subsequent commits made here were to fix the bugs described above
11
+ and create a renamed release "pozo_bugfix_fork". No further development is expected to occur on
12
+ pozo_bugfix_fork other than for support (if even that); please refer back to the original pozo repository.
13
+
14
+ # 🐰 pozo_bugfix_fork Well Visualizer
15
+
16
+ pozo_bugfix_fork is an open source, intuitive api for visualizing well logs. It uses [plotly](https://github.com/plotly/plotly.py) to render interactive graphs.
17
+
18
+ ```bash
19
+ $ pip install pozo_bugfix_fork
20
+ ```
21
+
22
+ Don't forget `pip install lasio` if you're using lasio! If you're using jupyter, `pip install ipywidgets nbformat` as well.
23
+
24
+ ## Simplest Usage
25
+
26
+ ```python
27
+ import pozo_bugfix_fork
28
+ import lasio
29
+ las = lasio.read("SALADIN.LAS")
30
+
31
+ # You can specify the data you are interested in
32
+ myGraph = pozo_bugfix_fork.Graph(las, include=["CALI", "CGR", "LLS", "ILD", "LLD", "NPH", "RHOB"])
33
+
34
+ # This is a good theme
35
+ myGraph.set_theme("cangrejo") # recommended theme!
36
+
37
+ myGraph.render(height=800, depth=[1080, 1180])
38
+
39
+ ```
40
+ <p align="center"><img src="docs/images/log_example2.png" /> </p>
41
+
42
+ <br />
43
+
44
+ Notice the tracks are in the same order as your list `include=[...]`.
45
+
46
+ **We have a new feature! [learn about crossplots](docs/en/users/CROSSPLOTS.md)**
47
+
48
+ ### Combining Tracks
49
+ ```
50
+ # Before you render
51
+
52
+ graph1.combine_tracks("CGR", "CALI") # Also maintains order!
53
+
54
+ graph1.combine_tracks("LLD","ILD","LLS")
55
+
56
+ graph1.combine_tracks("RHOB", "NPHI")
57
+
58
+ # Notice we change position of depth axis with `depth_position=1`
59
+ graph1.render(height=800, depth_position=1, depth=[1080, 1180])
60
+ ```
61
+ <p align="center"><img src="docs/images/log_example.png" /> </p>
62
+
63
+
64
+ A `pozo_bugfix_fork.Graph` is made up of `pozo_bugfix_fork.Track`, which is made up of `pozo_bugfix_fork.Axis`, which is made up of `pozo_bugfix_fork.Trace`, which contains `data` and `depth`.
65
+
66
+ #### Theming
67
+
68
+ ```
69
+ # Some possible settings:
70
+ # "color": "blue"
71
+ # "scale": "log"
72
+ # "range": [0, 10]
73
+ # "range_unit": "meter"
74
+ ```
75
+
76
+ Themes on more specific items (like `Axis`) override more general items (like `Track`). Calling `set_theme({})` on a `Trace` will override any theme on the `Axis`. If the theme on `Trace` lacks a key, the renderer will look in the `Axis` and so on and so forth.
77
+
78
+ *Note: Setting themes on `Trace` only works for certain keys, e.g. `Trace` doesn't decide color, `Axis` or above does*
79
+
80
+ The `"cangrejo"` theme above is a built-in `mnemonic` theme, it changes depending on the mnemonic.
81
+ ```
82
+ # Option One: Set a fallback for everything (only works if theme is set to "cangrejo")
83
+ graph.get_theme().set_fallback({"track_width":200})
84
+
85
+
86
+ # Option Two: Set a specific theme on a specific track:
87
+ graph.get_tracks("CGR")[0].set_theme({"track_width":200})
88
+
89
+ ```
90
+
91
+ [learn more about themeing](docs/en/users/THEMING.md)
92
+
93
+ #### Selecting Tracks
94
+
95
+ ```
96
+ # Returns list of Track objects
97
+ tracks = graph1.get_tracks("CGR", "MDP") # by name
98
+ other_tracks = graph1.get_tracks(0, 2) # by position
99
+
100
+ # Removes AND returns list of Track of objects
101
+ popped_tracks = graph1.pop_tracks("CGR", 3) # by name or position
102
+
103
+ # Note: The name is often the mnemonic. But not always, like in combined tracks.
104
+ # To search explicitly by mnemonic:
105
+ popped_tracks2 = graph1.pop_tracks(pozo_bugfix_fork.HasLog("CGR"))
106
+ ```
107
+
108
+ ## Adding Data Manually
109
+
110
+ #### Sometimes you want to do your own math and construct your own data:
111
+
112
+ ```
113
+ data = [1, 2, 3]
114
+ depth = [1010, 1020, 1030]
115
+
116
+ new_data=Data(data, depth=depth, mnemonic="LOL!")
117
+ graph.add_tracks(new_data)
118
+ # all data must have either a mnemonic or a name
119
+
120
+ ```
121
+ You can now call `graph.add_tracks(new_data)`
122
+
123
+ But maybe you want to theme it first. Don't theme the "Data" directly, it won't impact much. Instead:
124
+
125
+ ```
126
+ new_tracks = graph.add_tracks(new_data)
127
+ new_tracks[0].set_theme({"color":"red", range=[0, 1], range_unit="fraction"})
128
+ ```
129
+
130
+ [learn more about internals](docs/en/users/INTERNALS.md)
131
+
132
+ ## Sanitizing Data
133
+
134
+ ### Units
135
+
136
+ `pozo_bugfix_fork.units.check_las(las_object)` is a function that can help you verify the validy of LAS data. It will list the units it thinks it is and the ranges of values and number of NaNs.
@@ -0,0 +1,73 @@
1
+ import ood
2
+ import pint
3
+ import numpy as np
4
+
5
+ ood.exceptions.NameConflictException.default_level = ood.exceptions.ErrorLevel.IGNORE
6
+ ood.exceptions.MultiParentException.default_level = ood.exceptions.ErrorLevel.IGNORE
7
+ from .traces import Trace # noqa
8
+ from .axes import Axis # noqa
9
+ from .tracks import Track # noqa
10
+ from .graphs import Graph # noqa
11
+ from .annotations import Note # noqa
12
+
13
+ import pozo_bugfix_fork.themes as themes # noqa
14
+ import pozo_bugfix_fork.renderers as renderers # noqa
15
+ import pozo_bugfix_fork.units as units # noqa
16
+
17
+ class pozo_bugfix_forkWarning(UserWarning):
18
+ pass
19
+
20
+ # These are all utility functions
21
+ def deLASio(mnemonic):
22
+ return mnemonic.split(":", 1)[0] if ":" in mnemonic else mnemonic
23
+
24
+ # is_array use the input data to verify if is pint data or other type that has
25
+ # __len__ and return a boolean. Be careful with this, it will return true for pozo_bugfix_fork objects.
26
+ def is_array(value):
27
+ if isinstance(value, str): return False
28
+ if isinstance(value, pint.Quantity):
29
+ return is_array(value.magnitude)
30
+ return hasattr(value, "__len__")
31
+
32
+
33
+ # is_scalar_number use the input data to verify if is a number data
34
+ def is_scalar_number(value):
35
+ number_types = (int, float,
36
+ np.float16, np.float32, np.float64,
37
+ np.int16, np.int32, np.int64)
38
+ if isinstance(value, pint.Quantity):
39
+ return is_scalar_number(value.magnitude)
40
+ return isinstance(value, number_types)
41
+
42
+ class HasLog(ood.selectors.Selector):
43
+ def __init__(self, mnemonic):
44
+ self.mnemonic = mnemonic
45
+ def _process(self, parent):
46
+ ret_items = []
47
+ for item in parent.get_items():
48
+ if hasattr(item, 'get_mnemonic'):
49
+ if item.get_mnemonic() == self.mnemonic:
50
+ ret_items.append(item)
51
+ if isinstance(item, ood.Observer):
52
+ if item.has_item(self):
53
+ ret_items.append(item)
54
+ return ret_items
55
+ def __repr__(self):
56
+ return f"HasLog({self.mnemonic})"
57
+
58
+ # verify_array_len use three inputs to verify the lenght in the data
59
+ def verify_array_len(constant, data):
60
+ if is_array(constant) and len(constant) != len(data): return False
61
+ return True
62
+
63
+ def str_to_HasLog(argument):
64
+ if isinstance(argument, (list, tuple)):
65
+ ret = []
66
+ for selector in argument:
67
+ ret.append(str_to_HasLog(selector))
68
+ return ret
69
+ elif isinstance(argument, str):
70
+ return HasLog(argument)
71
+ elif isinstance(argument, dict) and 'name' in argument:
72
+ return argument['name']
73
+ return argument
@@ -0,0 +1,22 @@
1
+ import pozo_bugfix_fork
2
+
3
+ #TODO this doesn't handle units
4
+ #TODO xp doesn't handle units or check indices
5
+ #TODO what else doesn't handle units
6
+ class Note():
7
+ def __init__(self, depth, *, line={}, text="", width=1, fillcolor = 'lightskyblue', opacity=.5, show_text=True):
8
+ if not ( ( pozo_bugfix_fork.is_array(depth) and len(depth) == 2 ) or pozo_bugfix_fork.is_scalar_number(depth) ):
9
+ raise TypeError("depth must be two numbers in a tuple or list or just one number")
10
+ if not isinstance(line, dict):
11
+ raise TypeError("line must be a dictionary")
12
+ if width < -1 or width > 1:
13
+ raise ValueError("width must be between -1 and 1")
14
+ # TODO add further constraints on changes
15
+ self.depth = depth
16
+ self.line = line
17
+ self.fillcolor = fillcolor
18
+ self.opacity = None
19
+ self.show_text = True
20
+ self.text = text
21
+ self.width = width
22
+
@@ -0,0 +1,89 @@
1
+ import ood
2
+ import pozo_bugfix_fork
3
+ import pozo_bugfix_fork.themes as pzt
4
+
5
+
6
+ class Axis(ood.Item, pzt.Themeable):
7
+
8
+ def set_name(self, name):
9
+ return super().set_name(name)
10
+
11
+ def get_name(self):
12
+ return super().get_name()
13
+
14
+ _type = "axis"
15
+ _child_type = "trace"
16
+
17
+ def __init__(self, *args, **kwargs):
18
+ super().__init__(**kwargs)
19
+ for ar in args:
20
+ self.add_traces(ar)
21
+
22
+ def _check_types(self, *traces):
23
+ accepted_types = (pozo_bugfix_fork.Trace)
24
+ raw_return = []
25
+ for trace in traces:
26
+ if isinstance(trace, list):
27
+ raw_return.extend(self._check_types(*trace))
28
+ elif not isinstance(trace, accepted_types):
29
+ raise TypeError(f"Axis.add_traces() only accepts pozo_bugfix_fork.Trace, or a single list of pozo_bugfix_fork.Trace, not {type(trace)}")
30
+ else:
31
+ raw_return.append(trace)
32
+ return raw_return
33
+
34
+ def replace_traces(self, *traces, **kwargs):
35
+ mnemonics = []
36
+ for trace in traces:
37
+ mnemonics.append(trace.get_mnemonic())
38
+ self.pop_traces(*mnemonics, strict_index=False, exclude=kwargs.get('exclude', None))
39
+ self.add_traces(*traces, **kwargs)
40
+
41
+ # add_items
42
+ def add_traces(self, *traces, **kwargs):
43
+ good_traces = self._check_types(*traces)
44
+ super().add_items(*good_traces, **kwargs)
45
+ return good_traces
46
+
47
+ # get_items
48
+ def get_traces(self, *selectors, **kwargs):
49
+ selectors = pozo_bugfix_fork.str_to_HasLog(selectors)
50
+ return super().get_items(*selectors, **kwargs)
51
+
52
+ # get_item
53
+ def get_trace(self, selector=0, **kwargs):
54
+ selector = pozo_bugfix_fork.str_to_HasLog(selector)
55
+ return super().get_item(selector, **kwargs)
56
+
57
+ # pop items
58
+ def pop_traces(self, *selectors, **kwargs):
59
+ selectors = pozo_bugfix_fork.str_to_HasLog(selectors)
60
+ return super().pop_items(*selectors, **kwargs)
61
+
62
+ # what about whitelabelling all the other stuff
63
+ def has_trace(self, selector):
64
+ selector = pozo_bugfix_fork.str_to_HasLog(selector)
65
+ return super().has_item(selector)
66
+
67
+ def reorder_all_traces(self, order):
68
+ order = pozo_bugfix_fork.str_to_HasLog(order)
69
+ super().reorder_all_items(order)
70
+
71
+ def move_traces(self, *selectors, **kwargs):
72
+ selectors = pozo_bugfix_fork.str_to_HasLog(selectors)
73
+ super().move_items(*selectors, **kwargs)
74
+
75
+ def get_named_tree(self):
76
+ result = []
77
+ for el in self.get_traces():
78
+ result.append(el.get_named_tree())
79
+ return { "axis" : { self.name: result } }
80
+
81
+ def get_theme(self):
82
+ mnemonics = []
83
+ for d in self.get_traces():
84
+ mnemonics.append(d.get_mnemonic())
85
+ context = { "type":"axis",
86
+ "name": self._name,
87
+ "mnemonics": mnemonics,
88
+ }
89
+ return self._get_theme(context=context)
@@ -0,0 +1,103 @@
1
+ import ood
2
+ import pozo_bugfix_fork.themes as pzt
3
+ import warnings
4
+ # test versions
5
+ # do some string and object representations of everything
6
+ # do some tests (fix themes)
7
+ # do help
8
+ # render this
9
+ # separate renderer into renderTrace and renderInterval
10
+ # write about mira geoscience
11
+ # think more about versions and copies
12
+
13
+ class VersionedProperty:
14
+ def __set_name__(self, owner, name):
15
+ if type(owner) == str(Drawable):
16
+ raise AttributeError(f"{name} must be a member of a class inheriting pozo_bugfix_fork.drawable.Drawable, not {owner}. Is type {type(owner)}.")
17
+ self._private_name = "_" + name
18
+ self._name = name
19
+
20
+ def __get__(self, obj, objtype=None):
21
+ if obj is None:
22
+ return AttributeError(f"{self._name} can only be accessed from instantiated ojects, not classes")
23
+ return getattr(obj, self._private_name)[obj.version]
24
+
25
+ def __set__(self, obj, value):
26
+ if id(self) not in obj._versioned_properties: obj._versioned_properties[id(self)] = self
27
+ temp = getattr(obj, self._private_name, None)
28
+ if temp is None:
29
+ temp = [value]
30
+ setattr(obj, self._private_name, temp)
31
+ else:
32
+ temp[obj.version] = value
33
+
34
+ def __delete__(self, obj):
35
+ raise AttributeError(f"Can't delete {self._name}, please use {obj.__name__}.remove_version().")
36
+
37
+ def new_version(self, obj, copy=True, deep=True, index=-1):
38
+ if deep: copy = False
39
+ if index == -1:
40
+ index = obj._latest_version
41
+ temp = getattr(obj, self._private_name, None)
42
+ if temp is None:
43
+ temp = [None]
44
+ setattr(obj, self._private_name, temp)
45
+ if deep and hasattr(temp[max(index-1, 0)], "deepcopy"):
46
+ temp.insert(index, temp[max(index-1, 0)].deepcopy())
47
+ if copy and hasattr(temp[max(index-1, 0)], "copy"):
48
+ temp.insert(index, temp[max(index-1, 0)].copy())
49
+ else:
50
+ temp.insert(index, None)
51
+ if deep or copy:
52
+ warnings.warn(f"{self._name} was asked for a copy but it contains no native .copy() method, new version is None")
53
+
54
+ def remove_version(self, obj, version):
55
+ temp = getattr(obj, self._private_name, None)
56
+ if temp is None: return
57
+ temp.pop(version)
58
+
59
+ class Drawable(ood.Observed, pzt.Themeable):
60
+ def __init__(self, *args, **kwargs):
61
+ self.version = 0
62
+ self._latest_version = 0
63
+ self._versioned_properties = {}
64
+ super().__init__(*args, **kwargs)
65
+
66
+ @property # makes it read only
67
+ def latest_version(self):
68
+ return self._latest_version
69
+
70
+ def new_version(self, copy=False, deep=True):
71
+ self._latest_version += 1
72
+ self.version = self._latest_version
73
+ for prop in self._versioned_properties.values():
74
+ prop.new_version(self, copy=copy, deep=deep)
75
+
76
+ def insert_version(self, copy=False, deep=True):
77
+ self._latest_version += 1
78
+ self.version += 1
79
+ for prop in self._versioned_properties.values():
80
+ prop.new_version(self, copy=copy, deep=deep, index=self.version)
81
+
82
+ def remove_version(self, version=None):
83
+ if self._latest_version == 0: raise RuntimeError("Cannot pop last version")
84
+ if version > self._latest_version: return None
85
+ self._latest_version -= 1
86
+ if version < self.version:
87
+ self.version = self.version-1
88
+ self.version = min(max(self.version, 0), self._latest_version)
89
+ for prop in self._versioned_properties.values():
90
+ prop.remove_version(self, version)
91
+
92
+ # list all versions
93
+ def list_version(self):
94
+ return [
95
+ { 'version': i,
96
+ 'data': d[0],
97
+ 'unit': d[1],
98
+ 'note': d[2]
99
+ } for i, d in enumerate(zip(self.__data, self.__unit, self.__note))
100
+ ]
101
+
102
+ # change versions (semi permanently)
103
+ # get data and unit w/ a version