FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix host memory detection on macOS by BrendanStork · Pull Request #71 · Algorithmiq/src-method · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .toml  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ classifiers = [
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = ["array-api-compat>=1.12", "numpy>=2.0,<3", "opt_einsum>=3.4.0"]
dependencies = ["array-api-compat>=1.12", "numpy>=2.0,<3", "opt_einsum>=3.4.0", "psutil"]


[project.optional-dependencies]
Expand Down
9 changes: 8 additions & 1 deletion src/src_method/utils/_backend.py
Show comments Show annotations View file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
synchronous no-ops, so the same algorithm code runs on both backends.
"""

from __future__ import annotations

import os
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Any, TypeAlias

import numpy as np
from array_api_compat import numpy as np_compat

import psutil

Check failure on line 22 in src/src_method/utils/_backend.py

View workflow job for this annotation

GitHub Actions / lint

ruff (I001)

src/src_method/utils/_backend.py:12:1: I001 Import block is un-sorted or un-formatted help: Organize imports

if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from types import ModuleType
Expand Down Expand Up @@ -378,10 +380,15 @@
for line in path.read_text().splitlines():
if line.startswith("MemAvailable:"):
return int(line.split()[1]) * 1024
return os.sysconf("SC_AVPHYS_PAGES") * os.sysconf("SC_PAGE_SIZE")

try:
return os.sysconf("SC_AVPHYS_PAGES") * os.sysconf("SC_PAGE_SIZE")
except (ValueError, OSError):
return psutil.virtual_memory().available



def sketch_dtype(dtype: DTypeLike | None, *inputs: Sequence[Site]) -> np.dtype:

Check failure on line 391 in src/src_method/utils/_backend.py

View workflow job for this annotation

GitHub Actions / lint

ruff (unformatted)

src/src_method/utils/_backend.py:390:1: unformatted: File would be reformatted
"""Resolve the sketch dtype.

Args:
Expand Down
Loading

Back | FazBrowse Home | New Git URL