Skip to content

Commit

Permalink
Added name to Interval
Browse files Browse the repository at this point in the history
First step for #108

Added new `name` arg to `Interval` constructor, and will set `self.name` to that, if it is passed.

Still need to think about where in the repr this attribute goes, and it will need to be caught in various methods that call `Interval`, such as `Striplog._build_list_of_intervals`. There do not seem to be many, on a quick search.
  • Loading branch information
mtb-za committed Apr 21, 2021
1 parent 0c68f63 commit 149a4aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions scratch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from striplog import Interval
from striplog import Lexicon

lexicon = Lexicon.default()

text = "wet silty fine sand with tr clay"

interval = Interval._parse_description(text, lexicon=lexicon, max_component=3, abbreviations=True)

print(interval)
8 changes: 6 additions & 2 deletions striplog/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def __init__(self, top, base=None,
data=None,
components=None,
max_component=1,
abbreviations=False):
abbreviations=False,
name=None):

if not isinstance(top, Position):
top = Position(middle=top)
Expand All @@ -70,6 +71,9 @@ def __init__(self, top, base=None,
if not isinstance(base, Position):
base = Position(middle=base)

if name:
self.name = name

self.top = top
if base is not None:
self.base = base
Expand Down Expand Up @@ -162,7 +166,7 @@ def _repr_html_(self):
"""
Jupyter Notebook magic repr function.
"""
items = ['top', 'primary', 'summary', 'description', 'data', 'base']
items = ['name', 'top', 'primary', 'summary', 'description', 'data', 'base']
rows = ''
row = '<tr>{row1}<td><strong>{e}</strong></td><td>{v}</td></tr>'
style = 'width:2em; background-color:#DDDDDD'
Expand Down

0 comments on commit 149a4aa

Please sign in to comment.