Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.22
rev: v0.16.4
hooks:
# Run the linter.
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/sic_mo_stephan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
},
"outputs": [],
"source": [
"from ceresfit import LinReg # to calculate linear regression\n",
"from ceresfit.unc_calc import error_bar_positions # to plot correlated error bars\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from ceresfit import LinReg # to calculate linear regression\n",
"from ceresfit.unc_calc import error_bar_positions # to plot correlated error bars\n",
"\n",
"from pgdtools import pgd"
]
Expand Down
4 changes: 2 additions & 2 deletions examples/ruthenium_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from iniabu import (\n",
" inimf,\n",
") # iniabu module with abundances as mass fractions - for models!\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import pgdtools\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/silicon_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""For Benoit: Compare some Si isotope ratios."""

from iniabu import inimf # import as mass_fraction values right away
import matplotlib.pyplot as plt
import numpy as np
from iniabu import inimf # import as mass_fraction values right away

import pgdtools

Expand Down Expand Up @@ -65,8 +65,8 @@
ax.set_ylim(ylim)

# labels for axes
ax.set_xlabel("$\delta^{30}$Si$_{28}$ (‰)")
ax.set_ylabel("$\delta^{29}$Si$_{28}$ (‰)")
ax.set_xlabel(r"$\delta^{30}$Si$_{28}$ (‰)")
ax.set_ylabel(r"$\delta^{29}$Si$_{28}$ (‰)")
ax.legend()

# aspect and layout
Expand Down
8 changes: 4 additions & 4 deletions examples/titanium_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""For Benoit: Compare some Ti isotope ratios."""

from iniabu import inimf # import as mass_fraction values right away
import matplotlib.pyplot as plt
import numpy as np
from iniabu import inimf # import as mass_fraction values right away

import pgdtools

Expand Down Expand Up @@ -79,14 +79,14 @@
a.set_ylim(ylim)

# labels for axes
a.set_xlabel("$\delta^{46}$Ti$_{48}$ (‰)")
a.set_xlabel(r"$\delta^{46}$Ti$_{48}$ (‰)")

# aspect and layout
a.set_aspect("equal")

# y label
ax[0].set_ylabel("$\delta^{47}$Ti$_{48}$ (‰)")
ax[1].set_ylabel("$\delta^{49}$Ti$_{48}$ (‰)")
ax[0].set_ylabel(r"$\delta^{47}$Ti$_{48}$ (‰)")
ax[1].set_ylabel(r"$\delta^{49}$Ti$_{48}$ (‰)")

fig.tight_layout()

Expand Down
2 changes: 1 addition & 1 deletion src/pgdtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"classify_sic_grain",
"data",
"db",
"pgd",
"maintainer",
"pgd",
]
2 changes: 1 addition & 1 deletion src/pgdtools/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def classify_sic_grain(
if not ret_probabilities:
return "U", None # unclassified
else:
return dict(zip(types, probabilities)) #
return dict(zip(types, probabilities))

c12_c13 = _replace_errors(c12_c13)
n14_n15 = _replace_errors(n14_n15)
Expand Down
3 changes: 2 additions & 1 deletion src/pgdtools/db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Local database management for various PGD versions."""

from pgdtools.data import BIBFILE, DB_JSON, REFERENCES_JSON, TECHNIQUES_JSON

from . import setup_local
from .config import DataBases
from .management import current, set_current, update
Expand All @@ -14,4 +15,4 @@
LOCAL_REF_JSON = LOCAL_PATH.joinpath(f"config/{REFERENCES_JSON.split('/')[-1]}")
LOCAL_TECH_JSON = LOCAL_PATH.joinpath(f"config/{TECHNIQUES_JSON.split('/')[-1]}")

__all__ = ["current", "DataBases", "set_current", "update"]
__all__ = ["DataBases", "current", "set_current", "update"]
2 changes: 1 addition & 1 deletion src/pgdtools/db/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Classes to deal with the configuration files."""

from datetime import datetime
import json
from datetime import datetime
from typing import Any, List

from pgdtools import db
Expand Down
8 changes: 3 additions & 5 deletions src/pgdtools/db/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import requests

from pgdtools import data
from pgdtools import db
from pgdtools import data, db


def current() -> Dict[str, Path]:
Expand All @@ -33,7 +32,7 @@ def current() -> Dict[str, Path]:
try:
curr = json.load(open(db.LOCAL_CURRENT, "r"))
except json.JSONDecodeError as err:
raise IOError(file_io_error) from err
raise OSError(file_io_error) from err

# turn values of keys into paths
curr_ret = {k: Path(v) for k, v in curr.items()}
Expand Down Expand Up @@ -166,5 +165,4 @@ def _download_file(url: str, local_file: Path) -> None:
raise ConnectionError(f"Connection error {rin.status_code} for url {url}.")

with open(local_file, "wb") as floc:
for chunk in rin.iter_content(chunk_size=8192):
floc.write(chunk)
floc.writelines(rin.iter_content(chunk_size=8192))
2 changes: 1 addition & 1 deletion src/pgdtools/db/setup_local.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Set up the local path for the database based on OS."""

from pathlib import Path
import sys
from pathlib import Path


def setup_path() -> Path:
Expand Down
4 changes: 2 additions & 2 deletions src/pgdtools/maintainer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Tools and routines for maintaining the PGD database."""

from .excel_tools import (
append_to_db_json,
append_reference_json,
append_techniques_json,
append_to_db_json,
)

__all__ = ["append_to_db_json", "append_reference_json", "append_techniques_json"]
__all__ = ["append_reference_json", "append_techniques_json", "append_to_db_json"]
4 changes: 2 additions & 2 deletions src/pgdtools/maintainer/excel_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
used with `pgdtools`.
"""

from datetime import datetime
import json
import warnings
from datetime import datetime
from pathlib import Path
from typing import Union
import warnings

import numpy as np
import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion src/pgdtools/sub_tools/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Sub tool to add filtering capabilities."""

from typing import List, Union, Tuple
from typing import List, Tuple, Union

import pgdtools
import pgdtools.sub_tools.utilities as utl
Expand Down
1 change: 0 additions & 1 deletion src/pgdtools/sub_tools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import Tuple


import pgdtools
import pgdtools.sub_tools.utilities as utl

Expand Down
2 changes: 1 addition & 1 deletion src/pgdtools/sub_tools/info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Sub tool to add information querying capabilities."""

from typing import List, Union, Set, Tuple
from typing import List, Set, Tuple, Union

import pgdtools
import pgdtools.sub_tools.utilities as utl
Expand Down
2 changes: 1 addition & 1 deletion src/pgdtools/sub_tools/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import itertools
import json
from typing import List, Set
import re
from typing import List, Set

import pandas as pd

Expand Down
2 changes: 1 addition & 1 deletion src/pgdtools/sub_tools/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for all tool modules in pgdtools."""

from typing import Iterable
from collections.abc import Iterable


class Isotope:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def pgd_setup(tmpdir_home, data_files_dir):

current_file = tmpdir_home.joinpath("current.json")
current_file.write_text(
f'{{"sic": "{str(sic_db.absolute())}", "gra": "{str(gra_db.absolute())}"}}'
f'{{"sic": "{sic_db.absolute()!s}", "gra": "{gra_db.absolute()!s}"}}'
) # noqa: B907


Expand Down
3 changes: 2 additions & 1 deletion tests/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np
import pytest

from pgdtools import classify as cl, classify_sic_grain, PresolarGrains
from pgdtools import PresolarGrains, classify_sic_grain
from pgdtools import classify as cl

# grains to test, following definitions:
# [
Expand Down
1 change: 0 additions & 1 deletion tests/test_data/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from pgdtools import data


ALL_URLS = [data.BIBFILE, data.DB_JSON, data.REFERENCES_JSON, data.TECHNIQUES_JSON]


Expand Down
3 changes: 2 additions & 1 deletion tests/test_db/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import requests_mock

from pgdtools import db
from pgdtools.db import DataBases, management as mgmt
from pgdtools.db import DataBases
from pgdtools.db import management as mgmt


def test_current_no_file():
Expand Down
1 change: 0 additions & 1 deletion tests/test_pgdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pgdtools.sub_tools.headers
import pgdtools.sub_tools.utilities as utl


# ISOTOPE CLASS #


Expand Down
3 changes: 1 addition & 2 deletions tests/test_sub_tools/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import pytest

from pgdtools import PresolarGrains
from pgdtools.sub_tools import filters as flt
from pgdtools.sub_tools import Filters

from pgdtools.sub_tools import filters as flt

# DUNDER METHODS #

Expand Down
1 change: 0 additions & 1 deletion tests/test_sub_tools/test_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from pgdtools.sub_tools import References


# DUNDER METHODS #


Expand Down
1 change: 0 additions & 1 deletion tests/test_sub_tools/test_techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from pgdtools.sub_tools import Techniques


# DUNDER METHODS #


Expand Down
Loading