File: common.py

package info (click to toggle)
gemmi 0.6.5%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,836 kB
  • sloc: cpp: 54,719; python: 4,743; ansic: 3,972; sh: 384; makefile: 73; f90: 42; javascript: 12
file content (20 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import tempfile
try:
    import numpy
    numpy_version = tuple(int(n) for n in numpy.__version__.split('.')[:2])
except ImportError:
    numpy = None

def full_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)

def get_path_for_tempfile(suffix=''):
    handle, out_name = tempfile.mkstemp(suffix=suffix)
    os.close(handle)
    return out_name

def assert_numpy_equal(self, arr1, arr2):
    # equal_nan arg was added in NumPy 1.19.0
    if numpy and numpy_version >= (1,19):
        self.assertTrue(numpy.array_equal(arr1, arr2, equal_nan=True))