Skip to content

Commit

Permalink
Avoid import scipy.stats (#111)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
melund authored Mar 11, 2024
1 parent ba24e43 commit c865273
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ jobs:

test-linux-cloud:
runs-on: ubuntu-latest
container: ghcr.io/anybody/anybodycon-github-actions:latest_Beta
container: ghcr.io/anybody/anybodycon-github-actions:latest

needs: lint

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: install
run: pip install .
- uses: prefix-dev/[email protected]
with:
post-cleanup: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

- name: build
run: pixi run --frozen pip install .

- name: test
env:
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
run: pytest tests
run: pixi run --frozen pytest tests
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# AnyPyTools Change Log

## v1.11.5

**Fixed:**

* Speed up importing by avoiding importing scipy until it is needed.


## v1.11.4

**Fixed:**
Expand Down
2 changes: 1 addition & 1 deletion anypytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"NORMAL_PRIORITY_CLASS",
]

__version__ = "1.11.4"
__version__ = "1.11.5"


def print_versions():
Expand Down
5 changes: 3 additions & 2 deletions anypytools/macroutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from collections.abc import MutableSequence

import numpy as np
from scipy.stats import distributions

from anypytools.tools import define2str, path2str, array2anyscript

Expand Down Expand Up @@ -288,8 +287,10 @@ class SetValue_random(SetValue):
"""

def __init__(self, var, frozen_distribution, default_lower_tail_probability=0.5):
from scipy.stats.distributions import rv_frozen

self.var = var
if not isinstance(frozen_distribution, distributions.rv_frozen):
if not isinstance(frozen_distribution, rv_frozen):
raise TypeError(
"frozen_distribution must be frozen distribtuion from \
scipy.stats.distributions"
Expand Down

0 comments on commit c865273

Please sign in to comment.