def test_duplicate_warning(recwarn): """Test warning triggers if duplicate component in CSV. """ Legend.from_csv(csv_duplicate) w = recwarn.pop() assert issubclass(w.category, UserWarning) assert 'duplicate' in str(w.message) assert w.lineno
def test_duplicate_warning(recwarn): """Test warning triggers if duplicate component in CSV. """ Legend.from_csv(text=csv_duplicate) w = recwarn.pop() assert issubclass(w.category, UserWarning) assert 'duplicate' in str(w.message) assert w.lineno
def test_error(): """Test errors are raised. """ rock = Component(r) # No component with pytest.raises(LegendError): Decor({'colour': 'red'}) # No decoration with pytest.raises(LegendError): Decor({'component': rock}) # Bad colour with pytest.raises(LegendError): Decor({'colour': 'blurple', 'component': rock}) # Adding incompatible things legend = Legend.from_csv(csv_text) with pytest.raises(LegendError): legend + rock # Tolerance not allowed. with pytest.raises(LegendError): legend.get_component('#f7e9a7', tolerance=-1)
def test_legend(): legend = Legend.from_csv(csv_text) assert legend[0].colour == '#f7e9a6' assert legend.max_width == 5 assert legend.__str__() != '' assert legend.__repr__() != '' rock = Component(r) assert legend.get_colour(rock) == '#eeeeee' rock3 = Component(r3) assert legend.get_colour(rock3) == '#ffdbba' assert legend.get_width(rock3) == 3.0 c = legend.get_component('#f7e9a6') assert c.lithology == 'sandstone' colours = [d.colour for d in legend] assert len(colours) == 8 l = Legend.random([rock, rock3]) assert l != legend assert getattr(l[-1], 'colour') != '' assert l.to_csv() != '' summed = legend + l assert len(summed) == 10
def test_legend(): """Test all the basics. """ legend = Legend.from_csv(csv_text) assert legend[0].colour == '#f7e9a6' assert legend.max_width == 5 assert legend.__str__() != '' assert legend.__repr__() != '' assert len(legend[[3, 4]]) == 2 assert len(legend[3:5]) == 2 rock = Component(r) assert legend.get_colour(rock) == '#eeeeee' assert rock not in legend d = Decor({'colour': 'red', 'component': rock}) length = len(legend) legend[3] = d assert len(legend) == length assert legend[3].component == rock assert d in legend rock3 = Component(r3) assert legend.get_colour(rock3) == '#ffdbba' assert legend.get_width(rock3) == 3.0 c = legend.get_component('#f7e9a6') assert c.lithology == 'sandstone' c2 = legend.get_component('#f7e9a7', tolerance=30) assert c2.lithology == 'sandstone' colours = [d.colour for d in legend] assert len(colours) == 8 assert Legend.random(rock3)[0].colour != '' l = Legend.random([rock, rock3]) assert len(l) == 2 assert getattr(l[-1], 'colour') != '' assert l.to_csv() != '' assert l.max_width == 0 l = Legend.random([rock, rock3], width=True, colour='#abcdef') assert getattr(l[0], 'colour') == '#abcdef' # Test sums. summed = legend + l assert len(summed) == 10 summed_again = legend + d assert len(summed_again) == 9 summed_again_again = d + legend assert len(summed_again_again) == 9 # Test equality. assert not d == legend
def test_legend(): """Test all the basics. """ legend = Legend.from_csv(text=csv_text) assert legend[0].colour == '#f7e9a6' assert legend.max_width == 5 assert legend.__str__() != '' assert legend.__repr__() != '' assert len(legend[[3, 4]]) == 2 assert len(legend[3:5]) == 2 rock = Component(r) assert legend.get_colour(rock) == '#eeeeee' assert rock not in legend d = Decor({'colour': 'red', 'component': rock}) length = len(legend) legend[3] = d assert len(legend) == length assert legend[3].component == rock assert d in legend rock3 = Component(r3) assert legend.get_colour(rock3) == '#ffdbba' assert legend.get_width(rock3) == 3.0 c = legend.get_component('#f7e9a6') assert c.lithology == 'sandstone' c2 = legend.get_component('#f7e9a7', tolerance=30) assert c2.lithology == 'sandstone' colours = [d.colour for d in legend] assert len(colours) == 8 assert Legend.random(rock3)[0].colour != '' l = Legend.random([rock, rock3]) assert len(l) == 2 assert getattr(l[-1], 'colour') != '' assert l.to_csv() != '' assert l.max_width == 0 l = Legend.random([rock, rock3], width=True, colour='#abcdef') assert getattr(l[0], 'colour') == '#abcdef' # Test sums. summed = legend + l assert len(summed) == 10 summed_again = legend + d assert len(summed_again) == 9 summed_again_again = d + legend assert len(summed_again_again) == 9 # Test equality. assert not d == legend
def test_tolerance_warning(recwarn): """Test warning triggers if tolerance too low. """ legend = Legend.from_csv(text=csv_text) legend.get_component('#f7e9a7', tolerance=0) w = recwarn.pop() assert issubclass(w.category, UserWarning) assert 'tolerance of 0' in str(w.message) assert w.lineno
def test_warning(recwarn): """Test warning triggers if tolerance too low. """ legend = Legend.from_csv(csv_text) legend.get_component('#f7e9a7', tolerance=0) w = recwarn.pop() assert issubclass(w.category, UserWarning) assert 'tolerance of 0' in str(w.message) assert w.lineno
def test_error(): """Test errors are raised. """ rock = Component(r) # Adding incompatible things legend = Legend.from_csv(text=csv_text) with pytest.raises(LegendError): _ = legend + rock assert _ # Tolerance not allowed. with pytest.raises(LegendError): legend.get_component('#f7e9a7', tolerance=-1)
def test_error(): """Test errors are raised. """ rock = Component(r) # Adding incompatible things legend = Legend.from_csv(csv_text) with pytest.raises(LegendError): _ = legend + rock assert _ # Tolerance not allowed. with pytest.raises(LegendError): legend.get_component('#f7e9a7', tolerance=-1)
def test_legend(): """Test all the basics. """ legend = Legend.from_csv(csv_text) assert legend[0].colour == '#f7e9a6' assert legend.max_width == 5 assert legend.__str__() != '' assert legend.__repr__() != '' assert len(legend[[3, 4]]) == 2 assert len(legend[3:5]) == 2 rock = Component(r) assert legend.get_colour(rock) == '#eeeeee' assert rock not in legend d = Decor({'colour': 'red', 'component': rock}) length = len(legend) legend[3] = d assert len(legend) == length assert legend[3].component == rock assert d in legend rock3 = Component(r3) assert legend.get_colour(rock3) == '#ffdbba' assert legend.get_width(rock3) == 3.0 c = legend.get_component('#f7e9a6') assert c.lithology == 'sandstone' c2 = legend.get_component('#f7e9a7', tolerance=30) assert c2.lithology == 'sandstone' colours = [d.colour for d in legend] assert len(colours) == 8 l = Legend.random([rock, rock3]) assert l != legend assert getattr(l[-1], 'colour') != '' assert l.to_csv() != '' summed = legend + l assert len(summed) == 10
return 'data:image/png;base64,{}'.format(encoded_image.decode()) app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) # Create server variable with Flask server object for use with gunicorn server = app.server # Get las files path = 'data/Poseidon_data/las/' # direct link to specific data lasfiles = glob(path + '*.LAS') # Get striplog files path2 = 'data/Poseidon_data/tops/' # direct link to specific data stripfiles = glob(path2 + '*.csv') legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv' ) # direct link to specific data p = Project.from_las( 'data/Poseidon_data/las/*.LAS') # direct link to specific data well_uwi = [w.uwi for w in p ] ##gets the well uwi data for use in the well-selector tool # Add striplogs to Project # Striplog must have the same name as LAS file. # e.g. Torosa-1.LAS and Torosa-1.csv for w in p: name = Path(w.fname).stem strip = Striplog.from_csv( f'data/Poseidon_data/tops/{name}.csv') # direct link to specific data w.data['tops'] = strip
print('\n LAS PATH:', path, '\n') lasfiles = glob(path + '*.LAS') for fname in lasfiles: print(' '*5, fname) print('\n') # Get striplog files path2 = 'data/Poseidon_data/tops/' print('\n STRIP PATH:', path2, '\n') stripfiles = glob(path2 + '*.csv') for fname in stripfiles: print(' '*5, fname) print('\n') tops_legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv') p = Project.from_las('data/Poseidon_data/las/*.LAS') well_uwi = [w.uwi for w in p] ##gets the well uwi data for use in the well-selector tool # Add striplogs to Project # Striplog must have the same name as LAS file. # e.g. Torosa-1.LAS and Torosa-1.csv for w in p: name = Path(w.fname).name.split('.')[0] new_path = f'data/Poseidon_data/tops/{name}.csv' print(name, new_path) strip = Striplog.from_csv(f'data/Poseidon_data/tops/{name}.csv') w.data['tops'] = strip
def test_error(): legend = Legend.from_csv(csv_text) rock = Component(r) with pytest.raises(LegendError): legend + rock