Skip to content
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

5 cleanup project structure and workflows #16

Merged
merged 42 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
82cc502
Update README.md
elphick May 30, 2024
ee2d58f
initial set-up
elphick May 30, 2024
3a8f69a
initial set-up (#2)
elphick May 30, 2024
8993ad7
initial content migration with tests; moisture, pandas, base, sample
elphick Jun 5, 2024
7cb2491
cleaned up some examples, added elphick namespace, added api doc, MIT…
elphick Jun 6, 2024
3f0b41c
EOD progress
elphick Jun 7, 2024
7e61400
EOD - function flowsheet. working example.
elphick Jun 9, 2024
686ce8b
EOD - example cleanup, started ion validation. fixed to/from omf
elphick Jun 12, 2024
526d8ff
Work on the readers.
elphick Jun 16, 2024
6ce7a07
Added packages to pyproject.toml
elphick Jun 17, 2024
dbc5c36
initial setup - tests failing
elphick Jun 18, 2024
4253930
Merge branch 'main' into 1-set-up-project
elphick Jun 18, 2024
87b2d97
1 set up project (#4)
elphick Jun 18, 2024
19210ce
initial setup - tests failing
elphick Jun 19, 2024
4f671db
Merge remote-tracking branch 'origin/main' into main
elphick Jun 19, 2024
68a23ad
pyvista offscreen=True
elphick Jun 19, 2024
3ab8c5e
update env
elphick Jun 19, 2024
2f51395
update env #2
elphick Jun 19, 2024
ca75863
PYVISTA_OFF_SCREEN in conf.py
elphick Jun 19, 2024
384d7a2
PYVISTA_OFF_SCREEN using env:
elphick Jun 19, 2024
26110f4
change to build docs off main branch
elphick Jun 19, 2024
04b2df3
PYVISTA_OFF_SCREEN True as string
elphick Jun 19, 2024
673e6f0
removed autoclose in pv plots
elphick Jun 19, 2024
9152d8f
added pyvista/setup-headless-display-action
elphick Jun 19, 2024
ac5ef10
5 cleanup project structure and workflows (#6)
elphick Jun 19, 2024
3f32bf8
Merge branch 'main' into 5-cleanup-project-structure-and-workflows
elphick Jun 19, 2024
1c57ceb
passing tests
elphick Jun 19, 2024
693ca77
headless for tests
elphick Jun 19, 2024
0885099
skipped a test
elphick Jun 19, 2024
2c5647a
skip examples test in ci-cd
elphick Jun 19, 2024
8c692fa
5 cleanup project structure and workflows (#7)
elphick Jun 19, 2024
b66d70b
Merge branch 'main' into 5-cleanup-project-structure-and-workflows
elphick Jun 19, 2024
fbef883
import fix
elphick Jun 19, 2024
1928776
install the project to fix doc version import issue
elphick Jun 19, 2024
2329403
5 cleanup project structure and workflows (#8)
elphick Jun 19, 2024
d4d82e4
Merge branch 'main' into 5-cleanup-project-structure-and-workflows
elphick Jun 19, 2024
5c76039
docs on main branch only
elphick Jun 19, 2024
32a531a
5 cleanup project structure and workflows (#9)
elphick Jun 19, 2024
083b046
Merge branch 'main' into 5-cleanup-project-structure-and-workflows
elphick Jun 19, 2024
c01f985
skipped both tests for block models
elphick Jun 19, 2024
9f67319
set env var to skip example tests
elphick Jun 19, 2024
ab50908
Merge branch 'main' into 5-cleanup-project-structure-and-workflows
elphick Aug 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

import os
import sys

sys.path.insert(0, os.path.abspath('../..'))

from pathlib import Path

import numpy as np
import pyvista
import plotly
from plotly.io._sg_scraper import plotly_sg_scraper

sys.path.insert(0, os.path.abspath('../..'))
from sphinx_gallery.sorting import FileNameSortKey
from elphick import geomet

os.environ["PYVISTA_OFF_SCREEN"] = "True"
Expand Down
28 changes: 14 additions & 14 deletions docs/source/sg_execution_times.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**01:11.367** total execution time for 11 files **from all galleries**:
**00:36.744** total execution time for 11 files **from all galleries**:

.. container::

Expand All @@ -33,35 +33,35 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_examples_examples_04_block_model_02_create_block_model.py` (``..\..\examples\04_block_model\02_create_block_model.py``)
- 00:46.906
- 00:25.667
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_04_block_model_03_load_block_model.py` (``..\..\examples\04_block_model\03_load_block_model.py``)
- 00:08.296
- 00:04.207
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_01_getting_started_03_plot_demo.py` (``..\..\examples\01_getting_started\03_plot_demo.py``)
- 00:06.896
- 00:02.871
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_03_flowsheet_01_flowsheet_basics.py` (``..\..\examples\03_flowsheet\01_flowsheet_basics.py``)
- 00:03.337
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_01_getting_started_02_math_operations.py` (``..\..\examples\01_getting_started\02_math_operations.py``)
- 00:01.986
- 00:01.544
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_02_interval_sample_01_interval_sample.py` (``..\..\examples\02_interval_sample\01_interval_sample.py``)
- 00:01.957
- 00:00.961
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_01_getting_started_02_math_operations.py` (``..\..\examples\01_getting_started\02_math_operations.py``)
- 00:00.608
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_02_interval_sample_02_interval_data_sink_float.py` (``..\..\examples\02_interval_sample\02_interval_data_sink_float.py``)
- 00:00.702
- 00:00.356
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_01_getting_started_01_create_sample.py` (``..\..\examples\01_getting_started\01_create_sample.py``)
- 00:00.498
- 00:00.209
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_04_block_model_01_consuming_omf.py` (``..\..\examples\04_block_model\01_consuming_omf.py``)
- 00:00.450
- 00:00.187
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_06_map_01_mapping.py` (``..\..\examples\06_map\01_mapping.py``)
- 00:00.187
- 00:00.069
- 0.0
* - :ref:`sphx_glr_auto_examples_examples_05_mass_balance_01_mass_balance.py` (``..\..\examples\05_mass_balance\01_mass_balance.py``)
- 00:00.152
- 00:00.065
- 0.0
4 changes: 2 additions & 2 deletions examples/03_flowsheet/01_flowsheet_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# %%
#
# Create some Sample objects
# --------------------------
# -----------------------------------
#
# Create an object, and split it to create two more objects.

Expand Down Expand Up @@ -164,7 +164,7 @@
# Sometimes the network that is automatically created may not be what you are after - for example flow may be in
# the wrong direction. We'll learn how to modify an existing network, by picking up the network above.
#
# Let's break the links for the stream 1.
# Let's break the links for the _stream 1_.

fs.reset_stream_nodes(stream="stream 1")
fig = fs.table_plot()
Expand Down
Empty file added geomet/__init__.py
Empty file.
46 changes: 46 additions & 0 deletions tests/test_010_geoh5.py.hide
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from pathlib import Path

from geoh5py import Workspace
from geoh5py.data import Data
from geoh5py.groups import ContainerGroup
from geoh5py.objects import NoTypeObject


def test_project_load():
# load an existing geoh5 workspace
workspace_path = (Path(__file__).parents[1] / "Geoscience_ANALYST_demo_workspace_and_data" /
"GeoscienceANALYST_demo.geoh5")
if not workspace_path.exists():
raise FileNotFoundError(f"File not found: {workspace_path}")

workspace = Workspace(workspace_path)
print('done')

def test_create_new_project():
# create a new geoh5 workspace
if Path("data/test_workspace.geoh5").exists():
Path("data/test_workspace.geoh5").unlink()
workspace: Workspace = Workspace.create("data/test_workspace.geoh5")

# create a pandas dataframe
import pandas as pd
df = pd.DataFrame({
"column1": [5, 10, 20],
"column2": ["a", "b", "c"],
"column3": pd.to_datetime(["2010", "2011", "2012"]),
})

# create a group
group = ContainerGroup.create(workspace, name='my group')

# create an Object
obj = NoTypeObject.create(workspace, name='my object', parent=group)

# create some data
data1 = Data.create(workspace, name='column1', values=[1, 2, 3], entity=obj)
data2 = Data.create(workspace, name='column2', values=['a', 'b', 'c'], entity=obj)
data3 = Data.create(workspace, name='column3', values=[10, 20, 30], entity=obj)

# save the workspace
workspace.save_as("data/test_workspace_2.geoh5")
print('done')
94 changes: 94 additions & 0 deletions tests/test_011_file_readers.py.hide
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from pathlib import Path

import pandas as pd
import pyarrow.parquet as pq

from elphick.geomet.readers import ParquetFileReader, OMFFileReader


def create_parquet(num_cols=20, num_rows=10000, num_object_vars=2) -> Path:
import pandas as pd
import numpy as np
import pyarrow as pa

# Create num_cols - num_object_vars number of float columns
df = pd.DataFrame({f"column{i}": np.random.rand(num_rows) for i in range(num_cols - num_object_vars)})

# Create num_object_vars number of object columns
for i in range(num_object_vars):
df[f"column{num_cols - num_object_vars + i}"] = ['object_data'] * num_rows

table = pa.Table.from_pandas(df)
file_path = Path(f'test.{num_rows}x{num_cols}.parquet')
pq.write_table(table, file_path)
return file_path


# create_parquet()

def test_read_parquet():
file_path = Path('data/test.10000x20.parquet')
df = ParquetFileReader(file_path).read(columns=['column1', 'column2'])
assert not df.empty
assert len(df.columns) == 2
assert 'column1' in df.columns
assert 'column2' in df.columns
assert len(df) == 10000
assert df['column1'].dtype == float
assert df['column2'].dtype == float


def test_read_parquet_with_object_cols():
file_path = Path('data/test.10000x20.parquet')
df = ParquetFileReader(file_path).read(columns=['column1', 'column2', 'column18', 'column19'])
assert not df.empty
assert len(df.columns) == 4
assert 'column1' in df.columns
assert 'column2' in df.columns
assert 'column18' in df.columns
assert 'column19' in df.columns
assert len(df) == 10000
assert df['column1'].dtype == float
assert df['column2'].dtype == float
assert df['column18'].dtype == object
assert df['column19'].dtype == object
assert df['column18'].unique() == ['object_data']
assert df['column19'].unique() == ['object_data']


def test_read_parquet_with_query():
file_path = Path('data/test.10000x20.parquet')
df = ParquetFileReader(file_path).read(query="column1 > 0.5")
assert not df.empty
assert len(df) < 10000
assert df['column1'].dtype == float
assert (df['column1'] > 0.5).all()
assert len(df.columns) == 20


def test_read_parquet_with_query_and_columns():
file_path = Path('data/test.10000x20.parquet')
df = ParquetFileReader(file_path).read(columns=['column1', 'column2', 'column19'], query="column1 > 0.5")
assert not df.empty
assert len(df) < 10000
assert df['column1'].dtype == float
assert (df['column1'] > 0.5).all()
assert len(df.columns) == 3
assert 'column1' in df.columns
assert 'column2' in df.columns
assert 'column19' in df.columns
assert (df['column1'] > 0.5).all()
assert df['column19'].unique() == ['object_data']


def test_read_bm_parquet():
file_path = Path('data/block_model_copper.parquet')
df = ParquetFileReader(file_path).read(columns=['CU_pct'], query="CU_pct > 0.1")
assert not df.empty
assert len(df) < ParquetFileReader(file_path).records_in_file


def test_read_omf():
file_path = Path('data/test_model.omf')
df: pd.DataFrame = OMFFileReader(file_path, element='Block Model').read()
assert not df.empty
Loading