Skip to content
Merged
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 src/my/body/exercise/cross_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def parse_mm_ss(x: str) -> timedelta:
# I guess would be nice to have a means of specifying type in the column? maybe multirow column names??
# need to look up org-mode standard..
mappers = {
'duration': lambda s: parse_mm_ss(s),
'duration': parse_mm_ss,
'date' : lambda s: tzify(parse_org_datetime(s)),
'comment' : str,
}
Expand Down
6 changes: 3 additions & 3 deletions src/my/core/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __eq__(self, other) -> bool:
1,
Exc('last'),
]
results = sort_res_by(ress, lambda x: int(x))
results = sort_res_by(ress, key=int)
assert results == [
1,
'bad',
Expand All @@ -143,10 +143,10 @@ def __eq__(self, other) -> bool:
Exc('last'),
]

results2 = sort_res_by([*ress, 0], lambda x: int(x))
results2 = sort_res_by([*ress, 0], key=int)
assert results2 == [Exc('last'), 0, *results[:-1]]

assert sort_res_by(['caba', 'a', 'aba', 'daba'], key=lambda x: len(x)) == ['a', 'aba', 'caba', 'daba']
assert sort_res_by(['caba', 'a', 'aba', 'daba'], key=len) == ['a', 'aba', 'caba', 'daba']
assert sort_res_by([], key=lambda x: x) == []


Expand Down
5 changes: 3 additions & 2 deletions src/my/core/orgmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from collections.abc import Callable, Iterable
from datetime import datetime
from typing import Self

from more_itertools import one
from orgparse import OrgNode
Expand Down Expand Up @@ -40,8 +41,8 @@ def one_table(o: OrgNode) -> Table:


class TypedTable(Table):
def __new__(cls, orig: Table) -> 'TypedTable':
tt = super().__new__(TypedTable)
def __new__(cls, orig: Table) -> Self:
tt = super().__new__(cls)
tt.__dict__ = orig.__dict__
blocks = list(orig.blocks)
header = blocks[0] # fist block is schema
Expand Down
2 changes: 1 addition & 1 deletion src/my/core/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,4 @@ def it3() -> Iterator[Res[S]]:
'error': [np.nan, 'RuntimeError: whoops\n', np.nan, "RuntimeError: ('exception with datetime', datetime.datetime(2024, 8, 19, 22, 47, 1, tzinfo=datetime.timezone.utc))\n"],
# note: dt column is added even if errors don't have an associated datetime
'dt' : [np.nan, np.nan , np.nan, '2024-08-19 22:47:01+00:00'],
}).astype(dtype={'dt': 'datetime64[ns, UTC]'})) # fmt: skip
}).astype(dtype={'dt': 'datetime64[us, UTC]'})) # fmt: skip
4 changes: 2 additions & 2 deletions src/my/core/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def df() -> pd.DataFrame:
'df': {
'count': 7,
'dtypes': {
'index': np.dtype('<M8[ns]'),
'value': np.dtype('O'),
'index': np.dtype('<M8[us]'),
'value': pd.StringDtype(storage='python', na_value=np.nan),
},
'first': pd.Timestamp('2024-02-10 08:00'),
'last': pd.Timestamp('2024-02-11 14:00'),
Expand Down
4 changes: 2 additions & 2 deletions src/my/core/utils/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_make_dict() -> None:

# check type inference
# TODO https://github.com/astral-sh/ty/issues/2095
_d2: dict[str, int] = make_dict(it, key=lambda i: str(i)) # ty: ignore[invalid-assignment]
_d3: dict[str, bool] = make_dict(it, key=lambda i: str(i), value=lambda i: i % 2 == 0) # ty: ignore[invalid-assignment]
_d2: dict[str, int] = make_dict(it, key=str) # ty: ignore[invalid-assignment]
_d3: dict[str, bool] = make_dict(it, key=str, value=lambda i: i % 2 == 0) # ty: ignore[invalid-assignment]


@decorator
Expand Down
2 changes: 1 addition & 1 deletion src/my/jawbone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def plot() -> None:
axarr = fig.subplots(nrows=len(sleeps))
for sleep, axes in zip(sleeps, axarr, strict=True):
plot_one(sleep, fig, axes, showtext=True)
used = melatonin_data.get(sleep.date_, None)
used = melatonin_data.get(sleep.date_)
sused: str
color: str
# used = True if used is None else False # TODO?
Expand Down
2 changes: 1 addition & 1 deletion src/my/photos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _get_geo() -> LatLon | None:

# TODO aware on unaware?
def _get_dt() -> datetime | None:
edt = exif.get(ExifTags.DATETIME, None)
edt = exif.get(ExifTags.DATETIME)
if edt is not None:
dtimes = edt.replace(' 24', ' 00') # jeez maybe log it?
if dtimes == "0000:00:00 00:00:00":
Expand Down
Loading