Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
imaspy/_version.py export-subst
.git_archival.txt export-subst
29 changes: 29 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: linting-and-code-formatting

on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout IMAS-Python sources
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install the code linting and formatting tools
run: pip install --upgrade 'black >=24,<25' flake8

- name: Check formatting of code with black
run: black --check imas

- name: Check linting with flake8
run: flake8 imas
67 changes: 67 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: build-wheel-and-publish-test-pypi

on: push

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m pip install pip setuptools wheel build
- name: Build a binary wheel and a source tarball
run: python3 -m build .
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish IMAS-Python distribution to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/imas-python
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
name: Publish IMAS-Python distribution to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/imas-python
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@unstable/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
13 changes: 4 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,16 @@ ENV/
*.swo

# SCM setuptools
imaspy/version.py

# Saxon symlink or downloaded file
saxon*.jar
imas/_version.py

# IMAS DD
data-dictionary
access-layer
containers/arch/imaspy/
containers/arch/imas/
containers/arch/data-dictionary/
containers/arch/access-layer/
imaspy/assets/IDSDef.zip
imas/assets/IDSDef.zip

# IDS files
*.ids
# *.ids

# ASV folder
/.asv
23 changes: 23 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"
jobs:
post_checkout:
- git fetch --unshallow || true

python:
install:
- method: pip
path: .
extra_requirements:
- docs
- netcdf
- h5py

sphinx:
builder: html
configuration: docs/source/conf.py
fail_on_warning: false
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Contributing guidelines

We welcome any kind of contribution to `imas-python`,
We welcome any kind of contribution to `IMAS-Python`,
from a simple comment, a question or even a full fledged pull
request.
Please first make sure you read and follow the
[Code of Conduct](CODE_OF_CONDUCT.md).

## You think you found a bug in the code, or have a question in its use
1. use the [issue search](https://github.com/iterorganization/imas-python/issues)
1. use the [issue search](https://github.com/iterorganization/IMAS-Python/issues)
to check if someone already created a similar issue;
3. if not, make a **new issue** to describe your problem or question.
In the case of a bug suspiscion, please try to give all the relevant
information to allow reproducing the error or identifying
its root cause (version of the imas-python, OS and relevant
its root cause (version of the IMAS-Python, OS and relevant
dependencies, snippet of code);
4. apply relevant labels to the issue.

## You want to make or ask some change to the code
1. use the [issue search](https://github.com/iterorganization/imas-python/issues)
1. use the [issue search](https://github.com/iterorganization/IMAS-Python/issues)
to check if someone already proposed a similar idea/change;
3. if not, create a **new issue** to describe what change you would like to see
implemented and specify it if you intend to work on it yourself or if some help
Expand Down
12 changes: 6 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include imaspy/assets/IDSDef.zip
include imaspy/assets/IDSDef2MDSpreTree.xsl
include imaspy/assets/ITER_134173_106_equilibrium.ids
include imaspy/assets/ITER_134173_106_core_profiles.ids
include imaspy/assets/equilibrium.ids
include imaspy/assets/core_profiles.ids
include imas/assets/IDSDef.zip
include imas/assets/IDSDef2MDSpreTree.xsl
include imas/assets/ITER_134173_106_equilibrium.ids
include imas/assets/ITER_134173_106_core_profiles.ids
include imas/assets/equilibrium.ids
include imas/assets/core_profiles.ids
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Data Model.
Install steps are described in the documentation generated from `/docs/source/installing.rst`.

Documentation is autogenerated from the source using [Sphinx](http://sphinx-doc.org/)
and can be found at the [ITER sharepoint](https://sharepoint.iter.org/departments/POP/CM/IMDesign/Code%20Documentation/IMAS-doc/index.html)
and can be found at the [readthedocs](https://imas-python.readthedocs.io/en/latest/)

The documentation can be manually generated by installing sphinx and running:

Expand Down Expand Up @@ -40,7 +40,7 @@ A quick 5 minutes introduction is available in the documentation generated from

## Legal

IMAS-Python is Copyright 2020-2024 ITER Organization, Copyright 2020-2023 Karel Lucas van de
IMAS-Python is Copyright 2020-2025 ITER Organization, Copyright 2020-2023 Karel Lucas van de
Plassche <karelvandeplassche@gmail.com>, Copyright 2020-2022 Daan van Vugt <dvanvugt@ignitioncomputing.com>,
and Copyright 2020 Dutch Institute for Fundamental Energy Research <info@differ.nl>.
It is licensed under [LGPL 3.0](LICENSE.txt).
Expand Down
6 changes: 3 additions & 3 deletions asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": 1,

// The name of the project being benchmarked
"project": "imaspy",
"project": "imas",

// The project's homepage
"project_url": "https://git.iter.org/projects/IMAS/repos/imaspy/browse",
"project_url": "https://github.com/iterorganization/IMAS-Python",

// The URL or local path of the source code repository for the
// project being benchmarked
Expand Down Expand Up @@ -53,7 +53,7 @@
//"install_timeout": 600,

// the base URL to show a commit for the project.
"show_commit_url": "https://git.iter.org/projects/IMAS/repos/imaspy/commits/",
"show_commit_url": "https://github.com/iterorganization/IMAS-Python/commits/main/",

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
Expand Down
27 changes: 17 additions & 10 deletions benchmarks/core_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import imaspy
import imas

from .utils import (
available_backends,
Expand All @@ -22,16 +22,16 @@ def fill_slices(core_profiles, times):
"""Fill a time slice of a core_profiles IDS with generated data.

Args:
core_profiles: core_profiles IDS (either from IMASPy or AL HLI)
core_profiles: core_profiles IDS (either from IMAS-Python or AL Python)
times: time values to fill a slice for
"""
core_profiles.ids_properties.homogeneous_time = 1 # HOMOGENEOUS
core_profiles.ids_properties.comment = "Generated for the IMASPy benchmark suite"
core_profiles.ids_properties.comment = "Generated for the IMAS-Python benchmark suite"
core_profiles.ids_properties.creation_date = datetime.date.today().isoformat()
core_profiles.code.name = "IMASPy ASV benchmark"
core_profiles.code.version = imaspy.__version__
core_profiles.code.name = "IMAS-Python ASV benchmark"
core_profiles.code.version = imas.__version__
core_profiles.code.repository = (
"https://git.iter.org/projects/IMAS/repos/imaspy/browse"
"https://github.com/iterorganization/IMAS-Python"
)

core_profiles.time = np.array(times)
Expand All @@ -50,7 +50,14 @@ def fill_slices(core_profiles, times):
profiles_1d.ion.resize(len(ions))
profiles_1d.neutral.resize(len(ions))
for i, ion in enumerate(ions):
profiles_1d.ion[i].label = profiles_1d.neutral[i].label = ion
if hasattr(profiles_1d.ion[i], 'label'):
profiles_1d.ion[i].label = ion
profiles_1d.neutral[i].label = ion
if hasattr(profiles_1d.ion[i], 'name'):
profiles_1d.ion[i].name = ion
profiles_1d.neutral[i].name = ion

# profiles_1d.ion[i].label = profiles_1d.neutral[i].label = ion
profiles_1d.ion[i].z_ion = 1.0
profiles_1d.ion[i].neutral_index = profiles_1d.neutral[i].ion_index = i + 1

Expand All @@ -74,7 +81,7 @@ def setup(self, hli, backend):

def time_get_slice(self, hli, backend):
for t in TIME:
self.dbentry.get_slice("core_profiles", t, imaspy.ids_defs.CLOSEST_INTERP)
self.dbentry.get_slice("core_profiles", t, imas.ids_defs.CLOSEST_INTERP)

def teardown(self, hli, backend):
if hasattr(self, "dbentry"): # imas + netCDF has no dbentry
Expand All @@ -96,8 +103,8 @@ class LazyGet:
param_names = ["lazy", "backend"]

def setup(self, lazy, backend):
self.dbentry = create_dbentry("imaspy", backend)
core_profiles = factory["imaspy"].core_profiles()
self.dbentry = create_dbentry("imas", backend)
core_profiles = factory["imas"].core_profiles()
fill_slices(core_profiles, TIME)
self.dbentry.put(core_profiles)

Expand Down
30 changes: 21 additions & 9 deletions benchmarks/edge_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import imaspy
import imas

from .utils import available_backends, create_dbentry, factory, hlis

Expand All @@ -17,18 +17,18 @@ def fill_ggd(edge_profiles, times):
"""Fill nested arrays of structures in grids_ggd and ggd substructures.

Args:
edge_profiles: edge_profiles IDS object (either from IMASPy or AL HLI)
edge_profiles: edge_profiles IDS object (either from IMAS-Python or AL Python)
times: time values to fill
"""
edge_profiles.ids_properties.homogeneous_time = (
imaspy.ids_defs.IDS_TIME_MODE_HETEROGENEOUS
imas.ids_defs.IDS_TIME_MODE_HETEROGENEOUS
)
edge_profiles.ids_properties.comment = "Generated for IMASPy benchmark suite"
edge_profiles.ids_properties.comment = "Generated for IMAS-Python benchmark suite"
edge_profiles.ids_properties.creation_date = datetime.date.today().isoformat()
edge_profiles.code.name = "IMASPy ASV benchmark"
edge_profiles.code.version = imaspy.__version__
edge_profiles.code.name = "IMAS-Python ASV benchmark"
edge_profiles.code.version = imas.__version__
edge_profiles.code.repository = (
"https://git.iter.org/projects/IMAS/repos/imaspy/browse"
"https://github.com/iterorganization/IMAS-Python"
)

# This GGD grid is not a valid description, but it's a good stress test for the
Expand All @@ -46,7 +46,13 @@ def fill_ggd(edge_profiles, times):
grid.space[i].identifier.index = 1
grid.space[i].identifier.description = "Description...."
grid.space[i].geometry_type.index = 0
grid.space[0].coordinates_type = np.array([4, 5], dtype=np.int32)
grid.space[0].coordinates_type.resize(1)
if imas.__version__ >= "4.0.0":
grid.space[0].coordinates_type = np.array([4, 5], dtype=np.int32)
else:
grid.space[0].coordinates_type[0].name = "coordinates type"
grid.space[0].coordinates_type[0].index = 0
grid.space[0].coordinates_type[0].name = "example coordinates type"
grid.space[0].objects_per_dimension.resize(3) # points, lines, surfaces
points = grid.space[0].objects_per_dimension[0].object
points.resize(N_POINTS)
Expand All @@ -61,7 +67,13 @@ def fill_ggd(edge_profiles, times):
for i in range(N_SURFACES):
surfaces[i].nodes = np.random.randint(1, N_LINES + 1, 4, dtype=np.int32)

grid.space[1].coordinates_type = np.array([6], dtype=np.int32)
grid.space[1].coordinates_type.resize(1)
if imas.__version__ >= "4.0.0":
grid.space[1].coordinates_type = np.array([6], dtype=np.int32)
else:
grid.space[1].coordinates_type[0].name = "coordinates type"
grid.space[1].coordinates_type[0].index = 0
grid.space[1].coordinates_type[0].name = "example coordinates type"
grid.space[1].objects_per_dimension.resize(2)
obp = grid.space[1].objects_per_dimension[0]
obp.object.resize(2)
Expand Down
Loading
Loading