Skip to content

Commit c865273

Browse files
authored
Avoid import scipy.stats (#111)
* avoid importing scipy.stats.distributions * Update version to 1.11.5 and optimize importing for faster speed * Fix import statement in SetValue_random constructor * Update test.yml to use the latest container image and actions/checkout@v4 * Update
1 parent ba24e43 commit c865273

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

.github/workflows/test.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,23 @@ jobs:
4444

4545
test-linux-cloud:
4646
runs-on: ubuntu-latest
47-
container: ghcr.io/anybody/anybodycon-github-actions:latest_Beta
47+
container: ghcr.io/anybody/anybodycon-github-actions:latest
48+
4849
needs: lint
4950

5051
steps:
51-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v4
5253

53-
- name: install
54-
run: pip install .
54+
- uses: prefix-dev/[email protected]
55+
with:
56+
post-cleanup: true
57+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
58+
59+
- name: build
60+
run: pixi run --frozen pip install .
5561

5662
- name: test
5763
env:
5864
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
5965
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
60-
run: pytest tests
66+
run: pixi run --frozen pytest tests

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# AnyPyTools Change Log
22

3+
## v1.11.5
4+
5+
**Fixed:**
6+
7+
* Speed up importing by avoiding importing scipy until it is needed.
8+
9+
310
## v1.11.4
411

512
**Fixed:**

anypytools/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"NORMAL_PRIORITY_CLASS",
3838
]
3939

40-
__version__ = "1.11.4"
40+
__version__ = "1.11.5"
4141

4242

4343
def print_versions():

anypytools/macroutils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from collections.abc import MutableSequence
1313

1414
import numpy as np
15-
from scipy.stats import distributions
1615

1716
from anypytools.tools import define2str, path2str, array2anyscript
1817

@@ -288,8 +287,10 @@ class SetValue_random(SetValue):
288287
"""
289288

290289
def __init__(self, var, frozen_distribution, default_lower_tail_probability=0.5):
290+
from scipy.stats.distributions import rv_frozen
291+
291292
self.var = var
292-
if not isinstance(frozen_distribution, distributions.rv_frozen):
293+
if not isinstance(frozen_distribution, rv_frozen):
293294
raise TypeError(
294295
"frozen_distribution must be frozen distribtuion from \
295296
scipy.stats.distributions"

0 commit comments

Comments
 (0)