Skip to content

Commit

Permalink
Maintainence fixes abound; updates to support python>=3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed May 21, 2024
1 parent ed0f74d commit 35e1d74
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 116 deletions.
8 changes: 0 additions & 8 deletions .bumpversion.cfg

This file was deleted.

26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

27 changes: 17 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.270
rev: v0.4.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: python-no-log-warn
- id: python-check-mock-methods

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v4.0.0-alpha.8
hooks:
- id: prettier
- id: prettier
files: 'docs/'
types_or: [javascript, ts, tsx, html, css]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.3.0'
rev: 'v1.10.0'
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tabWidth = 4
tabWidth = 2
singleQuote = true
bracketSpacing = false
16 changes: 16 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Copyright (c) 2024 Peyton Murray

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Empty file removed pyforc/__init__.py
Empty file.
Empty file removed pyforc/core/__init__.py
Empty file.
Empty file removed pyforc/main.py
Empty file.
103 changes: 100 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,113 @@
[build-system]
requires = [
"setuptools",
"wheel",
"bump2version",
"setuptools_scm"
]
build-backend = "setuptools.build_meta"

[project]
name = "pyforc"
dynamic = ["version"]
authors = [
{ name="Peyton Murray" },
]
description = "FORC analysis in Python"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
]
dependencies = [
"numpy",
"scipy",
"matplotlib",
]
urls = { Homepage = "https://github.com/peytondmurray/pyforc" }
license = { file = 'LICENSE' }


[tool.interrogate]
ignore-init-method = true
ignore-init-module = true
ignore-magic = true
ignore-module = true

[tool.setuptools_scm]

[tool.isort]
profile = "black"

[project.optional-dependencies]
dev = ["pre-commit>=3.6.0"]
test = ["pytest"]
doc = ["sphinx", "myst-parser"]

[tool.ruff]
line-length = 100
line-length = 88

[tool.ruff.lint]
select = [
# pycodestyle
"E",
"W",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
# pep8 naming
"N",
# pydocstyle
"D",
# annotations
"ANN",
# debugger
"T10",
# flake8-pytest
"PT",
# flake8-return
"RET",
# flake8-unused-arguments
"ARG",
# flake8-fixme
"FIX",
# flake8-eradicate
"ERA",
# pandas-vet
"PD",
# numpy-specific rules
"NPY",
]
ignore = [
"D104", # Missing docstring in public package
"D100", # Missing docstring in public module
"D211", # No blank line before class
"D213", # Multiline summary second line
"PD901", # Avoid using 'df' for pandas dataframes. Perfectly fine in functions with limited scope
"ANN201", # Missing return type annotation for public function (makes no sense for NoneType return types...)
"ANN101", # Missing type annotation for `self`
"ANN204", # Missing return type annotation for special method
"ANN002", # Missing type annotation for `*args`
"ANN003", # Missing type annotation for `**kwargs`
"D105", # Missing docstring in magic method
"D107", # Missing docstring in __init__
"D203", # 1 blank line before after class docstring
"D204", # 1 blank line required after class docstring
"D413", # 1 black line after parameters
"SIM108", # Simplify if/else to one line; not always clearer
"D206", # Docstrings should be indented with spaces; unnecessary when running ruff-format
"E501", # Line length too long; unnecessary when running ruff-format
"W191", # Indentation contains tabs; unnecessary when running ruff-format
"B905", # zip() without an explicit strict=; incompatible with python<3.12
]

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"test_*.py" = ["ANN001"]
23 changes: 0 additions & 23 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions src/pyforc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import core
File renamed without changes.
1 change: 1 addition & 0 deletions src/pyforc/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import config, coordinates, forc, forcdata, ingester, ops, plot
13 changes: 6 additions & 7 deletions pyforc/core/config.py → src/pyforc/core/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Class to hold configuration details for creating and analyzing FORC data."""
from __future__ import annotations

import dataclasses
from typing import Callable, Optional
from collections.abc import Callable

from .forcdata import ForcData

Expand All @@ -13,9 +12,9 @@ class Config:
Parameters
----------
file_name: str
file_name: str | None
Name of the file containing FORC data
step: Optional[float]
step: float | None
Step size to be used for the interpolated dataset; if None, step size is determined from the
step size used for the measurement
interpolation: str
Expand All @@ -38,12 +37,12 @@ class Config:
Smoothing factor to use for calculating the FORC distribution
"""

file_name: Optional[str] = None
step: Optional[float] = None
file_name: str | None = None
step: float | None = None
interpolation: str = "cubic"
drift_correction: bool = True
drift_kernel_size: int = 4
drift_density: int = 3
pipeline: Optional[list[Callable[[ForcData, Config], ForcData]]] = None
pipeline: list[Callable[[ForcData, "Config"], ForcData]] | None = None
h_sat: float = 0
smoothing_factor: int = 3
7 changes: 2 additions & 5 deletions pyforc/core/coordinates.py → src/pyforc/core/coordinates.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
"""Coordinate transformations for FORC data."""
from __future__ import annotations

import typing

import matplotlib.transforms as transforms


class Coordinates(transforms.Affine2D):
"""Base class for coordinates."""

name: typing.Optional[str] = None
name: str | None = None

@staticmethod
def from_str(name: str) -> Coordinates:
def from_str(name: str) -> "Coordinates":
"""Get the appropriate Coordinates class instance by name.
Parameters
Expand Down
6 changes: 2 additions & 4 deletions pyforc/core/forc.py → src/pyforc/core/forc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Classes for storing, extracting, and processing FORC data."""
from typing import Type

from .config import Config
from .ingester import IngesterBase


class Forc:
"""
Generic for storing, extracting, and processing FORC data.
"""Generic container for extracting and processing FORC data.
Parameters
----------
Expand All @@ -17,7 +15,7 @@ class Forc:
Config instance holding the ingester configuration details
"""

def __init__(self, ingester: Type[IngesterBase], config: Config):
def __init__(self, ingester: type[IngesterBase], config: Config):
self.config = config
self.ingester = ingester(self.config)
self.data = self.ingester.run()
18 changes: 8 additions & 10 deletions pyforc/core/forcdata.py → src/pyforc/core/forcdata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Containers for holding FORC data as arrays."""
from __future__ import annotations
from typing import Optional

import numpy as np

Expand Down Expand Up @@ -34,9 +32,9 @@ class ForcData:

def __init__(
self,
h_raw: Optional[list[np.ndarray]] = None,
m_raw: Optional[list[np.ndarray]] = None,
t_raw: Optional[list[np.ndarray]] = None,
h_raw: list[np.ndarray] | None = None,
m_raw: list[np.ndarray] | None = None,
t_raw: list[np.ndarray] | None = None,
m_drift: np.ndarray = None,
h: np.ndarray = None,
hr: np.ndarray = None,
Expand Down Expand Up @@ -68,17 +66,17 @@ def get_step(self) -> float:

@staticmethod
def from_existing(
data: ForcData,
h_raw: Optional[list[np.ndarray]] = None,
m_raw: Optional[list[np.ndarray]] = None,
t_raw: Optional[list[np.ndarray]] = None,
data: "ForcData",
h_raw: list[np.ndarray] | None = None,
m_raw: list[np.ndarray] | None = None,
t_raw: list[np.ndarray] | None = None,
m_drift: np.ndarray = None,
h: np.ndarray = None,
hr: np.ndarray = None,
m: np.ndarray = None,
t: np.ndarray = None,
rho: np.ndarray = None,
) -> ForcData:
) -> "ForcData":
"""Generate a new ForcData instance from the input, but override fields with the kwargs.
Parameters
Expand Down
Loading

0 comments on commit 35e1d74

Please sign in to comment.