Skip to content

Commit 82b60fa

Browse files
authored
Merge pull request #152 from hyperiongeo/synthetics2021
Synthetics Bugs
2 parents 672cefb + 022da34 commit 82b60fa

21 files changed

+255
-133
lines changed

.github/workflows/run-tests.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Run tests
55

66
on:
77
push:
8-
branches: [ develop, master ]
8+
branches: [ develop, main ]
99
pull_request:
10-
branches: [ develop ]
10+
branches: [ develop, main ]
1111

1212
jobs:
1313
build:
@@ -16,18 +16,17 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v4
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
3030
python -m pip install .[test]
3131
- name: Test with pytest
32-
run: |
33-
python run_tests.py
32+
run: pytest

AUTHORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ The following people have contributed to the project (in alphabetical order):
1010
- [Thomas Martin](https://github.com/ThomasMGeo), Colorado, USA
1111
- [Steve Purves](https://github.com/stevejpurves), Curvenote, Spain
1212
- [Patrick Reinhard](https://github.com/patrick-reinhard), Shell, The Netherlands
13-
- [DC Slagel](https://github.com/dcslagel), Shell, The Netherlands
13+
- [DC Slagel](https://github.com/dcslagel), Code Farm, Colorado, USA
1414
- [Miguel de la Varga](https://github.com/Leguark), Germany
1515
- [Wenting Xiong](https://github.com/wenting-x), Shell, The Netherlands

CODE_OF_CONDUCT.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Racist or racially biased remarks, attacks, or content.
28+
* Trolling, insulting/derogatory comments, and personal or political attacks
29+
* Public or private harassment
30+
* Publishing others' private information, such as a physical or electronic
31+
address, without explicit permission
32+
* Other conduct which could reasonably be considered inappropriate in a
33+
professional setting
34+
35+
## Our responsibilities
36+
37+
Project maintainers are responsible for clarifying the standards of acceptable
38+
behavior and are expected to take appropriate and fair corrective action in
39+
response to any instances of unacceptable behavior.
40+
41+
Project maintainers have the right and responsibility to remove, edit, or
42+
reject comments, commits, code, wiki edits, issues, and other contributions
43+
that are not aligned to this Code of Conduct, or to ban temporarily or
44+
permanently any contributor for other behaviors that they deem inappropriate,
45+
threatening, offensive, or harmful.
46+
47+
## Scope
48+
49+
This Code of Conduct applies within all project spaces, and it also applies when
50+
an individual is representing the project or its community in public spaces.
51+
Examples of representing a project or community include using an official
52+
project e-mail address, posting via an official social media account, or acting
53+
as an appointed representative at an online or offline event. Representation of
54+
a project may be further defined and clarified by project maintainers.
55+
56+
## Enforcement
57+
58+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
59+
reported by contacting any of the following people:
60+
61+
- Matt Hall, [[email protected]](mailto:[email protected])
62+
- Evan Bianco, [[email protected]](mailto:[email protected])
63+
64+
All complaints will be reviewed and investigated and will result in a response that
65+
is deemed necessary and appropriate to the circumstances. The project team is
66+
obligated to maintain confidentiality with regard to the reporter of an incident.
67+
Further details of specific enforcement policies may be posted separately.
68+
69+
Project maintainers who do not follow or enforce the Code of Conduct in good
70+
faith may face temporary or permanent repercussions as determined by other
71+
members of the project's leadership.
72+
73+
## Attribution
74+
75+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4,
76+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
77+
78+
For answers to common questions about this code of conduct, see
79+
https://www.contributor-covenant.org/faq

pyproject.toml

+57-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=48",
4-
"setuptools_scm[toml] >= 4, <6",
5-
"setuptools_scm_git_archive",
6-
"wheel >= 0.29.0",
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "welly"
7+
dynamic = ["version"]
8+
authors = [{ name = "The Welly Authors", email = "[email protected]" }]
9+
description = "Tools for making and managing well data."
10+
readme = "README.md"
11+
readme-content-type = "text/markdown"
12+
homepage = "https://github.com/agilescientific/welly"
13+
classifiers = [
14+
"Intended Audience :: Science/Research",
15+
"Development Status :: 4 - Beta",
16+
"Natural Language :: English",
17+
"Programming Language :: Python :: 3.6",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"License :: OSI Approved :: Apache Software License",
23+
"Operating System :: OS Independent"
24+
]
25+
dependencies = [
26+
"numpy",
27+
"scipy",
28+
"pandas",
29+
"matplotlib",
30+
"lasio",
31+
"striplog",
32+
"tqdm",
33+
"wellpathpy",
34+
"requests"
35+
]
36+
37+
[project.optional-dependencies]
38+
docs = ["sphinx", "sphinxcontrib-apidoc", "myst_nb", "furo"]
39+
test = ["pytest", "pytest-cov", "pytest-mpl"]
40+
dev = ["build", "pytest", "pytest-cov", "pytest-mpl", "sphinx", "sphinxcontrib-apidoc", "myst_nb", "furo"]
41+
42+
[tool.hatch.metadata]
43+
packages = ["welly"]
44+
45+
[tool.hatch.version]
46+
source = "vcs"
47+
48+
[tool.hatch.build.hooks.vcs]
49+
version-file = "_version.py"
50+
51+
[tool.pytest.ini_options]
52+
minversion = "6.0"
53+
addopts = [
54+
"--cov=welly",
55+
"--cov-config=pyproject.toml",
56+
"--mpl",
57+
"--mpl-baseline-path=tests/baseline",
758
]
8-
build-backend = "setuptools.build_meta"
59+
testpaths = ["tests"]
960

1061
[tool.setuptools_scm]
1162
write_to = "welly/_version.py"

run_tests.py

-20
This file was deleted.

setup.cfg

-39
This file was deleted.

setup.py

-6
This file was deleted.

tests/baseline/test_curve_2d_plot.png

2.73 KB
Loading
-5.1 KB
Loading

tests/test_plots.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
https://pypi.python.org/pypi/pytest-mpl/0.3
1111
"""
12+
import matplotlib.pyplot as plt
1213
import pytest
1314

1415
from welly import Well
@@ -114,7 +115,8 @@ def test_synthetic_plot():
114115
test_params = {'dt': 0.004}
115116
s = Synthetic(data, params=test_params)
116117

117-
fig = s.plot().get_figure()
118+
fig, ax = plt.subplots(figsize=(2, 10))
119+
s.plot(ax)
118120

119121
return fig
120122

@@ -127,7 +129,8 @@ def test_well_synthetic_plot():
127129
w = Well.from_las(FNAME)
128130
w.make_synthetic()
129131

130-
fig = w.data['Synthetic'].plot().get_figure()
132+
fig, ax = plt.subplots(figsize=(2, 10))
133+
w.data['Synthetic'].plot(ax)
131134

132135
return fig
133136

tests/test_synthetic.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf 8 -*-
22
"""
3-
Define a suite a tests for the Curve module.
3+
Define a suite a tests for the Synthetic class.
44
"""
55
import numpy as np
66

@@ -17,3 +17,18 @@ def test_synthetic():
1717

1818
assert s.dt == 0.004
1919
assert s.name == 'Synthetic'
20+
21+
22+
def test_synthetic_as_curve():
23+
"""
24+
Test synthetic to curve.
25+
"""
26+
data = np.array([4, 2, 0, -4, -2, 1, 3, 6, 3, 1, -2, -5, -1, 0])
27+
params = {'dt': 0.004}
28+
s = Synthetic(data, params=params)
29+
30+
crv = s.as_curve(0, 500, 0.1, mnemonic="SYNTH_CRV")
31+
32+
assert crv.index[0] == 0
33+
assert round((crv.index[1]-crv.index[0]),2) == 0.1
34+
assert crv.mnemonic == 'SYNTH_CRV'

tests/test_well.py

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import os
66
from pathlib import Path
77

8+
import pandas as pd
9+
810
import welly
911
from welly import Well
1012

@@ -148,3 +150,11 @@ def test_iter_well(well):
148150
for curve in well:
149151
assert curve == well.data['CALI']
150152
break
153+
154+
def test_df_object_cols(df):
155+
156+
df["Test object"] = "54"
157+
df["test_str"] = '1z'
158+
well = Well.from_df(df)
159+
assert all(well.df()["Test object"] == 54)
160+
assert all(well.df()["test_str"] == "1z")

welly/__init__.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
welly
44
==================
55
"""
6+
import sys
7+
68
from .project import Project
79
from .well import Well
810
from .header import Header
@@ -12,6 +14,7 @@
1214
from .crs import CRS
1315
from . import tools
1416
from . import quality
17+
from . import defaults
1518

1619

1720
def read_las(path, **kwargs):
@@ -66,17 +69,10 @@ def read_df(df, **kwargs):
6669
]
6770

6871

69-
from pkg_resources import get_distribution, DistributionNotFound
70-
71-
try:
72-
VERSION = get_distribution(__name__).version
73-
except DistributionNotFound:
74-
try:
75-
from ._version import version as VERSION
76-
except ImportError:
77-
raise ImportError(
78-
"Failed to find (autogenerated) _version.py. "
79-
"This might be because you are installing from GitHub's tarballs, "
80-
"use the PyPI ones."
81-
)
82-
__version__ = VERSION
72+
if sys.version_info >= (3, 8):
73+
from importlib import metadata
74+
else:
75+
import importlib_metadata as metadata
76+
77+
__version__ = metadata.version(__name__)
78+

0 commit comments

Comments
 (0)