smpl 1.5.2__tar.gz → 1.5.3.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {smpl-1.5.2 → smpl-1.5.3.dev5}/PKG-INFO +1 -1
- {smpl-1.5.2 → smpl-1.5.3.dev5}/pyproject.toml +2 -2
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/_version.py +2 -2
- smpl-1.5.3.dev5/smpl/debug/__init__.py +1 -0
- smpl-1.5.3.dev5/smpl/debug/debug.py +529 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/plot.py +2 -4
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/plot2d.py +3 -5
- smpl-1.5.2/smpl/.plot.py.swp +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/.github/dependabot.yml +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/.github/workflows/ci.yml +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/.gitignore +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/.pre-commit-config.yaml +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/.readthedocs.yml +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/LICENSE +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/Makefile +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/README.md +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/animation/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/animation/animation.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/data.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/doc/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/doc/doc.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/fit.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/functions.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/interpolate.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/cat.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/grep.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/head.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/io.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/read_buffer.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/sed.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/io/tail.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/latex.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/parallel/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/parallel/parallel.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/stat.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/util/__init__.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/util/util.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/smpl/wrap.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/fit/test_fit_algos.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_data.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_fit.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_fit_lambda.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_fit_str.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_grid.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_style_image.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_style_pcolormesh.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_style_scatter.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_xscale.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/baseline/test_yscale.png +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/test_mpl_fit.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/test_mpl_plot2d.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/mpl/test_mpl_smplr.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/plot/test_fit.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/plot/test_plot.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/test_animation.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/test_linear.txt +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/test_wrap.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/tests/test_line_profiling.py +0 -0
- {smpl-1.5.2 → smpl-1.5.3.dev5}/tests/tests/test_line_profiling_doctests.py +0 -0
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '1.5.
|
|
21
|
-
__version_tuple__ = version_tuple = (1, 5,
|
|
20
|
+
__version__ = version = '1.5.3.dev5'
|
|
21
|
+
__version_tuple__ = version_tuple = (1, 5, 3, 'dev5')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .debug import *
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
"""Simplified python debuging."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from inspect import currentframe, getsource
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
# TODO comapare against logging module https://docs.python.org/3.5/library/logging.html
|
|
9
|
+
|
|
10
|
+
# TODO instead of hard coded global variables, use function arguments
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# TODO Enum maybe?
|
|
14
|
+
# DEBUG_LEVEL=-1 no debug
|
|
15
|
+
# DEBUG_LEVEL= 0 default level
|
|
16
|
+
# DEBUG_LEVEL= 1,2,3 higher levels, more debug
|
|
17
|
+
DEBUG_LEVEL = -1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# print prefix
|
|
21
|
+
DEBUG_PRE = "DBG"
|
|
22
|
+
|
|
23
|
+
# remove folders of files for print
|
|
24
|
+
|
|
25
|
+
# filename strings with .py (with folder if SPLIT_FILENAME==False)
|
|
26
|
+
WHITE_LIST_FILES = []
|
|
27
|
+
BLACK_LIST_FILES = []
|
|
28
|
+
|
|
29
|
+
active = debug = on = DEBUG_LEVEL >= 0
|
|
30
|
+
# count debug events by file+line
|
|
31
|
+
count_times = {}
|
|
32
|
+
cur_table_line = {}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_frame(_back=0):
|
|
36
|
+
cf = currentframe()
|
|
37
|
+
for _ in range(_back + 1):
|
|
38
|
+
cf = cf.f_back
|
|
39
|
+
return cf
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def once(_back=0):
|
|
43
|
+
"""
|
|
44
|
+
Returns true only one time
|
|
45
|
+
|
|
46
|
+
Examples
|
|
47
|
+
--------
|
|
48
|
+
>>> for i in range(10):
|
|
49
|
+
... if once():
|
|
50
|
+
... print(i)
|
|
51
|
+
0
|
|
52
|
+
|
|
53
|
+
"""
|
|
54
|
+
return times(1, _back=_back + 1)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def times(t=1, _back=0):
|
|
58
|
+
"""
|
|
59
|
+
Returns true if the count of the current line is greater than or equal to ``t``.
|
|
60
|
+
|
|
61
|
+
Parameters
|
|
62
|
+
----------
|
|
63
|
+
t : int
|
|
64
|
+
The count to check against.
|
|
65
|
+
_back : int
|
|
66
|
+
Number of stack/frames to go back.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
bool
|
|
71
|
+
True if the count of the current line is greater than or equal to ``t``.
|
|
72
|
+
|
|
73
|
+
Examples
|
|
74
|
+
--------
|
|
75
|
+
>>> reset_times()
|
|
76
|
+
>>> for i in range(10):
|
|
77
|
+
... if times(3):
|
|
78
|
+
... print(i)
|
|
79
|
+
0
|
|
80
|
+
1
|
|
81
|
+
2
|
|
82
|
+
"""
|
|
83
|
+
line, fname = get_line_number_file(_back=_back + 1)
|
|
84
|
+
inc_count(line, fname)
|
|
85
|
+
return check_count(line, fname, t)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def get_line_src(_back=0):
|
|
89
|
+
"""
|
|
90
|
+
Gets the current line in the python source.
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
_back : int
|
|
95
|
+
Number of stack/frames to go back.
|
|
96
|
+
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
src : str
|
|
100
|
+
The current line in the python source.
|
|
101
|
+
|
|
102
|
+
Examples
|
|
103
|
+
--------
|
|
104
|
+
>>> get_line_src()
|
|
105
|
+
'get_line_src()'
|
|
106
|
+
>>> "funky"+get_line_src()
|
|
107
|
+
'funky"funky"+get_line_src()'
|
|
108
|
+
"""
|
|
109
|
+
cf = get_frame(_back=_back + 1)
|
|
110
|
+
srcline = getsource(cf).split("\n")[cf.f_lineno - cf.f_code.co_firstlineno].strip()
|
|
111
|
+
return srcline
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def get_line_number_file(split=True, _back=0):
|
|
115
|
+
"""
|
|
116
|
+
Gets the current filename and the current linenumber within it.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
split : bool
|
|
121
|
+
Indicates whenever the folders above of the file should be included in the returned filename.
|
|
122
|
+
_back : int
|
|
123
|
+
Number of stack/frames to go back.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
filenumber : int
|
|
128
|
+
First element in the return array
|
|
129
|
+
filename : str
|
|
130
|
+
Second element in the return array
|
|
131
|
+
|
|
132
|
+
Examples
|
|
133
|
+
--------
|
|
134
|
+
>>> get_line_number_file()
|
|
135
|
+
(1, '<doctest smpl.debug.debug.get_line_number_file[0]>')
|
|
136
|
+
>>> for i in range(2):
|
|
137
|
+
... get_line_number_file()
|
|
138
|
+
(2, '<doctest smpl.debug.debug.get_line_number_file[1]>')
|
|
139
|
+
(2, '<doctest smpl.debug.debug.get_line_number_file[1]>')
|
|
140
|
+
"""
|
|
141
|
+
cf = get_frame(_back=_back + 1)
|
|
142
|
+
fname = cf.f_code.co_filename
|
|
143
|
+
if split:
|
|
144
|
+
fname = cf.f_code.co_filename.split("/")[-1]
|
|
145
|
+
return cf.f_lineno, fname
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_line_number(_back=0):
|
|
149
|
+
return get_line_number_file(_back=_back + 1)[0]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def line(msg_, tag="", level=0, times=-1, _back=0, **kwargs):
|
|
153
|
+
msg(msg_, tag=tag, level=level, times=times, line_=True, _back=_back + 1, **kwargs)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# only once
|
|
157
|
+
def line1(msg_, tag="", level=0, times=1, _back=0, **kwargs):
|
|
158
|
+
"""
|
|
159
|
+
Just like :func:`line` but ``times`` set to 1.
|
|
160
|
+
|
|
161
|
+
Examples
|
|
162
|
+
--------
|
|
163
|
+
>>> for i in range(-2,2):
|
|
164
|
+
... line1(i,level=-1)
|
|
165
|
+
DBG::<doctest smpl.debug.debug.line1[0]>:2: line1(i,level=-1) = -2
|
|
166
|
+
"""
|
|
167
|
+
msg1(msg_, tag=tag, level=level, times=times, line_=True, _back=_back + 1, **kwargs)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# counting functions
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def get_count(line, fname):
|
|
174
|
+
"""
|
|
175
|
+
Returns the counts of the line.
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
line : int
|
|
180
|
+
The line in the python source of ``fname``.
|
|
181
|
+
fname : str
|
|
182
|
+
The filename.
|
|
183
|
+
|
|
184
|
+
Returns
|
|
185
|
+
-------
|
|
186
|
+
count : int
|
|
187
|
+
The count of the current line.
|
|
188
|
+
|
|
189
|
+
Examples
|
|
190
|
+
--------
|
|
191
|
+
>>> get_count(1, "debug.py")
|
|
192
|
+
0
|
|
193
|
+
"""
|
|
194
|
+
global count_times
|
|
195
|
+
if fname + ":" + str(line) in count_times:
|
|
196
|
+
return count_times[fname + ":" + str(line)]
|
|
197
|
+
return 0
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def inc_count(line, fname):
|
|
201
|
+
"""
|
|
202
|
+
Increments the count of the line.
|
|
203
|
+
|
|
204
|
+
Parameters
|
|
205
|
+
----------
|
|
206
|
+
line : int
|
|
207
|
+
The line in the python source of ``fname``.
|
|
208
|
+
fname : str
|
|
209
|
+
The filename.
|
|
210
|
+
|
|
211
|
+
Examples
|
|
212
|
+
--------
|
|
213
|
+
>>> inc_count(1, "debug.py")
|
|
214
|
+
"""
|
|
215
|
+
global count_times
|
|
216
|
+
if fname + ":" + str(line) in count_times:
|
|
217
|
+
count_times[fname + ":" + str(line)] += 1
|
|
218
|
+
else:
|
|
219
|
+
count_times[fname + ":" + str(line)] = 1
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def check_count(line, fname, t):
|
|
223
|
+
"""
|
|
224
|
+
Returns true if the count of the line is greater than or equal to ``t``.
|
|
225
|
+
|
|
226
|
+
Parameters
|
|
227
|
+
----------
|
|
228
|
+
line : int
|
|
229
|
+
The line in the python source of ``fname``.
|
|
230
|
+
fname : str
|
|
231
|
+
The filename.
|
|
232
|
+
t : int
|
|
233
|
+
The count to check against.
|
|
234
|
+
|
|
235
|
+
Returns
|
|
236
|
+
-------
|
|
237
|
+
bool
|
|
238
|
+
True if the count of the line is greater than or equal to ``t``.
|
|
239
|
+
|
|
240
|
+
Examples
|
|
241
|
+
--------
|
|
242
|
+
>>> check_count(2, "debug.py", 0)
|
|
243
|
+
True
|
|
244
|
+
>>> inc_count(2, "debug.py")
|
|
245
|
+
>>> check_count(2, "debug.py", 0)
|
|
246
|
+
False
|
|
247
|
+
|
|
248
|
+
"""
|
|
249
|
+
if t >= get_count(line, fname) or t == -1:
|
|
250
|
+
if fname not in BLACK_LIST_FILES and (
|
|
251
|
+
len(WHITE_LIST_FILES) == 0 or fname in WHITE_LIST_FILES
|
|
252
|
+
):
|
|
253
|
+
return True
|
|
254
|
+
return False
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
# _line enables printint src line
|
|
258
|
+
# t stands for times
|
|
259
|
+
def msg(msg, tag="", level=0, times=-1, line_=False, _back=0, **kwargs):
|
|
260
|
+
"""
|
|
261
|
+
Prints the message ``msg`` if level > debug_level and always returns the msg.
|
|
262
|
+
|
|
263
|
+
Parameters
|
|
264
|
+
----------
|
|
265
|
+
tag : str
|
|
266
|
+
Sets a tag to be printed for the debug message.
|
|
267
|
+
level : int
|
|
268
|
+
Debug level.
|
|
269
|
+
times : int
|
|
270
|
+
How often should the message be printed if the function gets called multiple times (e.g. in a loop).
|
|
271
|
+
_line : bool
|
|
272
|
+
Print the current line in the python source.
|
|
273
|
+
_back : int
|
|
274
|
+
Number of stack/frames to go back.
|
|
275
|
+
|
|
276
|
+
Examples
|
|
277
|
+
--------
|
|
278
|
+
>>> msg("hi", level = -9999)
|
|
279
|
+
DBG::<doctest smpl.debug.debug.msg[0]>:1: hi
|
|
280
|
+
'hi'
|
|
281
|
+
>>> msg("hi")
|
|
282
|
+
'hi'
|
|
283
|
+
|
|
284
|
+
"""
|
|
285
|
+
if level <= DEBUG_LEVEL:
|
|
286
|
+
line, fname = get_line_number_file(_back=_back + 1)
|
|
287
|
+
src = ""
|
|
288
|
+
if line_:
|
|
289
|
+
src = get_line_src(_back=_back + 1)
|
|
290
|
+
src = src + " = "
|
|
291
|
+
inc_count(line, fname)
|
|
292
|
+
if check_count(line, fname, times):
|
|
293
|
+
print(
|
|
294
|
+
DEBUG_PRE
|
|
295
|
+
+ ":"
|
|
296
|
+
+ tag
|
|
297
|
+
+ ":"
|
|
298
|
+
+ fname
|
|
299
|
+
+ ":"
|
|
300
|
+
+ str(line)
|
|
301
|
+
+ ": "
|
|
302
|
+
+ src
|
|
303
|
+
+ str(msg)
|
|
304
|
+
)
|
|
305
|
+
return msg
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def msg1(_msg, tag="", level=0, times=1, line_=False, _back=0, **kwargs):
|
|
309
|
+
"""
|
|
310
|
+
Just like :func:`msg` but ``times`` set to 1.
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
tag : str
|
|
315
|
+
Sets a tag to be printed for the debug message.
|
|
316
|
+
level : int
|
|
317
|
+
Debug level.
|
|
318
|
+
times : int
|
|
319
|
+
How often should the message be printed if the function gets called multiple times (e.g. in a loop).
|
|
320
|
+
_line : bool
|
|
321
|
+
Print the current line in the python source.
|
|
322
|
+
_back : int
|
|
323
|
+
Number of stack/frames to go back.
|
|
324
|
+
|
|
325
|
+
Examples
|
|
326
|
+
--------
|
|
327
|
+
>>> for i in range(-2,2):
|
|
328
|
+
... msg1(i, level = i)
|
|
329
|
+
DBG::<doctest smpl.debug.debug.msg1[0]>:2: -2
|
|
330
|
+
-2
|
|
331
|
+
-1
|
|
332
|
+
0
|
|
333
|
+
1
|
|
334
|
+
"""
|
|
335
|
+
return msg(
|
|
336
|
+
_msg, level=level, tag=tag, times=times, line_=line_, _back=_back + 1, **kwargs
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def file(
|
|
341
|
+
key,
|
|
342
|
+
value,
|
|
343
|
+
level=0,
|
|
344
|
+
times=-1,
|
|
345
|
+
seperator=";",
|
|
346
|
+
_print=True,
|
|
347
|
+
_back=0,
|
|
348
|
+
filename="debug.csv",
|
|
349
|
+
):
|
|
350
|
+
"""
|
|
351
|
+
Prints the message ``msg`` if level > debug_level to file ``filename``.
|
|
352
|
+
"""
|
|
353
|
+
if level <= DEBUG_LEVEL:
|
|
354
|
+
line, fname = get_line_number_file(_back=_back + 1)
|
|
355
|
+
inc_count(line, fname)
|
|
356
|
+
if check_count(line, fname, times):
|
|
357
|
+
f = open(filename, "a+")
|
|
358
|
+
if _print:
|
|
359
|
+
tag = "debug.file"
|
|
360
|
+
print(
|
|
361
|
+
DEBUG_PRE
|
|
362
|
+
+ ":"
|
|
363
|
+
+ tag
|
|
364
|
+
+ ":"
|
|
365
|
+
+ fname
|
|
366
|
+
+ ":"
|
|
367
|
+
+ str(line)
|
|
368
|
+
+ ": "
|
|
369
|
+
+ key
|
|
370
|
+
+ seperator
|
|
371
|
+
+ value
|
|
372
|
+
)
|
|
373
|
+
f.write(key + seperator + value + "\n")
|
|
374
|
+
f.close()
|
|
375
|
+
return value
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def file1(_key, _value, level=0, times=1, _back=0, **kwargs):
|
|
379
|
+
"""
|
|
380
|
+
Just like :func:`file` but ``times`` set to 1.
|
|
381
|
+
"""
|
|
382
|
+
return file(_key, _value, level=level, times=times, _back=_back + 1, **kwargs)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def table_flush_header(filename="debug_table.csv", seperator=";"):
|
|
386
|
+
"""
|
|
387
|
+
Saves the current keys from :func:`table` to ``filename``.
|
|
388
|
+
"""
|
|
389
|
+
global cur_table_line
|
|
390
|
+
f = open(filename, "a+")
|
|
391
|
+
for key in sorted(cur_table_line):
|
|
392
|
+
f.write(key + seperator)
|
|
393
|
+
f.write("\n")
|
|
394
|
+
f.close()
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def table_flush_line(filename="debug_table.csv", seperator=";"):
|
|
398
|
+
"""
|
|
399
|
+
Saves the current values from :func:`table` to ``filename``
|
|
400
|
+
"""
|
|
401
|
+
global cur_table_line
|
|
402
|
+
f = open(filename, "a+")
|
|
403
|
+
ok = False
|
|
404
|
+
dim = 1
|
|
405
|
+
for cur in iter(cur_table_line):
|
|
406
|
+
ok = isinstance(cur_table_line[cur], np.ndarray)
|
|
407
|
+
if ok:
|
|
408
|
+
dim = len(cur_table_line[cur])
|
|
409
|
+
break
|
|
410
|
+
for i in range(dim):
|
|
411
|
+
for key in sorted(cur_table_line):
|
|
412
|
+
if isinstance(cur_table_line[key], np.ndarray):
|
|
413
|
+
f.write("%.30e" % cur_table_line[key][i] + seperator)
|
|
414
|
+
else:
|
|
415
|
+
f.write("%.30e" % cur_table_line[key] + seperator)
|
|
416
|
+
f.write("\n")
|
|
417
|
+
f.close()
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def table(
|
|
421
|
+
key,
|
|
422
|
+
value,
|
|
423
|
+
level=0,
|
|
424
|
+
times=-1,
|
|
425
|
+
seperator=";",
|
|
426
|
+
_print=False,
|
|
427
|
+
_back=0,
|
|
428
|
+
filename="debug_table.csv",
|
|
429
|
+
):
|
|
430
|
+
"""
|
|
431
|
+
Saves ``key``:``value`` in ``filename``.
|
|
432
|
+
|
|
433
|
+
Examples
|
|
434
|
+
--------
|
|
435
|
+
>>> for i in range(-2,2):
|
|
436
|
+
... table("a", i,level=-1)
|
|
437
|
+
... table("b", i**2,level=-1)
|
|
438
|
+
... table("c", i**i,level=-1)
|
|
439
|
+
... if once(): table_flush_header();
|
|
440
|
+
... table_flush_line()
|
|
441
|
+
-2
|
|
442
|
+
4
|
|
443
|
+
0.25
|
|
444
|
+
-1
|
|
445
|
+
1
|
|
446
|
+
-1.0
|
|
447
|
+
0
|
|
448
|
+
0
|
|
449
|
+
1
|
|
450
|
+
1
|
|
451
|
+
1
|
|
452
|
+
1
|
|
453
|
+
>>> from smpl import io
|
|
454
|
+
>>> print(io.read("debug_table.csv").strip())
|
|
455
|
+
a;b;c;
|
|
456
|
+
-2.000000000000000000000000000000e+00;4.000000000000000000000000000000e+00;2.500000000000000000000000000000e-01;
|
|
457
|
+
-1.000000000000000000000000000000e+00;1.000000000000000000000000000000e+00;-1.000000000000000000000000000000e+00;
|
|
458
|
+
0.000000000000000000000000000000e+00;0.000000000000000000000000000000e+00;1.000000000000000000000000000000e+00;
|
|
459
|
+
1.000000000000000000000000000000e+00;1.000000000000000000000000000000e+00;1.000000000000000000000000000000e+00;
|
|
460
|
+
>>> import pandas as pd
|
|
461
|
+
>>> pd.read_csv("debug_table.csv")
|
|
462
|
+
a;b;c;
|
|
463
|
+
0 -2.000000000000000000000000000000e+00;4.000000...
|
|
464
|
+
1 -1.000000000000000000000000000000e+00;1.000000...
|
|
465
|
+
2 0.000000000000000000000000000000e+00;0.0000000...
|
|
466
|
+
3 1.000000000000000000000000000000e+00;1.0000000...
|
|
467
|
+
>>> reset_table()
|
|
468
|
+
>>> io.write("debug_table.csv","")
|
|
469
|
+
>>> for i in range(1,3):
|
|
470
|
+
... table("a", np.array([i*k for k in range(5)]),level=-1)
|
|
471
|
+
... table("b", np.array([i*i*k for k in range(5)]),level=-1)
|
|
472
|
+
... if once(): table_flush_header();
|
|
473
|
+
... table_flush_line()
|
|
474
|
+
array([0, 1, 2, 3, 4])
|
|
475
|
+
array([0, 1, 2, 3, 4])
|
|
476
|
+
array([0, 2, 4, 6, 8])
|
|
477
|
+
array([ 0, 4, 8, 12, 16])
|
|
478
|
+
>>> print(io.read("debug_table.csv").strip())
|
|
479
|
+
a;b;
|
|
480
|
+
0.000000000000000000000000000000e+00;0.000000000000000000000000000000e+00;
|
|
481
|
+
1.000000000000000000000000000000e+00;1.000000000000000000000000000000e+00;
|
|
482
|
+
2.000000000000000000000000000000e+00;2.000000000000000000000000000000e+00;
|
|
483
|
+
3.000000000000000000000000000000e+00;3.000000000000000000000000000000e+00;
|
|
484
|
+
4.000000000000000000000000000000e+00;4.000000000000000000000000000000e+00;
|
|
485
|
+
0.000000000000000000000000000000e+00;0.000000000000000000000000000000e+00;
|
|
486
|
+
2.000000000000000000000000000000e+00;4.000000000000000000000000000000e+00;
|
|
487
|
+
4.000000000000000000000000000000e+00;8.000000000000000000000000000000e+00;
|
|
488
|
+
6.000000000000000000000000000000e+00;1.200000000000000000000000000000e+01;
|
|
489
|
+
8.000000000000000000000000000000e+00;1.600000000000000000000000000000e+01;
|
|
490
|
+
"""
|
|
491
|
+
global cur_table_line
|
|
492
|
+
if level <= DEBUG_LEVEL:
|
|
493
|
+
line, fname = get_line_number_file(_back=_back + 1)
|
|
494
|
+
inc_count(line, fname)
|
|
495
|
+
if check_count(line, fname, times):
|
|
496
|
+
if isinstance(value, np.ndarray):
|
|
497
|
+
cur_table_line[key] = value.copy()
|
|
498
|
+
else:
|
|
499
|
+
cur_table_line[key] = value
|
|
500
|
+
return value
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def reset_times():
|
|
504
|
+
"""
|
|
505
|
+
Resets global `count_times`.
|
|
506
|
+
"""
|
|
507
|
+
global count_times
|
|
508
|
+
count_times = {}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def reset_table():
|
|
512
|
+
"""
|
|
513
|
+
Resets global `cur_table_line`.
|
|
514
|
+
"""
|
|
515
|
+
global cur_table_line
|
|
516
|
+
cur_table_line = {}
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
reset_count = reset_times
|
|
520
|
+
|
|
521
|
+
if os.path.exists("debug.csv"):
|
|
522
|
+
os.remove("debug.csv")
|
|
523
|
+
if os.path.exists("debug_table.csv"):
|
|
524
|
+
os.remove("debug_table.csv")
|
|
525
|
+
|
|
526
|
+
if __name__ == "__main__":
|
|
527
|
+
import doctest
|
|
528
|
+
|
|
529
|
+
doctest.testmod(verbose=True, optionflags=doctest.ELLIPSIS)
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Simplified plotting."""
|
|
2
2
|
|
|
3
|
-
import warnings
|
|
4
|
-
|
|
5
3
|
import matplotlib
|
|
6
4
|
import matplotlib.pyplot as plt
|
|
7
5
|
import numpy as np
|
|
@@ -275,11 +273,11 @@ def fit(func, *adata, **kwargs):
|
|
|
275
273
|
|
|
276
274
|
"""
|
|
277
275
|
if "xaxis" in kwargs and not kwargs["xlabel"]:
|
|
278
|
-
warnings.warn("xaxis is deprecated. Use xlabel instead.", DeprecationWarning, 2)
|
|
276
|
+
# warnings.warn("xaxis is deprecated. Use xlabel instead.", DeprecationWarning, 2)
|
|
279
277
|
kwargs["xlabel"] = kwargs["xaxis"]
|
|
280
278
|
# TODO maybe pop
|
|
281
279
|
if "yaxis" in kwargs and not kwargs["ylabel"]:
|
|
282
|
-
warnings.warn("yaxis is deprecated. Use ylabel instead.", DeprecationWarning, 2)
|
|
280
|
+
# warnings.warn("yaxis is deprecated. Use ylabel instead.", DeprecationWarning, 2)
|
|
283
281
|
kwargs["ylabel"] = kwargs["yaxis"]
|
|
284
282
|
# TODO maybe pop
|
|
285
283
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
|
|
3
1
|
import matplotlib.pyplot as plt
|
|
4
2
|
import numpy as np
|
|
5
3
|
import smplr
|
|
@@ -56,13 +54,13 @@ def plot2d(datax, datay, dataz, **kwargs):
|
|
|
56
54
|
"""
|
|
57
55
|
kwargs = plot2d_kwargs(kwargs)
|
|
58
56
|
if "xaxis" in kwargs and not kwargs["xlabel"]:
|
|
59
|
-
warnings.warn("xaxis is deprecated. Use xlabel instead.", DeprecationWarning, 2)
|
|
57
|
+
# warnings.warn("xaxis is deprecated. Use xlabel instead.", DeprecationWarning, 2)
|
|
60
58
|
kwargs["xlabel"] = kwargs["xaxis"]
|
|
61
59
|
if "yaxis" in kwargs and not kwargs["ylabel"]:
|
|
62
|
-
warnings.warn("yaxis is deprecated. Use ylabel instead.", DeprecationWarning, 2)
|
|
60
|
+
# warnings.warn("yaxis is deprecated. Use ylabel instead.", DeprecationWarning, 2)
|
|
63
61
|
kwargs["ylabel"] = kwargs["yaxis"]
|
|
64
62
|
if "zaxis" in kwargs and not kwargs["zlabel"]:
|
|
65
|
-
warnings.warn("zaxis is deprecated. Use zlabel instead.", DeprecationWarning, 2)
|
|
63
|
+
# warnings.warn("zaxis is deprecated. Use zlabel instead.", DeprecationWarning, 2)
|
|
66
64
|
kwargs["zlabel"] = kwargs["zaxis"]
|
|
67
65
|
|
|
68
66
|
if util.has("axes", kwargs) and kwargs["axes"] is not None:
|
smpl-1.5.2/smpl/.plot.py.swp
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|