Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
d441795
Refactor validation imports and remove unused DataTypes references
AndrewSazonov Mar 14, 2026
f3c0c5d
Refactor value specification to use 'data_type' instead of 'type_' in…
AndrewSazonov Mar 14, 2026
5f381de
Refactor content_validator to validator in AttributeSpec
AndrewSazonov Mar 14, 2026
1ffe834
Refactor Cell class constructor to use default parameters and simplif…
AndrewSazonov Mar 14, 2026
9555cbc
Refactor AtomSite and SpaceGroup initializers to remove parameters an…
AndrewSazonov Mar 15, 2026
239dfb6
Refactor constructors in multiple classes to remove parameters and us…
AndrewSazonov Mar 15, 2026
a60bd9e
Refactor add method to accept only keyword arguments for improved cla…
AndrewSazonov Mar 15, 2026
440eee0
Refactor initialization of descriptors in multiple classes for consis…
AndrewSazonov Mar 15, 2026
9063ebb
Remove value initialization from validation class constructor
AndrewSazonov Mar 15, 2026
ae6287a
Refactor parameter value specification to remove DataTypes dependency
AndrewSazonov Mar 15, 2026
7c2aed4
Refactor parameter initialization and property methods in mixin files
AndrewSazonov Mar 15, 2026
682ebb2
Refactor: streamline CIF handler initialization and add public proper…
AndrewSazonov Mar 15, 2026
fe00821
Refactor ExperimentType initialization to use property setters
AndrewSazonov Mar 15, 2026
38aa8e0
Refactor ExperimentType initialization to use property setters
AndrewSazonov Mar 15, 2026
12ca9ed
Add temporary test script
AndrewSazonov Mar 15, 2026
67fd93c
Initialize parent class in guard.py constructor
AndrewSazonov Mar 15, 2026
0988190
Refactor peak-profile mixins to remove unused broadening and asymmetr…
AndrewSazonov Mar 15, 2026
f61a0ee
Refactor broadening parameter comments and remove unused initializati…
AndrewSazonov Mar 15, 2026
7df0b34
Refactor parameter definitions to streamline unit assignments in vari…
AndrewSazonov Mar 15, 2026
54b2286
Refactor CIF handler initialization for clarity and consistency
AndrewSazonov Mar 15, 2026
5973ce8
Refactor constructors in PdDataPoint mixins to remove kwargs
AndrewSazonov Mar 15, 2026
dc6adc4
Refactor parameters module to variable module; update imports across …
AndrewSazonov Mar 16, 2026
2759d32
Refactor import statements for consistency and clarity
AndrewSazonov Mar 16, 2026
56cdefe
Refactor sample models to structures in project and related files
AndrewSazonov Mar 16, 2026
58ab4a7
Refactor terminology from "sample" to "structure" in documentation an…
AndrewSazonov Mar 16, 2026
0c3e5cc
More refactoring from sample models to structures
AndrewSazonov Mar 16, 2026
7b6e7db
Refactor factory methods, etc.
AndrewSazonov Mar 17, 2026
927f829
Refactor method names from `add_from_scratch` to `create` for consist…
AndrewSazonov Mar 17, 2026
3213f39
Rebuild classes structure
AndrewSazonov Mar 17, 2026
30e08af
Refactor validation module by removing unused type checking decorator
AndrewSazonov Mar 17, 2026
3f063ef
Refactor PeakProfileTypeEnum to consider auto-extraction of peak prof…
AndrewSazonov Mar 17, 2026
6f5131e
Add revised design for all factories
AndrewSazonov Mar 17, 2026
ff808e7
Improve revised design for all factories
AndrewSazonov Mar 19, 2026
8811e5d
Add copilot instructions for EasyDiffraction project
AndrewSazonov Mar 20, 2026
750ccdc
Update all init files
AndrewSazonov Mar 20, 2026
394fdaf
Refactor metadata handling
AndrewSazonov Mar 20, 2026
636db7b
Refactor type hints for optional parameters in collection.py
AndrewSazonov Mar 20, 2026
cca9f4a
Add per-file ignores for __init__.py in Ruff configuration
AndrewSazonov Mar 20, 2026
c86cf66
Add TOF instrument and peak profile classes with compatibility and ca…
AndrewSazonov Mar 20, 2026
edce3d0
Clarify usage of keyword arguments in copilot instructions
AndrewSazonov Mar 22, 2026
daabe98
Add metadata dataclasses for factory-created classes
AndrewSazonov Mar 22, 2026
5121e7a
Refactor setter methods for improved readability and consistency
AndrewSazonov Mar 24, 2026
24a2e67
Refactor formatting of beam_mode and calculators in Chebyshev class
AndrewSazonov Mar 24, 2026
513be08
Update copilot instructions to clarify beta project guidelines
AndrewSazonov Mar 24, 2026
5d47e5e
Update copilot instructions to clarify refactoring guidelines
AndrewSazonov Mar 24, 2026
48502f8
Add architecture documentation for EasyDiffraction library
AndrewSazonov Mar 24, 2026
6a31c07
Refactor calculator management for joint and sequential fitting in ex…
AndrewSazonov Mar 24, 2026
ea001a3
Refactor code blocks in architecture.md to specify shell syntax highl…
AndrewSazonov Mar 24, 2026
2c000bc
Document current and potential architectural issues in the codebase
AndrewSazonov Mar 24, 2026
173ab0d
Document current and potential issues in architecture
AndrewSazonov Mar 24, 2026
79381e0
Document limitations of `FactoryBase` regarding constructor-variant r…
AndrewSazonov Mar 24, 2026
7701d00
Refactor calculator and minimizer factory methods for consistency and…
AndrewSazonov Mar 24, 2026
50d75e5
Refactor architecture documentation for improved clarity and consistency
AndrewSazonov Mar 24, 2026
3ac5cc8
Refactor logging and docstring formatting in analysis and factory mod…
AndrewSazonov Mar 24, 2026
793fd45
Refactor calculator and minimizer factory to use tag strings; update …
AndrewSazonov Mar 24, 2026
d2ebdc3
Refactor core factory structure to eliminate duplication and unify me…
AndrewSazonov Mar 24, 2026
7c3f558
Add initial experiment setup and analysis workflow for hrpt project
AndrewSazonov Mar 24, 2026
eb7f8fd
Update easydiffraction version and SHA-256 hash in pixi.lock
AndrewSazonov Mar 24, 2026
d3a0cd7
Refactor architecture documentation to clarify factory structures and…
AndrewSazonov Mar 24, 2026
291d0fc
Remove unused exports from __init__.py to streamline module interface
AndrewSazonov Mar 24, 2026
14ecfbb
Refactor string quotes in test.py for consistency and readability
AndrewSazonov Mar 24, 2026
9be2021
unify CollectionBase key resolution, add __contains__ and remove()
AndrewSazonov Mar 24, 2026
00c065b
Make ExperimentType immutable after creation
AndrewSazonov Mar 24, 2026
be9bac0
Make peak and background read-only public properties
AndrewSazonov Mar 24, 2026
0e7201e
Document editable vs read-only property convention with _set_ private…
AndrewSazonov Mar 24, 2026
6957b2f
Standardize switchable-category naming convention
AndrewSazonov Mar 24, 2026
dcbfb37
Apply formatting
AndrewSazonov Mar 24, 2026
efb4f35
Refactor Analysis class to instantiate calculator in __init__ and rem…
AndrewSazonov Mar 24, 2026
3407e7a
Remove duplicated symmetry methods from Structure
AndrewSazonov Mar 24, 2026
8562500
Route constraint updates through validated setter
AndrewSazonov Mar 24, 2026
d4f254c
Override _key_for in CategoryCollection and DatablockCollection
AndrewSazonov Mar 24, 2026
9d83fbc
Warn when switching background or peak profile type
AndrewSazonov Mar 24, 2026
433c193
Document why minimisers bypass the value setter
AndrewSazonov Mar 24, 2026
02fa44b
Replace 'lmfit (leastsq)' with 'lmfit' in tests, tutorials, and docs
AndrewSazonov Mar 24, 2026
c282976
Consolidate revised-design-v5.md into architecture.md
AndrewSazonov Mar 24, 2026
39ab41f
Apply formatting
AndrewSazonov Mar 24, 2026
8cf9d3b
Update copilot instructions for linting and testing workflow
AndrewSazonov Mar 24, 2026
8b34bb3
Enable dirty-flag guard via _set_value_from_minimizer
AndrewSazonov Mar 24, 2026
a019b55
Add factory.py and metadata.py to package structure documentation
AndrewSazonov Mar 24, 2026
52f90bf
Consolidate all issues into issues.md and update copilot instructions
AndrewSazonov Mar 24, 2026
9b46438
Move calculator from global Analysis to per-experiment
AndrewSazonov Mar 24, 2026
fc2f82b
Add Bragg+PDF joint tutorial, multi-experiment docs section, and test
AndrewSazonov Mar 25, 2026
19b2da2
Temporarily disable Bragg+PDF joint fit until test is improved
AndrewSazonov Mar 25, 2026
0353ef8
Add universal factories for Extinction and LinkedCrystal
AndrewSazonov Mar 25, 2026
2ab8179
Add universal factories for all remaining categories
AndrewSazonov Mar 25, 2026
9445d04
Update tutorial #14
AndrewSazonov Mar 25, 2026
500f3d9
Add switchable-category API to all factory-created categories
AndrewSazonov Mar 25, 2026
45df16f
Add switchable-category API for instrument and data on experiments
AndrewSazonov Mar 25, 2026
21b696e
Filter show_supported_instrument_types by experiment context
AndrewSazonov Mar 25, 2026
5ab9974
Add target-audience and reliability instructions to copilot config
AndrewSazonov Mar 25, 2026
b20c337
Convert fit_mode to CategoryItem
AndrewSazonov Mar 25, 2026
b91e3ec
Convert fit_mode to factory-based category with enum comparison
AndrewSazonov Mar 25, 2026
83e2398
Add flat category structure rule to architecture.md
AndrewSazonov Mar 25, 2026
a7bf2a8
Consolidate architecture docs and fix stale references
AndrewSazonov Mar 25, 2026
b9b01cf
Restructure help() to show Parameters, Properties, and Methods tables
AndrewSazonov Mar 25, 2026
84d7c20
Auto-populate Analysis.help() from class introspection
AndrewSazonov Mar 25, 2026
d89d133
Refine eager-imports rule to document lazy-import exceptions
AndrewSazonov Mar 25, 2026
060de26
Update tutorial structure in mkdocs.yml for clarity and consistency
AndrewSazonov Mar 25, 2026
651add7
Update issues list
AndrewSazonov Mar 25, 2026
a13b997
Add instruction to run tutorial tests after changes
AndrewSazonov Mar 25, 2026
1588441
Refactor background type naming for consistency
AndrewSazonov Mar 25, 2026
b70b3bd
Delete test.py
AndrewSazonov Mar 25, 2026
e7cfe2b
Fix tutorial failures and stale calculator cache with excluded regions
AndrewSazonov Mar 25, 2026
bb56ad0
Update issues [ci skip]
AndrewSazonov Mar 25, 2026
d575226
Update tutorial names and copyright year [ci skip]
AndrewSazonov Mar 25, 2026
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
136 changes: 136 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Copilot Instructions for EasyDiffraction

## Project Context

- Python library for crystallographic diffraction analysis, such as refinement
of the structural model against experimental data.
- Support for
- sample_form: powder and single crystal
- beam_mode: time-of-flight and constant wavelength
- radiation_probe: neutron and x-ray
- scattering_type: bragg and total scattering
- Calculations are done using external calculation libraries:
- `cryspy` for Bragg diffraction
- `crysfml` for Bragg diffraction
- `pdffit2` for Total scattering
- Follow CIF naming conventions where possible. In some places, we deviate for
better API design, but we try to keep the spirit of the CIF names.
- Reusing the concept of datablocks and categories from CIF. We have
`DatablockItem` (structure or experiment) and `DatablockCollection`
(collection of structures or experiments), as well as `CategoryItem` (single
categories in CIF) and `CategoryCollection` (loop categories in CIF).
- Metadata via frozen dataclasses: `TypeInfo`, `Compatibility`,
`CalculatorSupport`.
- The API is designed for scientists who use EasyDiffraction as a final product
in a user-friendly, intuitive way. The target users are not software
developers and may have little or no Python experience. The design is not
oriented toward developers building their own tooling on top of the library,
although experienced developers will find their own way. Prioritize
discoverability, clear error messages, and safe defaults so that
non-programmers are not stuck by standard API conventions.
- This project must be developed to be as error-free as possible, with the same
rigour applied to critical software (e.g. nuclear-plant control systems).
Every code path must be tested, edge cases must be handled explicitly, and
silent failures are not acceptable.

## Code Style

- Use snake_case for functions and variables, PascalCase for classes, and
UPPER_SNAKE_CASE for constants.
- Use `from __future__ import annotations` in every module.
- Type-annotate all public function signatures.
- Docstrings on all public classes and methods (Google style).
- Prefer flat over nested, explicit over clever.
- Write straightforward code; do not add defensive checks for unlikely edge
cases.
- Prefer composition over deep inheritance.
- One class per file when the class is substantial; group small related classes.
- Avoid `**kwargs`; use explicit keyword arguments for clarity, autocomplete,
and typo detection.
- Do not use string-based dispatch (e.g. `getattr(self, f'_{name}')`) to route
to attributes or methods. Instead, write explicit named methods (e.g.
`_set_sample_form`, `_set_beam_mode`). This keeps the code greppable,
autocomplete-friendly, and type-safe.
- Public parameters and descriptors are either **editable** (property with both
getter and setter) or **read-only** (property with getter only). If internal
code needs to mutate a read-only property, add a private `_set_<name>` method
instead of exposing a public setter.

## Architecture

- Eager imports at the top of the module by default. Use lazy imports (inside a
method body) only when necessary to break circular dependencies or to keep
`core/` free of heavy utility imports on rarely-called paths (e.g. `help()`).
- No `pkgutil` / `importlib` auto-discovery patterns.
- No background/daemon threads.
- No monkey-patching or runtime class mutation.
- Do not use `__all__` in modules; instead, rely on explicit imports in
`__init__.py` to control the public API.
- Do not use redundant `import X as X` aliases in `__init__.py`. Use plain
`from module import X`.
- Concrete classes use `@Factory.register` decorators. To trigger registration,
each package's `__init__.py` must explicitly import every concrete class (e.g.
`from .chebyshev import ChebyshevPolynomialBackground`). When adding a new
concrete class, always add its import to the corresponding `__init__.py`.
- Switchable categories (those whose implementation can be swapped at runtime
via a factory) follow a fixed naming convention on the owner (experiment,
structure, or analysis): `<category>` (read-only property), `<category>_type`
(getter + setter), `show_supported_<category>_types()`,
`show_current_<category>_type()`. The owner class owns the type setter and the
show methods; the show methods delegate to `Factory.show_supported(...)`
passing context. Every factory-created category must have this full API, even
if only one implementation exists today.
- Categories are flat siblings within their owner (datablock or analysis). A
category must never be a child of another category of a different type.
Categories can reference each other via IDs, but not via parent-child nesting.
- Every finite, closed set of values (factory tags, experiment axes, category
descriptors with enumerated choices) must use a `(str, Enum)` class. Internal
code compares against enum members, never raw strings.
- Keep `core/` free of domain logic — only base classes and utilities.
- Don't introduce a new abstraction until there is a concrete second use case.
- Don't add dependencies without asking.

## Changes

- Before implementing any structural or design change (new categories, new
factories, switchable-category wiring, new datablocks, CIF serialisation
changes), read `docs/architecture/architecture.md` to understand the current
design choices and conventions. Follow the documented patterns (factory
registration, switchable-category naming, metadata classification, etc.) to
stay consistent with the rest of the codebase. For localised bug fixes or test
updates, the rules in this file are sufficient.
- The project is in beta; do not keep legacy code or add deprecation warnings.
Instead, update tests and tutorials to follow the current API.
- Minimal diffs: don't rewrite working code just to reformat it.
- Never remove or replace existing functionality as part of a new change without
explicit confirmation. If a refactor would drop features, options, or
configurations, highlight every removal and wait for approval.
- Fix only what's asked; flag adjacent issues as comments, don't fix them
silently.
- Don't add new features or refactor existing code unless explicitly asked.
- Do not remove TODOs or comments unless the change fully resolves them.
- When renaming, grep the entire project (code, tests, tutorials, docs).
- Every change should be atomic and self-contained, small enough to be described
by a single commit message. Make one change, suggest the commit message, then
stop and wait for confirmation before starting the next change.
- When in doubt, ask for clarification before making changes.

## Workflow

- All open issues, design questions, and planned improvements are tracked in
`docs/architecture/issues_open.md`, ordered by priority. When an issue is
fully implemented, move it from that file to
`docs/architecture/issues_closed.md`. When the resolution affects the
architecture, update the relevant sections of
`docs/architecture/architecture.md`.
- After changes, run linting and formatting fixes with `pixi run fix`. Do not
check what was auto-fixed, just accept the fixes and move on.
- After changes, run unit tests with `pixi run unit-tests`.
- After changes, run integration tests with `pixi run integration-tests`.
- After changes, run tutorial tests with `pixi run script-tests`.
- Suggest a concise commit message (as a code block) after each change (less
than 72 characters, imperative mood, without prefixing with the type of
change). E.g.:
- Add ChebyshevPolynomialBackground class
- Implement background_type setter on Experiment
- Standardize switchable-category naming convention
1 change: 1 addition & 0 deletions docs/api-reference/datablocks/experiment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: easydiffraction.datablocks.experiment
1 change: 1 addition & 0 deletions docs/api-reference/datablocks/structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: easydiffraction.datablocks.structure
1 change: 0 additions & 1 deletion docs/api-reference/experiments.md

This file was deleted.

9 changes: 5 additions & 4 deletions docs/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ available in EasyDiffraction:
space groups, and symmetry operations.
- [utils](utils.md) – Miscellaneous utility functions for formatting,
decorators, and general helpers.
- datablocks
- [experiments](datablocks/experiment.md) – Manages experimental setups and
instrument parameters, as well as the associated diffraction data.
- [structures](datablocks/structure.md) – Defines structures, such as
crystallographic structures, and manages their properties.
- [display](display.md) – Tools for plotting data and rendering tables.
- [project](project.md) – Defines the project and manages its state.
- [sample_models](sample_models.md) – Defines sample models, such as
crystallographic structures, and manages their properties.
- [experiments](experiments.md) – Manages experimental setups and instrument
parameters, as well as the associated diffraction data.
- [analysis](analysis.md) – Provides tools for analyzing diffraction data,
including fitting and minimization.
- [summary](summary.md) – Provides a summary of the project.
1 change: 0 additions & 1 deletion docs/api-reference/sample_models.md

This file was deleted.

Loading
Loading