Skip to content

Commit

Permalink
add fix-encoding-pragma hook
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshs committed Aug 12, 2019
1 parent d68e5ab commit a7b0985
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 66 deletions.
19 changes: 9 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3.7
default_stages: [commit, push, manual]
repos:
- repo: https://github.com/ambv/black
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
Expand All @@ -13,23 +13,23 @@ repos:
types: [python]
files: \.pyi?$

- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/asottile/blacken-docs
rev: v1.0.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
language: python
language_version: python3.7
- id: blacken-docs
additional_dependencies: [black==19.3b0]
language: python
language_version: python3.7

- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: check-yaml
language: python
- id: check-added-large-files
language: python
# - id: fix-encoding-pragma
# language: python
- id: fix-encoding-pragma
language: python
- id: check-docstring-first
language: python
- id: flake8
Expand All @@ -46,7 +46,6 @@ repos:
language: python
types: [python]


# - repo: https://github.com/asottile/reorder_python_imports
# rev: v1.4.0
# hooks:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

from setuptools import Extension
from setuptools import find_packages
Expand Down
42 changes: 19 additions & 23 deletions src/c_lib/include/Hamiltonian.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Contact email = srivastava.89@osu.edu, deepansh2012@gmail.com
//

#include "transition_function.h"
#include "mrsimulator.h"
#include "transition_function.h"

/*
===============================================================================
Expand All @@ -18,8 +18,7 @@ spin transition functions.
*/
static inline void get_nuclear_shielding_hamiltonian_to_first_order(
double *R0, complex128 *R2, double iso, double zeta, double eta,
double *transition)
{
double *transition) {
// Spin transition contribution
double transition_fn = p(transition[1], transition[0]);

Expand All @@ -45,10 +44,10 @@ static inline void get_nuclear_shielding_hamiltonian_to_first_order(
The Hamiltonian includes the product of second rank tensor and the
spin transition functions.
*/
static inline void get_quadrupole_hamiltonian_to_first_order(
double *R0, complex128 *R2, double spin, double Cq, double eta,
double *transition)
{
static inline void
get_quadrupole_hamiltonian_to_first_order(double *R0, complex128 *R2,
double spin, double Cq, double eta,
double *transition) {
// Spin transition contribution
double transition_fn = d(transition[1], transition[0]);

Expand Down Expand Up @@ -79,10 +78,9 @@ The Hamiltonian includes the product of second rank tensor and the
spin transition functions.
*/
static inline void get_quadrupole_hamiltonian_to_second_order(
double *R0, complex128 *R2, complex128 *R4, double spin,
double Cq, double eta, double *transition, double vo,
int remove_second_order_quad_iso)
{
double *R0, complex128 *R2, complex128 *R4, double spin, double Cq,
double eta, double *transition, double vo,
int remove_second_order_quad_iso) {
// Spin transition contribution
double c0, c2, c4;
quad_ci(&c0, &c2, &c4, transition[1], transition[0], spin);
Expand All @@ -97,31 +95,30 @@ static inline void get_quadrupole_hamiltonian_to_second_order(
double eta2 = eta * eta;

// Scaled R00
if (remove_second_order_quad_iso == 0)
{
if (remove_second_order_quad_iso == 0) {
R0[0] += (eta2 * 0.33333333333 + 1.0) * 0.07453559925 * scale * c0;
}

/* Scaled R2m containing the components of the quad second rank tensor in
its principal axis frame. */
double temp = -eta * 0.07273929675 * scale * c2;
double temp2 = 0.08908708064 * (eta2 * 0.33333333333 - 1.0) * scale * c2;
complex128_add_inplace(R2[0], temp); // R2-2
complex128_add_inplace(R2[1], 0.0); // R2-1
complex128_add_inplace(R2[0], temp); // R2-2
complex128_add_inplace(R2[1], 0.0); // R2-1
complex128_add_inplace(R2[2], temp2); // R2 0
complex128_add_inplace(R2[3], 0.0); // R2 1
complex128_add_inplace(R2[4], temp); // R2 2
complex128_add_inplace(R2[3], 0.0); // R2 1
complex128_add_inplace(R2[4], temp); // R2 2

/* Scaled R4m containing the components of the quad second rank tensor in
its principal axis frame. */
temp = eta2 * 0.02777777778 * scale * c4;
temp2 = -0.06299407883 * eta * scale * c4;
double temp4 = 0.1195228609 * (eta2 * 0.05555555556 + 1.0) * scale * c4;
complex128_add_inplace(R4[0], temp); // R4-4
complex128_add_inplace(R4[2], temp2); // R4-2
complex128_add_inplace(R4[0], temp); // R4-4
complex128_add_inplace(R4[2], temp2); // R4-2
complex128_add_inplace(R4[4], temp4); // R4 0
complex128_add_inplace(R4[6], temp2); // R4 2
complex128_add_inplace(R4[8], temp); // R4 4
complex128_add_inplace(R4[6], temp2); // R4 2
complex128_add_inplace(R4[8], temp); // R4 4
}

/*
Expand All @@ -132,8 +129,7 @@ The Hamiltonian includes the product of second rank tensor and the
spin transition functions in the weak coupling limit.
*/
static inline void get_weakly_coupled_direct_dipole_hamiltonian_to_first_order(
double *R0, complex128 *R2, double D, double *transition)
{
double *R0, complex128 *R2, double D, double *transition) {
// Spin transition contribution
double transition_fn = dIS(transition[0], transition[1], 0.5, 0.5);

Expand Down
2 changes: 0 additions & 2 deletions src/c_lib/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,4 @@ inline complex128 complex128_add_inplace(complex128 a, double b) {
// // printf("Using upto %d threads for simulation.\n", max_threads);
// #endif



#endif
1 change: 0 additions & 1 deletion src/c_lib/include/isotopomer_ravel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct __isotopomers_list {
isotopomer_ravel *isotopomers;
};


typedef struct __isotopomers_list isotopomers_list;

#endif /* isotopomer_h */
2 changes: 1 addition & 1 deletion src/c_lib/include/spinning_sidebands.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern void spinning_sideband_core(
// the second order quad Hamiltonian.

// spin rate, spin angle and number spinning sidebands
int number_of_sidebands, // The number of sidebands
int number_of_sidebands, // The number of sidebands
double sample_rotation_frequency_in_Hz, // The rotor spin frequency
double rotor_angle_in_rad, // The rotor angle relative to lab-frame z-axis

Expand Down
41 changes: 18 additions & 23 deletions src/c_lib/include/transition_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/
static inline double p(double mf, double mi) { return (mf - mi); }


/**
* @brief The @f$\mathbb{d}@f$ spin transition symmetry function.
*
Expand All @@ -53,12 +52,10 @@ static inline double p(double mf, double mi) { return (mf - mi); }
* @param mi The quantum number associated with the initial energy state.
* @return The spin transition symmetry function @f$\mathbb{d}@f$.
*/
static inline double d(double mf, double mi)
{
return 1.2247448714 * (mf * mf - mi * mi);
static inline double d(double mf, double mi) {
return 1.2247448714 * (mf * mf - mi * mi);
}


/**
* @brief The @f$\mathbb{f}@f$ spin transition symmetry function.
*
Expand All @@ -75,13 +72,12 @@ static inline double d(double mf, double mi)
* @param mi The quantum number associated with the initial energy state.
* @return The spin transition symmetry function @f$\mathbb{f}@f$.
*/
static inline double f(double mf, double mi, double spin)
{
double f_ = 1.0 - 3.0 * spin * (spin + 1.0);
f_ *= (mf - mi);
f_ += 5.0 * (mf * mf * mf - mi * mi * mi);
f_ *= 0.316227766;
return f_;
static inline double f(double mf, double mi, double spin) {
double f_ = 1.0 - 3.0 * spin * (spin + 1.0);
f_ *= (mf - mi);
f_ += 5.0 * (mf * mf * mf - mi * mi * mi);
f_ *= 0.316227766;
return f_;
}

/**
Expand All @@ -104,18 +100,17 @@ static inline double f(double mf, double mi, double spin)
* @param mSf The quantum number associated with the final state of spin S.
* @return The spin transition symmetry function @f$\mathbb{d_{IS}}@f$.
*/
static inline double dIS(double mIf, double mIi, double mSf, double mSi)
{
return mIf * mSf - mIi * mSi;
static inline double dIS(double mIf, double mIi, double mSf, double mSi) {
return mIf * mSf - mIi * mSi;
}

static inline void quad_ci(double *c0, double *c2, double *c4, double mf, double mi, double spin)
{
double f_ = f(mf, mi, spin);
double p_ = p(mf, mi);
static inline void quad_ci(double *c0, double *c2, double *c4, double mf,
double mi, double spin) {
double f_ = f(mf, mi, spin);
double p_ = p(mf, mi);

double temp = spin * (spin + 1.0) - 0.75;
c0[0] = 0.3577708764 * temp * p_ + 0.8485281374 * f_;
c2[0] = 0.1069044968 * temp * p_ + -1.0141851057 * f_;
c4[0] = -0.1434274331 * temp * p_ + -1.2850792082 * f_;
double temp = spin * (spin + 1.0) - 0.75;
c0[0] = 0.3577708764 * temp * p_ + 0.8485281374 * f_;
c2[0] = 0.1069044968 * temp * p_ + -1.0141851057 * f_;
c4[0] = -0.1434274331 * temp * p_ + -1.2850792082 * f_;
}
4 changes: 2 additions & 2 deletions src/c_lib/lib/angular_momentum.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void __wigner_d_matrix_cosine(const int l, const int n, const double *cos_angle,

wigner[12] = 1.5 * cx2 - .5; // 0, 0 // 12

wigner+=25;
wigner += 25;
}
}
if (l == 4) {
Expand Down Expand Up @@ -250,7 +250,7 @@ void __wigner_d_matrix_cosine(const int l, const int n, const double *cos_angle,
temp = 0.125 * (3. - 30. * cx2 + 35 * cx2 * cx2);
wigner[40] = temp; // 0, 0 // 40

wigner+=81;
wigner += 81;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/parseable.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from pydantic import BaseModel
from mrsimulator.unit import string_to_quantity
from typing import ClassVar, Dict
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/Hamiltonian.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np

# from . import transition_function as tf
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/angular_momentum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np

__author__ = "Deepansh J. Srivastava"
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/orientation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np

__author__ = "Deepansh J. Srivastava"
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/simulator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from numpy.fft import fft, fftfreq
import numpy as np
from numpy import dot, exp
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/transition_function.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Transition symmetry functions from irreducible tensors.
.. seealso::
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/python/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np

__author__ = "Deepansh J. Srivastava"
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/site.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from typing import ClassVar, Optional
from mrsimulator import Parseable, SymmetricTensor, AntisymmetricTensor

Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/spectrum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os.path
import re
from monty.serialization import loadfn
Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/tensors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from typing import ClassVar, Optional
from mrsimulator import Parseable

Expand Down
1 change: 1 addition & 0 deletions src/mrsimulator/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os.path
import pytest
from monty.serialization import loadfn
Expand Down
2 changes: 1 addition & 1 deletion src/mrsimulator/tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- coding: utf-8 -*-
"""
Tests for the base Parseable pattern
"""
Expand Down
2 changes: 1 addition & 1 deletion src/mrsimulator/tests/test_parseable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- coding: utf-8 -*-
"""
Tests for the base Parseable pattern
"""
Expand Down
2 changes: 1 addition & 1 deletion src/mrsimulator/tests/test_simulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- coding: utf-8 -*-
"""
Tests for the base Parseable pattern
"""
Expand Down
1 change: 1 addition & 0 deletions tests/orientations_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import numpy as np
from mrsimulator.python.orientation import cosine_of_polar_angles_and_amplitudes
from mrsimulator.python.orientation import triangle_interpolation
Expand Down
1 change: 1 addition & 0 deletions tests/phase_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import mrsimulator.sandbox as clib
from mrsimulator.python.utils import pre_phase_components
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/wigner/wigner_matrix_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import mrsimulator.sandbox as clib
from mrsimulator.python.angular_momentum import (
wigner_d_matrix_cosines,
Expand Down
1 change: 1 addition & 0 deletions tests/wigner/wigner_rotation_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import mrsimulator.sandbox as clib
from mrsimulator.python.angular_momentum import wigner_rotation
import numpy as np
Expand Down

0 comments on commit a7b0985

Please sign in to comment.