Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
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: 2 additions & 2 deletions src/diffcalc_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""API to expose diffcalc-core methods."""

from . import config, core_types, database, openapi, server
from . import config, database, openapi, server
from ._version_git import __version__

__all__ = ["__version__", "server", "config", "database", "core_types", "openapi"]
__all__ = ["__version__", "server", "config", "database", "openapi"]
51 changes: 0 additions & 51 deletions src/diffcalc_api/core_types.py

This file was deleted.

44 changes: 41 additions & 3 deletions src/diffcalc_api/models/response.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
"""Pydantic models relating to all endpoint responses."""
from typing import Dict, List
from dataclasses import dataclass
from typing import Dict, List, Optional

from pydantic import BaseModel

from diffcalc_api.core_types import Orientation, Reflection
from diffcalc_api.models.ub import HklModel, MiscutModel, SphericalCoordinates, XyzModel
from diffcalc_api.models.ub import (
HklModel,
MiscutModel,
PositionModel,
SphericalCoordinates,
XyzModel,
)


class InfoResponse(BaseModel):
Expand Down Expand Up @@ -83,6 +89,38 @@ class MiscutResponse(BaseModel):
payload: MiscutModel


@dataclass
class Orientation:
"""Reference orientation of the sample.

Similar to diffcalc.ub.reference.Orientation
"""

h: float
k: float
l: float
x: float
y: float
z: float
pos: PositionModel
tag: Optional[str]


@dataclass
class Reflection:
"""Reference reflection of the sample.

Similar to diffcalc.ub.reference.Reflection
"""

h: float
k: float
l: float
pos: PositionModel
energy: float
tag: Optional[str]


class ReflectionResponse(BaseModel):
"""Response for any operation returning a reflection."""

Expand Down
7 changes: 4 additions & 3 deletions src/diffcalc_api/routes/ub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from fastapi import APIRouter, Body, Depends, Query

from diffcalc_api.core_types import Orientation, Position, Reflection
from diffcalc_api.errors.ub import (
BothTagAndIdxProvidedError,
InvalidSetLatticeParamsError,
Expand All @@ -15,8 +14,10 @@
ArrayResponse,
InfoResponse,
MiscutResponse,
Orientation,
OrientationResponse,
ReciprocalSpaceResponse,
Reflection,
ReflectionResponse,
SphericalResponse,
StringResponse,
Expand Down Expand Up @@ -100,7 +101,7 @@ async def get_reflection(
ref.h,
ref.k,
ref.l,
Position(**ref.pos.asdict),
PositionModel(**ref.pos.asdict),
ref.energy,
ref.tag,
)
Expand Down Expand Up @@ -246,7 +247,7 @@ async def get_orientation(
orient.x,
orient.y,
orient.z,
Position(**orient.pos.asdict),
PositionModel(**orient.pos.asdict),
orient.tag if orient.tag is not None else "",
)
return OrientationResponse(payload=orientation)
Expand Down