Skip to content

Commit

Permalink
Towards PEP8 compatibility
Browse files Browse the repository at this point in the history
Names of modules have been changed following PEP8
recommandations. Thus, for example, Core/peakFunctions.py becomes
core/peak_functions.py. Module ICython has been renamed to
cython. Also, Script env.sh has been modified to allow optional
download of the data base.
  • Loading branch information
jjgomezcadenas committed Jan 7, 2017
1 parent 8364157 commit b34c275
Show file tree
Hide file tree
Showing 46 changed files with 79 additions and 95 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ install:
- source activate IC
- pip install hypothesis-numpy
- pip install flaky
- source env.sh
- source env.sh 1

script:
- python setup.py develop
- pytest

7 changes: 6 additions & 1 deletion env.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/bash
#echo -n "Enter 0 to use an existing copy of DB or 1 to download a new copy --> "
#echo "your choice is $download"
export ICDIR=`pwd`
export ICTDIR=$ICDIR/invisible_cities/
export PYTHONPATH=$ICDIR:$PYTHONPATH
python $ICDIR/invisible_cities/Database/download.py

python $ICDIR/invisible_cities/database/download.py
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from __future__ import print_function

import sys
from glob import glob
from time import time

import numpy as np
import tables as tb

import invisible_cities.Core.tblFunctions as tbl
from invisible_cities.Core.Configure import configure, print_configuration
from invisible_cities.Core.Nh5 import FEE
import invisible_cities.Core.mplFunctions as mpl
import invisible_cities.Core.wfmFunctions as wfm
from invisible_cities.Core.RandomSampling import NoiseSampler as SiPMsNoiseSampler
from invisible_cities.Database import loadDB
import invisible_cities.Sierpe.FEE as FE
import invisible_cities.core.tbl_functions as tbl
from invisible_cities.core.configure import configure, print_configuration
from invisible_cities.core.nh5 import FEE
import invisible_cities.core.mpl_functions as mpl
import invisible_cities.core.wfm_functions as wfm
from invisible_cities.core.random_sampling\
import NoiseSampler as SiPMsNoiseSampler
from invisible_cities.database import loadDB
import invisible_cities.sierpe.fee as FE


class Diomira:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import os
from time import time

from Core.Configure import configure
from Cities.diomira_ms import Diomira
from invisible_cities.core.configure import configure
from invisible_cities.cities.diomira import Diomira

ffile = os.environ['ICDIR'] + '/tests/electrons_40keV_z250_RWF.h5'
ffile = os.environ['ICTDIR'] + '/tests/electrons_40keV_z250_RWF.h5'
try:
os.system("rm -f {}".format(ffile))
except(IOError):
pass

ffile = os.environ['ICDIR'] + '/Config/diomira_ms.conf'
ffile = os.environ['ICTDIR'] + '/config/diomira.conf'
CFP = configure(['DIOMIRA','-c',ffile])
fpp = Diomira()
files_in = glob(CFP['FILE_IN'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from __future__ import print_function
from __future__ import absolute_import

import os
from glob import glob
import tables as tb
import numpy as np

from invisible_cities.Core.Configure import configure
import invisible_cities.Core.tblFunctions as tbl
import invisible_cities.Core.system_of_units as units
from invisible_cities.Sierpe import FEE
import invisible_cities.ICython.Sierpe.BLR as blr
from invisible_cities.Database import loadDB
from invisible_cities.Cities.diomira_ms import Diomira
import os
from invisible_cities.core.configure import configure
import invisible_cities.core.tbl_functions as tbl
import invisible_cities.core.system_of_units as units
from invisible_cities.sierpe import fee as FEE
import invisible_cities.cython.sierpe.BLR as blr
from invisible_cities.database import loadDB
from invisible_cities.cities.diomira import Diomira

def test_diomira_run():
""" Tests that DIOMIRA runs on default config parameters """
ffile = os.environ['ICDIR'] + '/invisible_cities/tests/electrons_40keV_z250_RWF.h5'
ffile = os.environ['ICTDIR'] + '/tests/electrons_40keV_z250_RWF.h5'
try:
os.system("rm -f {}".format(ffile))
except(IOError):
pass

ffile = os.environ['ICDIR'] + '/invisible_cities/Config/diomira_ms.conf'
ffile = os.environ['ICTDIR'] + '/config/diomira.conf'
CFP = configure(['DIOMIRA','-c',ffile])
fpp = Diomira()
files_in = glob(CFP['FILE_IN'])
Expand All @@ -41,7 +41,7 @@ def test_diomira_run():

def test_diomira_fee_table():
""" tests that FEE table reads back correctly with expected values"""
path = os.environ['ICDIR'] + '/invisible_cities/tests/'
path = os.environ['ICTDIR'] + '/tests/'

ffile ='electrons_40keV_z250_RWF.h5'
e40rwf= tb.open_file(path+ffile,'r+')
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_diomira_cwf_blr():
the BLR within 1 %.
"""
eps = 1.
path = os.environ['ICDIR'] + '/invisible_cities/tests/'
path = os.environ['ICTDIR'] + '/tests/'
ffile ='electrons_40keV_z250_RWF.h5'
e40rwf= tb.open_file(path+ffile,'r+')
pmtrwf = e40rwf.root.RD.pmtrwf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import tables as tb
import matplotlib.pyplot as plt

from Core.Nh5 import RunInfo, EventInfo
from Core.Nh5 import S12, S2Si
import Core.mplFunctions as mpl
import Core.wfmFunctions as wfm
import Core.peakFunctions as pf
import Core.tblFunctions as tbl
from Core.Configure import configure, define_event_loop, print_configuration

import ICython.Sierpe.BLR as blr
import ICython.Core.peakFunctions as cpf
from ICython.Core.system_of_units import SystemOfUnits

from Database import loadDB
from invisible_cities.core.nh5 import RunInfo, EventInfo
from invisible_cities.core.Nh5 import S12, S2Si
import invisible_cities.core.mpl_functions as mpl
import invisible_cities.core.wfm_functions as wfm
import invisible_cities.core.peak_functions as pf
import invisible_cities.core.tbl_functions as tbl
from invisible_cities.core.configure\
import configure, define_event_loop, print_configuration

import invisible_cities.cython.sierpe.BLR as blr
import invisible_cities.cython.core.peak_functions as cpf
from invisible_cities.cython.core.system_of_units import SystemOfUnits

from invisible_cities.database import loadDB

units = SystemOfUnits()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import os

from invisible_cities.Core.LogConfig import logger
from invisible_cities.core.log_config import logger


def print_configuration(options):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from time import time
import numpy as np
import wfmFunctions as wfm
import ICython.Core.peakFunctions as cpf
import invisible_cities.core.wfm_functions as wfm
import invisible_cities.cython.core.peak_functions as cpf


t = np.arange(1.,100., 0.1, dtype=np.double)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# from mpl_toolkits.mplot3d import Axes3D
# from IPython.display import HTML

import invisible_cities.Core.coreFunctions as cf
import invisible_cities.Core.system_of_units as units
import invisible_cities.Core.wfmFunctions as wfm
import invisible_cities.Core.tblFunctions as tbl
import invisible_cities.core.core_functions as cf
import invisible_cities.core.system_of_units as units
import invisible_cities.core.wfm_functions as wfm
import invisible_cities.core.tbl_functions as tbl


# matplotlib.style.use("ggplot")
Expand All @@ -39,24 +39,6 @@ def histo(x, nbins, title="hsimple", xlabel="", ylabel="Frequency"):
plt.ylabel(ylabel)


def HSimple1(x, nbins, title="hsimple", xlabel="", ylabel="Frequency",
save=False, filename="hsimple.png", filepath="./"):
"""an interface for plt.hist with some decorations and default options"""

plt.hist(x, nbins, histtype="bar", alpha=0.75)
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel(ylabel)

if save:
pathfile = filepath+filename
print("saving histogram %s in %s" % (filename, pathfile))
plt.savefig(pathfile, bbox_inches="tight")
plt.close()
else:
plt.figure()


def plts(signal, signal_start=0, signal_end=1e+4, offset=5):
"""Plot a signal in a give interval, control offset by hand."""
ax1 = plt.subplot(1, 1, 1)
Expand All @@ -75,14 +57,14 @@ def plot_signal(signal_t, signal, title="signal",
ax1 = plt.subplot(1, 1, 1)
ax1.set_xlim([signal_start, signal_end])
ax1.set_ylim([0, ymax])
SetPlotLabels(xlabel="t ({})".format(t_units),
set_plot_labels(xlabel="t ({})".format(t_units),
ylabel="signal ({})".format(units))
plt.title(title)
plt.plot(signal_t, signal)
plt.show()


def SetPlotLabels(xlabel="", ylabel="", grid=True):
def set_plot_labels(xlabel="", ylabel="", grid=True):
"""Short cut to set labels in plots."""
plt.xlabel(xlabel)
plt.ylabel(ylabel)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import math
import numpy as np
import pandas as pd
import Core.system_of_units as units
import ICython.Sierpe.BLR as blr
import ICython.Core.peakFunctions as pf
from Database import loadDB
import matplotlib.pyplot as plt
from time import time
import tables as tb
import matplotlib.pyplot as plt

import invisible_cities.core.system_of_units as units
import invisible_cities.cython.sierpe.BLR as blr
import invisible_cities.cython.core.peak_functions as pf
from invisible_cities.database import loadDB


def pmt_sum(CWF, adc_to_pes):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import numpy as np
import pandas as pd
import tables as tb
import Core.system_of_units as units
import ICython.Core.pmapsFunctions as cpm
import matplotlib.pyplot as plt
import invisible_cities.core.system_of_units as units
import invisible_cities.cython.core.pmaps_functions as cpm


def read_PMAPS(path, pmap_file):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np

import invisible_cities.Database.loadDB as DB
import invisible_cities.database.loadDB as DB


class NoiseSampler:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import tables as tb
import pandas as pd

import invisible_cities.Core.wfmFunctions as wfm
import invisible_cities.Database.loadDB as DB
import invisible_cities.Sierpe.FEE as FE
import invisible_cities.core.wfm_functions as wfm
import invisible_cities.database.loadDB as DB
import invisible_cities.sierpe.fee as FE


def filters(name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ def rebin_waveform(t, e, stride = 40):
return T, E




def rebin_df(df, stride=40):
"""Applies rebin_wf to a dataframe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from hypothesis.strategies import lists, integers, floats
from hypothesis.extra.numpy import arrays

from . import wfmFunctions as wfm
import invisible_cities.ICython.Core.peakFunctions as cpf
from . import wfm_functions as wfm
import invisible_cities.cython.core.peak_functions as cpf
import numpy as np


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def loadDB():
dbfile = os.environ['ICDIR'] + '/invisible_cities/Database/localdb.sqlite3'
dbfile = os.environ['ICTDIR'] + '/database/localdb.sqlite3'
try:
os.remove(dbfile)
except:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from future_builtins import map


DATABASE_LOCATION = '/invisible_cities/Database/localdb.sqlite3'
DATABASE_LOCATION = '/invisible_cities/database/localdb.sqlite3'

def tmap(*args):
return tuple(map(*args))

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import numpy as np
from scipy import signal
import invisible_cities.Core.system_of_units as units
import invisible_cities.Database.loadDB as DB
import invisible_cities.core.system_of_units as units
import invisible_cities.database.loadDB as DB

# globals describing FEE
PMT_GAIN = 1.7e6
Expand Down Expand Up @@ -399,4 +399,3 @@ def daq_decimator(f_sample1, f_sample2, signal_in):

scale = int(f_sample1 / f_sample2)
return signal.decimate(signal_in, scale, ftype='fir', zero_phase=False)

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from hypothesis.strategies import lists, floats
from flaky import flaky

import invisible_cities.Sierpe.FEE as FE
import invisible_cities.Core.system_of_units as units
import invisible_cities.sierpe.fee as FE
import invisible_cities.core.system_of_units as units
import numpy as np

def signal_i_th():
Expand Down Expand Up @@ -95,5 +95,3 @@ def test_FEE():
energy_mea2=np.sum(signal_r2[1000:11000])
energy_in2=np.sum(signal_i*FE.i_to_adc())
diff = np.abs(100.*((energy_in2-energy_mea2)/energy_in2))


4 changes: 2 additions & 2 deletions invisible_cities/tests/test_db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tables
from invisible_cities.Database import download
import invisible_cities.Database.loadDB as DB
from invisible_cities.database import download
import invisible_cities.database.loadDB as DB
import os


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
author_email = 'nextic@TODO.org',
license = 'TODO',
packages = ['invisible_cities'],
ext_modules = cythonize('invisible_cities/ICython**/*.pyx'),
ext_modules = cythonize('invisible_cities/cython**/*.pyx'),
include_dirs = [numpy_include],
)

0 comments on commit b34c275

Please sign in to comment.