Skip to content

Commit

Permalink
Merge pull request #11 from SteveGrehl/dev
Browse files Browse the repository at this point in the history
Add Python 3.12 and Python 3.13 to build
  • Loading branch information
RLumSK authored Nov 17, 2024
2 parents 34d38e4 + 14bc84f commit 1a42187
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [macos-12, ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
architecture: ['x64']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: setup-conda
uses: s-weigand/setup-conda@v1.1.1
uses: s-weigand/setup-conda@v1
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
Expand Down
8 changes: 6 additions & 2 deletions conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
# Status of Python versions: https://devguide.python.org/versions/
# Also change github workflow in python-package-conda.yml
python_version:
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
- 3.11
- 3.12
- 3.13
80 changes: 80 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"__pycache__",
"_build",
"assets",
"buck-out",
"build",
"dist",
"docs",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.9
target-version = "py39"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"
4 changes: 1 addition & 3 deletions scripts/example2.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import xlum

try:
import matplotlib
from matplotlib import pyplot as plt
except ModuleNotFoundError:
import pip
pip.main(["install", "--user", "matplotlib"])
finally:
import matplotlib
from matplotlib import pyplot as plt
try:
import tkinter
from tkinter.filedialog import askopenfilename
except ModuleNotFoundError:
import pip
pip.main(["install", "--user", "tkinter"])
Expand Down
4 changes: 3 additions & 1 deletion src/xlum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__version__ = "0.0.8"

# make from_xlum available in package namespace
from .importer import from_xlum
# re-export avoids code scaning tools to mark it as unused
# see: https://docs.astral.sh/ruff/rules/unused-import/
from .importer import from_xlum as from_xlum
40 changes: 20 additions & 20 deletions src/xlum/data/classes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import base64
from dataclasses import dataclass, asdict
import logging
import re
from dataclasses import asdict, dataclass, field
from datetime import datetime
from functools import cached_property
from typing import Dict, List
import re
from lxml import etree

import pandas as pd
from functools import cached_property
import logging
from lxml import etree

from xlum.data.enumerations import CurveType, RecordType, State, SampleCondition
from xlum.data.enumerations import CurveType, RecordType, SampleCondition, State


class Xlum_DataFrame_Support(object):
Expand Down Expand Up @@ -110,25 +111,26 @@ def from_attributes(cls, dct: Dict) -> "XLum_Meta":
else:
attr["state"] = State[dct["state"].upper()]
except KeyError as ex:
logging.warning(f"KeyError: got {ex} expected one of {[s.name for s in State]}, using {State.UNKNOWN.name}")
logging.warning(
f"KeyError: got {ex} expected one of {[s.name for s in State]}, using {State.UNKNOWN.name}"
)
attr["state"] = State.UNKNOWN.name

return XLum_Meta(**attr)


@dataclass
class Curve(Xlum_DataFrame_Support):

lstValues: List = lambda: [] # internal list in the curve node

component: str = "NA"
startDate: datetime = datetime(2013, 1, 1, 3, 42, 42, 42)
curveType: CurveType = CurveType.UNKNOWN
duration: float = 0.0
offset: float = 0.0
xValues: List[
int
] = lambda: [] # see: https://stackoverflow.com/questions/52063759/passing-default-list-argument-to-dataclasses
xValues: List[int] = (
lambda: []
) # see: https://stackoverflow.com/questions/52063759/passing-default-list-argument-to-dataclasses
yValues: List[int] = lambda: []
tValues: List[int] = lambda: []
xLabel: str = "NA"
Expand All @@ -141,7 +143,7 @@ class Curve(Xlum_DataFrame_Support):
vUnit: str = "NA"
detectionWindow: str = "NA"
filter: str = "NA"
_meta: XLum_Meta = XLum_Meta(comment="empty curve")
_meta: XLum_Meta = field(default_factory=lambda: XLum_Meta(comment="empty curve"))

@classmethod
def from_element(cls, element: etree.Element) -> "Curve":
Expand Down Expand Up @@ -193,7 +195,9 @@ def from_element(cls, element: etree.Element) -> "Curve":
attr[k] = []
# check if values are base64 encoded
strValues = element.text
b64_pattern = re.compile('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$')
b64_pattern = re.compile(
"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$"
)
if re.fullmatch(b64_pattern, strValues):
strValues = base64.b64decode(strValues)
lstStrValues = re.findall(r"[\d]+[.,\d]+|[\d]*[.][\d]+|[\d]+", strValues)
Expand Down Expand Up @@ -244,14 +248,13 @@ def df(self) -> pd.DataFrame:

@dataclass
class Record(Xlum_DataFrame_Support):

lstCurves: List[Curve] = lambda: []

recordType: RecordType = RecordType.UNKNOWN
sequenceStepNumber: int = 0
sampleCondition: SampleCondition = SampleCondition.UNKNOWN

_meta: XLum_Meta = XLum_Meta(comment="empty record")
_meta: XLum_Meta = field(default_factory=lambda: XLum_Meta(comment="empty record"))

@classmethod
def from_element(cls, element: etree.Element) -> "Record":
Expand Down Expand Up @@ -294,7 +297,6 @@ def from_element(cls, element: etree.Element) -> "Record":

@dataclass
class Sequence(Xlum_DataFrame_Support):

lstRecords: List[Record] = lambda: []

fileName: str = "NA"
Expand All @@ -303,7 +305,7 @@ class Sequence(Xlum_DataFrame_Support):
readerSN: str = "NA"
readerFW: str = "NA"

_meta: XLum_Meta = XLum_Meta(comment="empty sequence")
_meta: XLum_Meta = field(default_factory=lambda: XLum_Meta(comment="empty sequence"))

@classmethod
def from_element(cls, element: etree.Element) -> "Sequence":
Expand Down Expand Up @@ -338,7 +340,6 @@ def from_element(cls, element: etree.Element) -> "Sequence":

@dataclass
class Sample(Xlum_DataFrame_Support):

lstSequences: List[Sequence] = lambda: []

name: str = "NA"
Expand All @@ -348,7 +349,7 @@ class Sample(Xlum_DataFrame_Support):
altitude: float = -1000.0
doi: str = "NA"

_meta: XLum_Meta = XLum_Meta(comment="empty sample")
_meta: XLum_Meta = field(default_factory=lambda: XLum_Meta(comment="empty sample"))

@classmethod
def from_element(cls, element: etree.Element) -> "Sample":
Expand Down Expand Up @@ -388,7 +389,6 @@ def from_element(cls, element: etree.Element) -> "Sample":

@dataclass
class XlumMeta(Xlum_DataFrame_Support):

lstSamples: List[Sample] = lambda: []

formatVersion: str = "NA"
Expand Down
2 changes: 0 additions & 2 deletions src/xlum/data/enumerations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from asyncio.base_futures import _FINISHED
import enum

from pkg_resources import UnknownExtra

class CurveType(enum.Enum):
NA=-2
Expand Down

0 comments on commit 1a42187

Please sign in to comment.