Skip to content

Commit 0b76c9a

Browse files
authored
Merge pull request #38 from PPPLDeepLearning/hotfix/package-deprecations
Address warnings from dependencies
2 parents 0089e60 + a687e18 commit 0b76c9a

File tree

15 files changed

+83
-122
lines changed

15 files changed

+83
-122
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Emacs
22
*~
33
\#*\#
4+
.auctex-auto/
5+
.dir-locals.el
46

57
# Generated by test
68
plot_*.html

examples/notebooks/Signal Influence.ipynb

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@
2626
{
2727
"cell_type": "code",
2828
"execution_count": 6,
29-
"metadata": {
30-
"collapsed": false
31-
},
29+
"metadata": {},
3230
"outputs": [],
3331
"source": [
34-
"dat = np.load('./temp_data/signal_influence/signal_influence_results_155191_2017-12-01-01-42-33.npz')"
32+
"dat = np.load('./temp_data/signal_influence/signal_influence_results_155191_2017-12-01-01-42-33.npz', allow_pickle=False)"
3533
]
3634
},
3735
{
3836
"cell_type": "code",
3937
"execution_count": 7,
40-
"metadata": {
41-
"collapsed": false
42-
},
38+
"metadata": {},
4339
"outputs": [
4440
{
4541
"name": "stdout",
@@ -60,9 +56,7 @@
6056
{
6157
"cell_type": "code",
6258
"execution_count": 8,
63-
"metadata": {
64-
"collapsed": false
65-
},
59+
"metadata": {},
6660
"outputs": [
6761
{
6862
"data": {
@@ -102,9 +96,7 @@
10296
{
10397
"cell_type": "code",
10498
"execution_count": 9,
105-
"metadata": {
106-
"collapsed": false
107-
},
99+
"metadata": {},
108100
"outputs": [
109101
{
110102
"data": {
@@ -139,9 +131,7 @@
139131
{
140132
"cell_type": "code",
141133
"execution_count": 17,
142-
"metadata": {
143-
"collapsed": false
144-
},
134+
"metadata": {},
145135
"outputs": [
146136
{
147137
"name": "stdout",
@@ -211,9 +201,7 @@
211201
{
212202
"cell_type": "code",
213203
"execution_count": 15,
214-
"metadata": {
215-
"collapsed": false
216-
},
204+
"metadata": {},
217205
"outputs": [
218206
{
219207
"data": {
@@ -315,15 +303,13 @@
315303
},
316304
"outputs": [],
317305
"source": [
318-
"dat = np.load('./temp_data/signal_influence/signal_influence_results_2017-11-30-20-13-39.npz')"
306+
"dat = np.load('./temp_data/signal_influence/signal_influence_results_2017-11-30-20-13-39.npz', allow_pickle=False)"
319307
]
320308
},
321309
{
322310
"cell_type": "code",
323311
"execution_count": 4,
324-
"metadata": {
325-
"collapsed": false
326-
},
312+
"metadata": {},
327313
"outputs": [],
328314
"source": [
329315
"y_gold = dat['y_gold']\n",
@@ -333,9 +319,7 @@
333319
{
334320
"cell_type": "code",
335321
"execution_count": 97,
336-
"metadata": {
337-
"collapsed": false
338-
},
322+
"metadata": {},
339323
"outputs": [
340324
{
341325
"data": {
@@ -362,9 +346,7 @@
362346
{
363347
"cell_type": "code",
364348
"execution_count": 18,
365-
"metadata": {
366-
"collapsed": false
367-
},
349+
"metadata": {},
368350
"outputs": [],
369351
"source": [
370352
"t_range = np.linspace(0,len(y_gold[0]),10,dtype=np.int)"
@@ -373,9 +355,7 @@
373355
{
374356
"cell_type": "code",
375357
"execution_count": 19,
376-
"metadata": {
377-
"collapsed": false
378-
},
358+
"metadata": {},
379359
"outputs": [
380360
{
381361
"data": {
@@ -395,9 +375,7 @@
395375
{
396376
"cell_type": "code",
397377
"execution_count": 95,
398-
"metadata": {
399-
"collapsed": false
400-
},
378+
"metadata": {},
401379
"outputs": [],
402380
"source": [
403381
"def difference_metric(y_prime,y_prime_orig):\n",
@@ -422,9 +400,7 @@
422400
{
423401
"cell_type": "code",
424402
"execution_count": 96,
425-
"metadata": {
426-
"collapsed": false
427-
},
403+
"metadata": {},
428404
"outputs": [],
429405
"source": [
430406
"differences = get_importance_measure(y_prime,difference_metric)"
@@ -433,9 +409,7 @@
433409
{
434410
"cell_type": "code",
435411
"execution_count": 24,
436-
"metadata": {
437-
"collapsed": false
438-
},
412+
"metadata": {},
439413
"outputs": [
440414
{
441415
"data": {
@@ -464,21 +438,21 @@
464438
],
465439
"metadata": {
466440
"kernelspec": {
467-
"display_name": "Python [conda root]",
441+
"display_name": "Python 3",
468442
"language": "python",
469-
"name": "conda-root-py"
443+
"name": "python3"
470444
},
471445
"language_info": {
472446
"codemirror_mode": {
473447
"name": "ipython",
474-
"version": 2
448+
"version": 3
475449
},
476450
"file_extension": ".py",
477451
"mimetype": "text/x-python",
478452
"name": "python",
479453
"nbconvert_exporter": "python",
480-
"pygments_lexer": "ipython2",
481-
"version": "2.7.12"
454+
"pygments_lexer": "ipython3",
455+
"version": "3.7.4"
482456
},
483457
"latex_envs": {
484458
"LaTeX_envs_menu_present": true,

examples/submit_batch_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def copy_conf_file(
3131
pathdst = os.path.join(save_path, conf_name)
3232

3333
with open(pathsrc, 'r') as yaml_file:
34-
conf = yaml.load(yaml_file)
34+
conf = yaml.load(yaml_file, Loader=yaml.SafeLoader)
3535
# make sure all files like checkpoints and normalization are done locally
3636
conf['training']['hyperparam_tuning'] = True
3737
with open(pathdst, 'w') as outfile:
@@ -40,7 +40,7 @@ def copy_conf_file(
4040

4141
def get_conf(template_path, conf_name):
4242
with open(os.path.join(template_path, conf_name), 'r') as yaml_file:
43-
conf = yaml.load(yaml_file)
43+
conf = yaml.load(yaml_file, Loader=yaml.SafeLoader)
4444
return conf
4545

4646

examples/tune_hyperparams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def generate_conf_file(tunables, shallow, template_path="../", save_path="./",
107107
conf_name="conf.yaml"):
108108
assert(template_path != save_path)
109109
with open(os.path.join(template_path, conf_name), 'r') as yaml_file:
110-
conf = yaml.load(yaml_file)
110+
conf = yaml.load(yaml_file, Loader=yaml.SafeLoader)
111111
for tunable in tunables:
112112
tunable.assign_to_conf(conf, save_path)
113113
# rely on early stopping to terminate training

jenkins-ci/run_jenkins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def generate_conf_file(
2323
conf_name="conf.yaml"):
2424
assert(template_path != save_path)
2525
with open(os.path.join(template_path, conf_name), 'r') as yaml_file:
26-
conf = yaml.load(yaml_file)
26+
conf = yaml.load(yaml_file, Loader=yaml.SafeLoader)
2727
conf['training']['num_epochs'] = 2
2828
conf['paths']['data'] = test_configuration[1]
2929
if test_configuration[1] == "Python3":

plasma/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import errno
44

5+
# TODO(KGF): this conf.py feels like an unnecessary level of indirection
56
if os.path.exists(os.path.join(os.path.abspath(os.path.dirname(__file__)),
67
'../examples/conf.yaml')):
78
conf = parameters(os.path.join(os.path.abspath(os.path.dirname(__file__)),

plasma/conf_parser.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ def parameters(input_file):
1616
TTDTarget, TTDInvTarget, TTDLinearTarget
1717
)
1818
with open(input_file, 'r') as yaml_file:
19-
params = yaml.load(yaml_file)
19+
params = yaml.load(yaml_file, Loader=yaml.SafeLoader)
2020

2121
params['user_name'] = getpass.getuser()
2222
output_path = params['fs_path'] + "/" + params['user_name']
2323
base_path = output_path
2424

2525
params['paths']['base_path'] = base_path
26-
params['paths']['signal_prepath'] = base_path + \
27-
params['paths']['signal_prepath']
28-
params['paths']['shot_list_dir'] = base_path + \
29-
params['paths']['shot_list_dir']
26+
params['paths']['signal_prepath'] = (
27+
base_path + params['paths']['signal_prepath'])
28+
params['paths']['shot_list_dir'] = (
29+
base_path + params['paths']['shot_list_dir'])
3030
params['paths']['output_path'] = output_path
3131
h = get_unique_signal_hash(sig.all_signals.values())
32-
params['paths']['global_normalizer_path'] = output_path + \
33-
'/normalization/normalization_signal_group_{}.npz'.format(h)
32+
params['paths']['global_normalizer_path'] = (
33+
output_path
34+
+ '/normalization/normalization_signal_group_{}.npz'.format(h))
3435
if params['training']['hyperparam_tuning']:
3536
# params['paths']['saved_shotlist_path'] =
3637
# './normalization/shot_lists.npz'
@@ -44,12 +45,12 @@ def parameters(input_file):
4445
# '/normalization/shot_lists.npz'
4546
params['paths']['normalizer_path'] = (
4647
params['paths']['global_normalizer_path'])
47-
params['paths']['model_save_path'] = (
48-
output_path + '/model_checkpoints/')
48+
params['paths']['model_save_path'] = (output_path
49+
+ '/model_checkpoints/')
4950
params['paths']['csvlog_save_path'] = output_path + '/csv_logs/'
5051
params['paths']['results_prepath'] = output_path + '/results/'
51-
params['paths']['tensorboard_save_path'] = output_path + \
52-
params['paths']['tensorboard_save_path']
52+
params['paths']['tensorboard_save_path'] = (
53+
output_path + params['paths']['tensorboard_save_path'])
5354
params['paths']['saved_shotlist_path'] = (
5455
params['paths']['base_path'] + '/processed_shotlists/'
5556
+ params['paths']['data']

plasma/models/mpi_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def save_shotlists(conf, shot_list_train, shot_list_validate, shot_list_test):
662662

663663
def load_shotlists(conf):
664664
path = get_shot_list_path(conf)
665-
data = np.load(path)
665+
data = np.load(path, allow_pickle=False)
666666
shot_list_train = data['shot_list_train'][()]
667667
shot_list_validate = data['shot_list_validate'][()]
668668
shot_list_test = data['shot_list_test'][()]

plasma/models/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from hyperopt import hp, STATUS_OK
1111
import numpy as np
1212
import sys
13-
import matplotlib.pyplot as plt
1413
import matplotlib
1514
matplotlib.use('Agg')
15+
import matplotlib.pyplot as plt # noqa
1616

1717
# if sys.version_info[0] < 3:
1818
# from itertools import imap

plasma/models/shallow_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import datetime
2121
import time
2222
import numpy as np
23+
2324
from copy import deepcopy
2425

25-
# import matplotlib.pyplot as plt
2626
import matplotlib
2727
matplotlib.use('Agg')
28+
# import matplotlib.pyplot as plt
2829

2930
# import sys
3031
# if sys.version_info[0] < 3:
@@ -134,7 +135,7 @@ def process(self, shot):
134135
# print(X.shape, Y.shape)
135136
else:
136137
try:
137-
dat = np.load(save_path)
138+
dat = np.load(save_path, allow_pickle=False)
138139
# X, Y, disr = dat["X"], dat["Y"], dat["disr"][()]
139140
X = dat["X"]
140141
except BaseException:

0 commit comments

Comments
 (0)