Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pylint #884

Merged
merged 43 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f9ac906
Added pylint tests
iprafols Sep 23, 2020
26904e7
Merge branch 'master' into add-pylint
iprafols Sep 23, 2020
e420143
Merge branch 'master' into add-pylint
iprafols Sep 24, 2020
1278f2a
Merge branch 'delta_extraction' into add-pylint
iprafols Feb 16, 2022
578266a
modified pylint workflow to work on delta_extraction only
iprafols Feb 18, 2022
90640e0
fix to pylint workflow
iprafols Feb 18, 2022
00d7934
restored pylint workflow
iprafols Feb 18, 2022
f960527
trying new configuration
iprafols Feb 21, 2022
52a4098
trying new config
iprafols Mar 2, 2022
a9d255a
test to figure out path in github actions
iprafols Mar 3, 2022
8d4b6ee
restored pylint test
iprafols Mar 3, 2022
b1f17a5
removed ending /
iprafols Mar 3, 2022
cdc4f39
added picca install
iprafols Mar 3, 2022
085288e
added install of missing dependencies
iprafols Mar 3, 2022
0c97082
removed extra 'run'
iprafols Mar 3, 2022
6d00753
changed path to module
iprafols Mar 3, 2022
195abf1
changed path to module
iprafols Mar 3, 2022
84a32d4
Merge branch 'add-pylint' of https://github.com/igmhub/picca into add…
iprafols Mar 3, 2022
8cdd88f
Merge branch 'master' into add-pylint
iprafols Mar 22, 2022
c566dbf
fixed delta extraction path
iprafols Mar 22, 2022
0d3bff6
Merge branch 'master' into add-pylint
iprafols May 2, 2022
6961620
basic linting
iprafols May 3, 2022
36e3596
Merge branch 'master' into add-pylint
iprafols May 3, 2022
404e885
more basic linting on things from master
iprafols May 3, 2022
6cc55de
duplicated code responsible for formatting data moved from DesiHealpi…
iprafols May 3, 2022
72798d8
updated README
iprafols May 3, 2022
10e917a
simplified function to minimize code repetitionclear
iprafols May 3, 2022
fd5d17c
fixed bug
iprafols May 3, 2022
4d42096
use function get_continuum_weights to avoid code repetition
iprafols May 3, 2022
73b558a
added TODOs
iprafols May 3, 2022
29b1a00
decreased code repetition
iprafols May 3, 2022
2566a25
fixed bug in testing
iprafols May 4, 2022
4208230
healpix computation moved to quasar loading
iprafols May 4, 2022
26991fe
basic linting
iprafols May 4, 2022
1f9f5c6
weights computed using get_continuum_weights
iprafols May 4, 2022
d4f2e21
moved variable inside loop as it was not used outside
iprafols May 4, 2022
5be5886
added a new function get_filename to encapsulate differences in read_…
iprafols May 4, 2022
02b9a61
temporarily increasing min-similarity-lines to 9 (see todo in Dr16Exp…
iprafols May 4, 2022
d502550
updated pylint test to also be run on PR
iprafols May 4, 2022
68647d9
updated data model
iprafols May 4, 2022
8bee5f2
updated docstrings, very minor changes
iprafols May 4, 2022
7b9bee6
removed trailing withespaces
iprafols May 4, 2022
727500a
cleanup
iprafols May 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pylint

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
sudo apt-get -y install libbz2-dev
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pylint
- name: This path
run: |
ls
realpath .
- name: Install picca
run: pip install -e .
- name: Analysing the code with pylint
run: |
pylint py/picca/delta_extraction/**/*py
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ picca_export.py

The tags name follow the names of the king of France:<br/>
https://fr.wikipedia.org/wiki/Liste_des_monarques_de_France#Liste_des_monarques_de_France

### For Developers
Before submitting a PR please make sure to:
1. Check the tutorials. Update them if necessary (typically the tutorial `picca_delta_extraction_configuration_tutorial` will need to be updated.
2. Update the data model
3. For every file you have modified run
```yapf --style google file.py > aux
mv aux file.py
```
to ensure the coding styles are maintained.
4. Consider using pylint to help in the debug process. From the repo folder run
```pylint py/picca/delta_extraction/**/*py```
Binary file modified docs/delta_extraction/data_model/data_model-Correction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/delta_extraction/data_model/data_model-Data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/delta_extraction/data_model/data_model-ExpectedFlux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/delta_extraction/data_model/data_model-FullDataModel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/delta_extraction/data_model/data_model-Main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/delta_extraction/data_model/data_model-Mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,392 changes: 1 addition & 5,391 deletions docs/delta_extraction/data_model/data_model.drawio

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ class DesiForest(Forest):

Methods
-------
__gt__ (from AstronomicalObject)
__eq__ (from AstronomicalObject)
class_variable_check (from Forest)
consistency_check (from Forest)
get_data (from Forest)
rebin (from Forest)
(see Forest in py/picca/delta_extraction/astronomical_objects/forest.py)
__init__
coadd
get_header
Expand Down
58 changes: 38 additions & 20 deletions py/picca/delta_extraction/astronomical_objects/desi_pk1d_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ class DesiPk1dForest(DesiForest, Pk1dForest):

Methods
-------
__gt__ (from AstronomicalObject)
__eq__ (from AstronomicalObject)
class_variable_check (from Forest, Pk1dForest)
consistency_check (from Forest, Pk1dForest)
get_data (from Forest, Pk1dForest)
rebin (from Forest)
coadd (from DesiForest, Pk1dForest)
get_header (from DesiForest, Pk1dForest)
(see DesiForest in py/picca/delta_extraction/astronomical_objects/desi_forest.py)
(see Pk1dForest in py/picca/delta_extraction/astronomical_objects/pk1d_forest.py)
__init__
consistency_check
coadd
get_data
rebin

Class Attributes
----------------
Expand All @@ -37,6 +35,7 @@ class DesiPk1dForest(DesiForest, Pk1dForest):
resolution_matrix: 2d-array of floats or None
Resolution matrix of the forests
"""

def __init__(self, **kwargs):
"""Initialize instance

Expand All @@ -57,14 +56,12 @@ def __init__(self, **kwargs):
raise AstronomicalObjectError(
"Error constructing DesiPk1dForest. "
"Missing variable 'resolution_matrix'")
else:
del kwargs["resolution_matrix"]
del kwargs["resolution_matrix"]

# call parent constructors
super().__init__(**kwargs)
self.consistency_check()


def consistency_check(self):
"""Consistency checks after __init__"""
super().consistency_check()
Expand Down Expand Up @@ -98,16 +95,37 @@ def coadd(self, other):
f"{type(other).__name__}")

if other.resolution_matrix.size > 0 and self.resolution_matrix.size > 0:
if self.resolution_matrix.shape[0]!=other.resolution_matrix.shape[0]:
largershape = np.max([self.resolution_matrix.shape[0],other.resolution_matrix.shape[0]])
smallershape = np.min([self.resolution_matrix.shape[0],other.resolution_matrix.shape[0]])
if self.resolution_matrix.shape[0] != other.resolution_matrix.shape[
0]:
largershape = np.max([
self.resolution_matrix.shape[0],
other.resolution_matrix.shape[0]
])
smallershape = np.min([
self.resolution_matrix.shape[0],
other.resolution_matrix.shape[0]
])
shapediff = largershape - smallershape
if self.resolution_matrix.shape[0]==smallershape:
self.resolution_matrix = np.append(np.zeros([shapediff//2,self.resolution_matrix.shape[1]]),self.resolution_matrix,axis=0)
self.resolution_matrix = np.append(self.resolution_matrix,np.zeros([shapediff//2,self.resolution_matrix.shape[1]]),axis=0)
if other.resolution_matrix.shape[0]==smallershape:
other.resolution_matrix = np.append(np.zeros([shapediff//2,other.resolution_matrix.shape[1]]),other.resolution_matrix,axis=0)
other.resolution_matrix = np.append(other.resolution_matrix,np.zeros([shapediff//2,other.resolution_matrix.shape[1]]),axis=0)
if self.resolution_matrix.shape[0] == smallershape:
self.resolution_matrix = np.append(np.zeros(
[shapediff // 2, self.resolution_matrix.shape[1]]),
self.resolution_matrix,
axis=0)
self.resolution_matrix = np.append(
self.resolution_matrix,
np.zeros(
[shapediff // 2, self.resolution_matrix.shape[1]]),
axis=0)
if other.resolution_matrix.shape[0] == smallershape:
other.resolution_matrix = np.append(np.zeros(
[shapediff // 2, other.resolution_matrix.shape[1]]),
other.resolution_matrix,
axis=0)
other.resolution_matrix = np.append(
other.resolution_matrix,
np.zeros(
[shapediff // 2, other.resolution_matrix.shape[1]]),
axis=0)

self.resolution_matrix = np.append(self.resolution_matrix,
other.resolution_matrix,
Expand Down
Loading