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
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"numpy",
"pydantic>=2.7.1",
"mat3ra-esse"

]

[project.optional-dependencies]
Expand Down
1 change: 1 addition & 0 deletions src/py/mat3ra/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
39 changes: 36 additions & 3 deletions src/py/mat3ra/prode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
import numpy as np
from enum import Enum
from types import SimpleNamespace

from mat3ra.esse.models.properties_directory.enum_options import (
ScalarPropertyEnum,
NonScalarPropertyEnum,
TensorPropertyEnum,
ObjectPropertyEnum,
ProtoPropertyEnum,
MetaPropertyEnum,
)

def get_length(vec: np.ndarray) -> float:
return float(np.linalg.norm(vec))

class AllPropertyEnum(str, Enum):
"""All property names combined from all categories"""
pass


for enum_class in [
ScalarPropertyEnum,
NonScalarPropertyEnum,
TensorPropertyEnum,
ObjectPropertyEnum,
ProtoPropertyEnum,
MetaPropertyEnum,
]:
for item in enum_class:
setattr(AllPropertyEnum, item.name, item.value)


PropertyName = SimpleNamespace(
scalar=ScalarPropertyEnum,
non_scalar=NonScalarPropertyEnum,
tensor=TensorPropertyEnum,
object=ObjectPropertyEnum,
proto=ProtoPropertyEnum,
meta=MetaPropertyEnum,
all=AllPropertyEnum,
)
14 changes: 5 additions & 9 deletions tests/py/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import numpy as np
import mat3ra.prode as prode

from mat3ra.prode import get_length


def test_get_length():
"""Test that get_length returns correct type and value."""
vec = np.array([1, 2])
result = get_length(vec)
assert isinstance(result, float)
assert np.isclose(result, np.sqrt(5))
def test_property_name_enum():
result = prode.PropertyName.non_scalar.band_gaps
assert result.value == "band_gaps"
assert isinstance(result.value, str)

Loading