Coverage for pyguymer3/osterrain/loadASCIIcontents.py: 12%
8 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-16 08:31 +0000
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-16 08:31 +0000
1#!/usr/bin/env python3
3# Define function ...
4def loadASCIIcontents(
5 fObj,
6 n,
7 /,
8):
9 """Load the content from the file
11 Parameters
12 ----------
13 fObj : io.BytesIO
14 the file object
15 n : int
16 the number of lines to skip before reading the content
18 Returns
19 -------
20 contents : numpy.ndarray
21 the file content
23 Notes
24 -----
26 Copyright 2017 Thomas Guymer [1]_
28 References
29 ----------
30 .. [1] PyGuymer3, https://github.com/Guymer/PyGuymer3
31 """
33 # Import special modules ...
34 try:
35 import numpy
36 except:
37 raise Exception("\"numpy\" is not installed; run \"pip install --user numpy\"") from None
39 # **************************************************************************
41 # Read ASCII dataset (and reset pointer) ...
42 contents = numpy.loadtxt(
43 fObj,
44 delimiter = " ",
45 dtype = numpy.float32,
46 skiprows = n,
47 ) # [m]
48 fObj.seek(0)
50 # Return contents ...
51 return contents