Skip to content

Commit

Permalink
Testing pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
amishgog committed Jul 22, 2024
1 parent b040084 commit b9833c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
28 changes: 14 additions & 14 deletions docs/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FAQ
=================

1. Precission Loss
1. Precision Loss
^^^^^^^^^^^^^^^^^^

::
Expand All @@ -12,9 +12,9 @@ FAQ

Check the jac value,

1.1 If all absulute value is small. it is acceptable because of the precision.
1.1 If all absulute values are small. it is acceptable because of the precision.

1.2 If some absolute value is large. It is the bad parameters or problem in models.
1.2 If some absolute values are large. It is due to the bad parameters or some problem in the models.

1.3 Avoid negative weights

Expand All @@ -30,26 +30,26 @@ Check the jac value,

There is a script (scripts/check_nan.py) to check it.

2.1.1 No stange value in data, (nan, infs ...).
2.1.1 No strange value in data, (nan, infs ...).

2.1.2 The data order should be :math:`E, p_x, p_y,p_z`, :math:`E` is the first.

2.1.3 The mass should be valid, :math:`E^2 - p_x^2 - p_y^2 - p_z^2 > 0`, and for any combinations of final particles, mab > ma + mb.
2.1.3 The mass should be valid, :math:`E^2 - p_x^2 - p_y^2 - p_z^2 > 0`, and for any combination of final particles, mab > ma + mb.

2.1.4 Avoid 0 in weights.
2.1.4 Avoid including 0 in the weights.


2.2 Check the model.
--------------------

2.2.1 The resonaces mass should be valid, for example in the mass range (m1+m2, m0-m3), out of the threshold required for special options.
2.2.1 The resonances mass should be valid, for example in the mass range (m1+m2, m0-m3), out of the threshold required for special options.

3. NaN value when getting params error.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

numpy.linalg.LinAlgError: Array must not contain infs or NaN.
numpy.linalg.LinAlgError: Arrays must not contain infs or NaN.

3.1 Similar as sec 2.2.

Expand All @@ -66,15 +66,15 @@ There is a script (scripts/check_nan.py) to check it.

4.1 Free parameters are not used in the model.

4.2 Used numpy for calculation of variable. The calculation have to be done in get_amp with TensorFlow.
4.2 Used numpy for calculation of variable. The calculations have to be done in get_amp with TensorFlow.

.. code::
...
def init_params(self):
self.a = self.add_var("a")
def get_amp(self, data, *args, **kwargs):
# avoid use numpy for varible as
# avoid using numpy for variable as
a = np.sin(self.a())
# use tensorflow instead
a = tf.sin(self.a())
Expand All @@ -100,7 +100,7 @@ There is a script (scripts/check_nan.py) to check it.
data:
lazy_call: True
5.1.3 Try to use small data sample, or simple cases (less final particles).
5.1.3 Try to use a small data sample, or simpler cases (less final particles).

5.1.4 Some special models require large memory (such as an interpolation model), try another model.

Expand Down Expand Up @@ -134,18 +134,18 @@ Check the yaml file (see https://yaml.org): the indent, speical chars :code:`,:}

AssertionError: not only one top particle

The decay chain should be complete. All the item in decay should decay from initial to finals.
The decay chain should be complete. All the item in decay chain should decay from initial to final state.


6.3 Decay chain 2
-----------------

::

RuntimeError: not decay chain available, check you config.yml
RuntimeError: not decay chain available, check your config.yml

6.3.1 Similar as sec 6.2.

6.3.2 Check the information in *remove decay chain*, see the reson why those decays are not available.
6.3.2 Check the information in *remove decay chain*, see the reason why those decays are not available.

*ls not available* means no possible LS combination allowed. Check the spin and parity. If parity is allowed to be violated, add :code:`p_break: True` to decay.
20 changes: 9 additions & 11 deletions docs/developer.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
Setup for Developer Enveriment
------------------------------
Setup for Developer Environment
-------------------------------

.. note::
Before the developing, creating a standalone enveriment is recommanded (see https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands for more).
Before developing, creating a standalone environment is recommended (see https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands for more).

The main steps are similar to the normal installation process; however, two additional steps are to be performed here.

The main steps are similar to the normal installtion process, however two additonal steps are to be performed here.

The first thing is writing tests, and testing your code.
The first thing is writing tests and then testing your code.
We use pytest (https://docs.pytest.org/en/stable/) framework for the same, it should be installed as well.

.. code::
conda install pytest pytest-cov pytest-benchmark
The other thing is `pre-commit`. it is needed for developing.
The other thing is `pre-commit`. It is needed for development.

1. You can install `pre-commit` as

Expand All @@ -29,7 +27,7 @@ and

.. code::
conda install pylint # local dependences
conda install pylint # local dependencies
pre-commit install
You can check if pre-commit is working well by running:
Expand All @@ -38,13 +36,13 @@ You can check if pre-commit is working well by running:
pre-commit run -a
It may take some time to install required package.
It may take some time to install required packages.

.. note::
If there are some `GLIBC_XXX` errors at this step, you can try to install `node.js`.

.. note::
For developer using editor with formatter, you should be careful about the options.
For developers using an editor with a formatter, you should be careful about the options.

The following are all commands needed:

Expand Down
12 changes: 6 additions & 6 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Install
To use TFPWA, we need some dependent packages. There are two main ways,
`conda` and `virtualenv` you can choose *one* of them. *Or* you can choose other method in :ref:`other-method`

1. vitrual environment
1. virtual environment
----------------------

To avoid conflict of dependence, we recommed to use vitrual environment. there are two main vitrual environment for python packages,
Expand Down Expand Up @@ -64,7 +64,7 @@ and then you can install packages in the conda environment
source ./tfpwa/bin/activate
- 1.2.5 You can exit the environment by
- 1.2.5 You can exit the environment by

.. code::
Expand Down Expand Up @@ -105,7 +105,7 @@ When using `virtualenv`, there is also simple way to install tensorflow2


3. Other dependencies
--------------------
---------------------

Other dependencies of TFPWA is simple.

Expand All @@ -126,7 +126,7 @@ Get the packages using

3.2.1 other dependencies

In conda environment, go into the directory of `tf-pwa`, you can install the rest dependencies by
In conda environment, go into the directory of `tf-pwa`, you can install rest of the dependencies by

.. code::
Expand Down Expand Up @@ -166,7 +166,7 @@ Using `-e`, so it can be updated by `git pull` directly.


4. (option) Other dependencies.
-------------------------------
--------------------------------

There are some optional packages, such as `uproot` for reading root file.

Expand Down Expand Up @@ -209,7 +209,7 @@ command to install it.
conda install tf-pwa
5.2 pip
````````
``````````

When using `pip`, you will need to install CUDA to use GPU. Just run the
following command :
Expand Down

0 comments on commit b9833c5

Please sign in to comment.