feat: many disparate updates for modernising
Some checks failed
gitea-physics/kalpa/pipeline/head There was a failure building this commit

This commit is contained in:
Deepak Mallubhotla 2025-02-21 15:58:12 -06:00
parent c5b76e6f24
commit a731a81c6a
Signed by: deepak
GPG Key ID: BEBAEBF28083E022
15 changed files with 229 additions and 59 deletions

View File

@ -13,9 +13,11 @@ from kalpaa.config import (
MeasurementTypeEnum,
)
def get_version() -> str:
return __version__
__all__ = [
"get_version",
"read_dots_and_binned",
@ -29,4 +31,4 @@ __all__ = [
"MeasurementTypeEnum",
]
logging.getLogger(__name__).addHandler(logging.NullHandler())
logging.getLogger(__name__).addHandler(logging.NullHandler())

View File

@ -9,6 +9,7 @@ def set_up_logging(
log_file: typing.Optional[str],
create_logfile_parents: bool = True,
):
handlers: typing.List[logging.Handler]
if log_file is None:
handlers = [
logging.StreamHandler(),

View File

@ -1,10 +1,7 @@
import dataclasses
import typing
import logging
from tantri.dipoles.types import Orientation
import kalpaa.config
_logger = logging.getLogger(__name__)
from pdme.model import (
LogSpacedRandomCountMultipleDipoleFixedMagnitudeModel,
@ -12,6 +9,8 @@ from pdme.model import (
LogSpacedRandomCountMultipleDipoleFixedMagnitudeFixedOrientationModel,
)
_logger = logging.getLogger(__name__)
def long_orientation_name(orientation: Orientation) -> str:
return {

View File

@ -36,7 +36,7 @@ class Coalescer:
def __init__(self, rows, num_replicas: int):
self.rows = rows
# sort into actuals, then dots, then probs
self.actual_dict = {}
self.actual_dict: dict = {}
for row in self.rows:
keys = Keys(row).all_keys()
_logger.debug(keys)

View File

@ -9,7 +9,8 @@ import csv
import deepdog.direct_monte_carlo.dmc_filters
import deepdog.direct_monte_carlo.compose_filter
import deepdog.direct_monte_carlo.cost_function_filter
import tantri.cli
# import tantri.cli
import pdme
import pdme.util.fast_v_calc
@ -257,7 +258,7 @@ class BinnedData:
self, dot_names: typing.Sequence[str]
) -> typing.Sequence[Measurement]:
_logger.debug(f"Constructing measurements for dots {dot_names=}")
ret = []
ret: typing.List[Measurement] = []
for dot_name in dot_names:
ret.extend(self._dot_to_measurement(dot_name))
return ret

View File

@ -12,7 +12,7 @@ import kalpaa.config
import argparse
# try not to use this out side of main or when defining config stuff pls
import numpy
# import numpy
_logger = logging.getLogger(__name__)
@ -91,31 +91,31 @@ def main():
# kalpa.TantriConfig(1234, 50, 0.0005, 10000),
]
override_config = {
# "test1": [
# tantri.dipoles.types.DipoleTO(
# numpy.array([0, 0, 100]),
# numpy.array([-2, -2, 2.9]),
# 0.0005
# )
# ],
"two_dipole_connors_geom": [
tantri.dipoles.types.DipoleTO(
numpy.array([0, 0, 100]), numpy.array([-2, -2, 5.75]), 0.0005
),
tantri.dipoles.types.DipoleTO(
numpy.array([0, 0, 100]), numpy.array([6, 2, 5.75]), 0.05
),
],
"two_dipole_connors_geom_omegaswap": [
tantri.dipoles.types.DipoleTO(
numpy.array([0, 0, 100]), numpy.array([-2, -2, 5.75]), 0.05
),
tantri.dipoles.types.DipoleTO(
numpy.array([0, 0, 100]), numpy.array([6, 2, 5.75]), 0.0005
),
],
}
# override_config = {
# # "test1": [
# # tantri.dipoles.types.DipoleTO(
# # numpy.array([0, 0, 100]),
# # numpy.array([-2, -2, 2.9]),
# # 0.0005
# # )
# # ],
# "two_dipole_connors_geom": [
# tantri.dipoles.types.DipoleTO(
# numpy.array([0, 0, 100]), numpy.array([-2, -2, 5.75]), 0.0005
# ),
# tantri.dipoles.types.DipoleTO(
# numpy.array([0, 0, 100]), numpy.array([6, 2, 5.75]), 0.05
# ),
# ],
# "two_dipole_connors_geom_omegaswap": [
# tantri.dipoles.types.DipoleTO(
# numpy.array([0, 0, 100]), numpy.array([-2, -2, 5.75]), 0.05
# ),
# tantri.dipoles.types.DipoleTO(
# numpy.array([0, 0, 100]), numpy.array([6, 2, 5.75]), 0.0005
# ),
# ],
# }
generation_config = kalpaa.GenerationConfig(
tantri_configs=tantri_configs,

View File

@ -1,7 +1,6 @@
#! /usr/bin/env poetry run python
import json
import pathlib
import argparse
import logging
import kalpaa

View File

@ -2,34 +2,19 @@ import argparse
import pathlib
# import csv
import numpy
import deepdog
import deepdog.direct_monte_carlo.compose_filter
import deepdog.indexify
import deepdog.direct_monte_carlo
import logging
# # import itertools
import pdme
import tantri.cli
import tantri.cli.file_importer
import tantri.dipoles.types
import typing
# import pdme.measurement
#
# # import random
# # import sys
# # import re
# # import math
# # import os
import json
# # from dataclasses import dataclass
#
#
# folder in curr dir
import kalpaa
import kalpaa.common

View File

@ -1,8 +1,6 @@
import argparse
import pathlib
# import csv
import numpy
import csv
import deepdog
import deepdog.cli.probs
@ -13,7 +11,6 @@ import deepdog.direct_monte_carlo
import logging
# # import itertools
import pdme
import kalpaa.stages
import kalpaa.stages.stage03_1

View File

@ -1,7 +1,5 @@
import kalpaa.common
import os
import logging
import argparse
import deepdog.results
import pathlib
from dataclasses import dataclass

View File

@ -68,17 +68,17 @@ INFERENCED_OUT_FIELDNAMES = [
def is_actual(row, actual_normal_orientation, actual_count):
_logger.debug(f"Check orientations")
_logger.debug("Check orientations")
row_or = row["orientation"]
_logger.debug(f"row: {row_or}, actual: {actual_normal_orientation}")
is_or = row_or == actual_normal_orientation
_logger.debug(f"Check counts")
_logger.debug("Check counts")
row_count = row["avg_filled"]
_logger.debug(f"row: {row_count}, actual: {actual_count}")
is_count = int(row_count) == int(actual_count)
_logger.debug(f"Check magnitude")
_logger.debug("Check magnitude")
row_logmag = row["log_magnitude"]
# TODO hardcoding
is_mag = int(row_logmag) == 2

174
poetry.lock generated
View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
[[package]]
name = "black"
@ -88,6 +88,117 @@ pdme = ">=1.5.0,<2.0.0"
scipy = "1.10"
tqdm = ">=4.66.2,<5.0.0"
[[package]]
name = "exceptiongroup"
version = "1.2.2"
description = "Backport of PEP 654 (exception groups)"
optional = false
python-versions = ">=3.7"
files = [
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
]
[package.extras]
test = ["pytest (>=6)"]
[[package]]
name = "flake8"
version = "4.0.1"
description = "the modular source code checker: pep8 pyflakes and co"
optional = false
python-versions = ">=3.6"
files = [
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
]
[package.dependencies]
mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.8.0,<2.9.0"
pyflakes = ">=2.4.0,<2.5.0"
[[package]]
name = "iniconfig"
version = "2.0.0"
description = "brain-dead simple config-ini parsing"
optional = false
python-versions = ">=3.7"
files = [
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
]
[[package]]
name = "mccabe"
version = "0.6.1"
description = "McCabe checker, plugin for flake8"
optional = false
python-versions = "*"
files = [
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
]
[[package]]
name = "mypy"
version = "1.14.1"
description = "Optional static typing for Python"
optional = false
python-versions = ">=3.8"
files = [
{file = "mypy-1.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:52686e37cf13d559f668aa398dd7ddf1f92c5d613e4f8cb262be2fb4fedb0fcb"},
{file = "mypy-1.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1fb545ca340537d4b45d3eecdb3def05e913299ca72c290326be19b3804b39c0"},
{file = "mypy-1.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:90716d8b2d1f4cd503309788e51366f07c56635a3309b0f6a32547eaaa36a64d"},
{file = "mypy-1.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ae753f5c9fef278bcf12e1a564351764f2a6da579d4a81347e1d5a15819997b"},
{file = "mypy-1.14.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e0fe0f5feaafcb04505bcf439e991c6d8f1bf8b15f12b05feeed96e9e7bf1427"},
{file = "mypy-1.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:7d54bd85b925e501c555a3227f3ec0cfc54ee8b6930bd6141ec872d1c572f81f"},
{file = "mypy-1.14.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f995e511de847791c3b11ed90084a7a0aafdc074ab88c5a9711622fe4751138c"},
{file = "mypy-1.14.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d64169ec3b8461311f8ce2fd2eb5d33e2d0f2c7b49116259c51d0d96edee48d1"},
{file = "mypy-1.14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ba24549de7b89b6381b91fbc068d798192b1b5201987070319889e93038967a8"},
{file = "mypy-1.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:183cf0a45457d28ff9d758730cd0210419ac27d4d3f285beda038c9083363b1f"},
{file = "mypy-1.14.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f2a0ecc86378f45347f586e4163d1769dd81c5a223d577fe351f26b179e148b1"},
{file = "mypy-1.14.1-cp311-cp311-win_amd64.whl", hash = "sha256:ad3301ebebec9e8ee7135d8e3109ca76c23752bac1e717bc84cd3836b4bf3eae"},
{file = "mypy-1.14.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:30ff5ef8519bbc2e18b3b54521ec319513a26f1bba19a7582e7b1f58a6e69f14"},
{file = "mypy-1.14.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cb9f255c18052343c70234907e2e532bc7e55a62565d64536dbc7706a20b78b9"},
{file = "mypy-1.14.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b4e3413e0bddea671012b063e27591b953d653209e7a4fa5e48759cda77ca11"},
{file = "mypy-1.14.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:553c293b1fbdebb6c3c4030589dab9fafb6dfa768995a453d8a5d3b23784af2e"},
{file = "mypy-1.14.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fad79bfe3b65fe6a1efaed97b445c3d37f7be9fdc348bdb2d7cac75579607c89"},
{file = "mypy-1.14.1-cp312-cp312-win_amd64.whl", hash = "sha256:8fa2220e54d2946e94ab6dbb3ba0a992795bd68b16dc852db33028df2b00191b"},
{file = "mypy-1.14.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:92c3ed5afb06c3a8e188cb5da4984cab9ec9a77ba956ee419c68a388b4595255"},
{file = "mypy-1.14.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:dbec574648b3e25f43d23577309b16534431db4ddc09fda50841f1e34e64ed34"},
{file = "mypy-1.14.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8c6d94b16d62eb3e947281aa7347d78236688e21081f11de976376cf010eb31a"},
{file = "mypy-1.14.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d4b19b03fdf54f3c5b2fa474c56b4c13c9dbfb9a2db4370ede7ec11a2c5927d9"},
{file = "mypy-1.14.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0c911fde686394753fff899c409fd4e16e9b294c24bfd5e1ea4675deae1ac6fd"},
{file = "mypy-1.14.1-cp313-cp313-win_amd64.whl", hash = "sha256:8b21525cb51671219f5307be85f7e646a153e5acc656e5cebf64bfa076c50107"},
{file = "mypy-1.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:7084fb8f1128c76cd9cf68fe5971b37072598e7c31b2f9f95586b65c741a9d31"},
{file = "mypy-1.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:8f845a00b4f420f693f870eaee5f3e2692fa84cc8514496114649cfa8fd5e2c6"},
{file = "mypy-1.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:44bf464499f0e3a2d14d58b54674dee25c031703b2ffc35064bd0df2e0fac319"},
{file = "mypy-1.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c99f27732c0b7dc847adb21c9d47ce57eb48fa33a17bc6d7d5c5e9f9e7ae5bac"},
{file = "mypy-1.14.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:bce23c7377b43602baa0bd22ea3265c49b9ff0b76eb315d6c34721af4cdf1d9b"},
{file = "mypy-1.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:8edc07eeade7ebc771ff9cf6b211b9a7d93687ff892150cb5692e4f4272b0837"},
{file = "mypy-1.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3888a1816d69f7ab92092f785a462944b3ca16d7c470d564165fe703b0970c35"},
{file = "mypy-1.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:46c756a444117c43ee984bd055db99e498bc613a70bbbc120272bd13ca579fbc"},
{file = "mypy-1.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:27fc248022907e72abfd8e22ab1f10e903915ff69961174784a3900a8cba9ad9"},
{file = "mypy-1.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:499d6a72fb7e5de92218db961f1a66d5f11783f9ae549d214617edab5d4dbdbb"},
{file = "mypy-1.14.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:57961db9795eb566dc1d1b4e9139ebc4c6b0cb6e7254ecde69d1552bf7613f60"},
{file = "mypy-1.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:07ba89fdcc9451f2ebb02853deb6aaaa3d2239a236669a63ab3801bbf923ef5c"},
{file = "mypy-1.14.1-py3-none-any.whl", hash = "sha256:b66a60cc4073aeb8ae00057f9c1f64d49e90f918fbcef9a977eb121da8b8f1d1"},
{file = "mypy-1.14.1.tar.gz", hash = "sha256:7ec88144fe9b510e8475ec2f5f251992690fcf89ccb4500b214b4226abcd32d6"},
]
[package.dependencies]
mypy_extensions = ">=1.0.0"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
typing_extensions = ">=4.6.0"
[package.extras]
dmypy = ["psutil (>=4.0)"]
faster-cache = ["orjson"]
install-types = ["pip"]
mypyc = ["setuptools (>=50)"]
reports = ["lxml"]
[[package]]
name = "mypy-extensions"
version = "1.0.0"
@ -181,6 +292,65 @@ docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-a
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"]
type = ["mypy (>=1.11.2)"]
[[package]]
name = "pluggy"
version = "1.5.0"
description = "plugin and hook calling mechanisms for python"
optional = false
python-versions = ">=3.8"
files = [
{file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"},
{file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"},
]
[package.extras]
dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"]
[[package]]
name = "pycodestyle"
version = "2.8.0"
description = "Python style guide checker"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
files = [
{file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"},
{file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"},
]
[[package]]
name = "pyflakes"
version = "2.4.0"
description = "passive checker of Python programs"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
files = [
{file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"},
{file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"},
]
[[package]]
name = "pytest"
version = "8.3.4"
description = "pytest: simple powerful testing with Python"
optional = false
python-versions = ">=3.8"
files = [
{file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"},
{file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"},
]
[package.dependencies]
colorama = {version = "*", markers = "sys_platform == \"win32\""}
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=1.5,<2"
tomli = {version = ">=1", markers = "python_version < \"3.11\""}
[package.extras]
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
[[package]]
name = "scipy"
version = "1.10.0"
@ -311,4 +481,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<3.10"
content-hash = "a23c50acc381141ba713781e3d768822aebc29c5a1e77e83f95e97181e929aa6"
content-hash = "257ebf05cb3f9a68400d459a4bf4186d1a2400659390f09ad790d7a80f0c609f"

View File

@ -15,6 +15,9 @@ tantri = "^1.3.0"
tomli = "^2.0.1"
[tool.poetry.group.dev.dependencies]
black = "^24.8.0"
flake8 = "^4.0.1"
mypy = ">=1.14"
pytest = ">=6"
[build-system]
requires = ["poetry-core"]
@ -26,3 +29,18 @@ stage02 = "kalpaa.stages.stage02:main"
stage03 = "kalpaa.stages.stage03:main"
stage04 = "kalpaa.stages.stage04:main"
kalpaa = "kalpaa.stages:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
[tool.mypy]
plugins = "numpy.typing.mypy_plugin"
[[tool.mypy.overrides]]
module = [
"tantri.*",
"tantri",
"deepdog",
"deepdog.*"
]
follow_untyped_imports = true