Merge pull request #9 from spectrochempy/master
calculation of the xaxis + travis/conda configs
This commit is contained in:
commit
00b719e9c1
|
@ -1,2 +1,7 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
*.csv
|
*.csv
|
||||||
|
|
||||||
|
# dir
|
||||||
|
.idea/
|
||||||
|
conda-bld/
|
||||||
|
*.egg-info/
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
language: python
|
||||||
|
|
||||||
|
python:
|
||||||
|
- "3.7"
|
||||||
|
|
||||||
|
# limit git clone depth to 50 commits
|
||||||
|
git:
|
||||||
|
depth: 50
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get update
|
||||||
|
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
|
||||||
|
- bash miniconda.sh -b -p $HOME/miniconda
|
||||||
|
- source "$HOME/miniconda/etc/profile.d/conda.sh"
|
||||||
|
- hash -r
|
||||||
|
- conda config --set always_yes yes --set changeps1 no
|
||||||
|
- conda update -q conda
|
||||||
|
- conda config --add channels conda-forge
|
||||||
|
- conda config --add channels spectrocat
|
||||||
|
- conda config --set channel_priority strict
|
||||||
|
|
||||||
|
script:
|
||||||
|
- conda create -n py$TRAVIS_PYTHON_VERSION python=$TRAVIS_PYTHON_VERSION pytest numpy scipy
|
||||||
|
- conda activate py$TRAVIS_PYTHON_VERSION
|
||||||
|
- conda update pytest
|
||||||
|
- pip install .
|
||||||
|
- pytest
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- conda activate py$TRAVIS_PYTHON_VERSION
|
||||||
|
- conda install conda-build anaconda-client
|
||||||
|
- bash recipe/conda_upload.sh
|
|
@ -7,8 +7,8 @@ class OpusData(dict):
|
||||||
param_key = f"{spec_name} Data Parameter"
|
param_key = f"{spec_name} Data Parameter"
|
||||||
fxv = self[param_key]["FXV"]
|
fxv = self[param_key]["FXV"]
|
||||||
lxv = self[param_key]["LXV"]
|
lxv = self[param_key]["LXV"]
|
||||||
# NPT and REAL NUMBER OF POINTS may differ
|
# the number of points here is OK. It is "AB" that can return more values (equals to zero)
|
||||||
npt = self[spec_name].shape[0]
|
npt = self[param_key]["NPT"]
|
||||||
x_no_unit = np.linspace(fxv, lxv, npt)
|
x_no_unit = np.linspace(fxv, lxv, npt)
|
||||||
if wavenums:
|
if wavenums:
|
||||||
return x_no_unit
|
return x_no_unit
|
||||||
|
|
|
@ -11,14 +11,17 @@ def main(path_to_file):
|
||||||
print(f"Data fields: " f"{list(opus_data.keys())}")
|
print(f"Data fields: " f"{list(opus_data.keys())}")
|
||||||
|
|
||||||
ab_x = opus_data.get_range("AB")
|
ab_x = opus_data.get_range("AB")
|
||||||
|
# the "AB" data can contain more null values at the end (at least 1)
|
||||||
|
# so the getting useful data requires slicing the array:
|
||||||
|
abs = opus_data["AB"][0:len(ab_x)]
|
||||||
print(f"Absorption spectrum range: " f"{ab_x[0]} {ab_x[-1]}")
|
print(f"Absorption spectrum range: " f"{ab_x[0]} {ab_x[-1]}")
|
||||||
print(f"Absorption elements num: " f'{len(opus_data["AB"])}')
|
print(f"Absorption elements num: " f'{len(abs)}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
print("Plotting AB")
|
print("Plotting AB")
|
||||||
plt.plot(opus_data.get_range("AB"), opus_data["AB"])
|
plt.plot(opus_data.get_range("AB"), abs)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
print("Plotting interpolated AB")
|
print("Plotting interpolated AB")
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
## adapted on https://gist.github.com/zshaheen/fe76d1507839ed6fbfbccef6b9c13ed9
|
||||||
|
|
||||||
|
PKG_NAME=brukeropusreader
|
||||||
|
OS=noarch
|
||||||
|
conda config --set anaconda_upload no
|
||||||
|
|
||||||
|
## TAG
|
||||||
|
TAG=$(git describe --tags)
|
||||||
|
IFS=$"-"
|
||||||
|
read -ra arr <<< "$TAG"
|
||||||
|
LAST_TAG="${arr[0]}"
|
||||||
|
IFS=$"."
|
||||||
|
read -ra tag <<< "$LAST_TAG"
|
||||||
|
NEXT_TAG="${tag[0]}.${tag[1]}.`expr ${tag[2]} + 1`"
|
||||||
|
NUMBER="${arr[1]}"
|
||||||
|
|
||||||
|
export CONDA_BLD_PATH="$HOME/conda-bld"
|
||||||
|
mkdir -p "$CONDA_BLD_PATH"
|
||||||
|
|
||||||
|
## Here we will choose depending on the way this script is run
|
||||||
|
if [[ $USER != "travis" ]]; then
|
||||||
|
## if we are in local
|
||||||
|
TRAVIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
if [[ $TRAVIS_BRANCH == $LAST_TAG ]]; then
|
||||||
|
TRAVIS_TAG=$LAST_TAG
|
||||||
|
fi
|
||||||
|
## else this run by TravisCI (this are env variables)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "user: $USER current branch: $TRAVIS_BRANCH last_tag: $LAST_TAG next_tag: $NEXT_TAG"
|
||||||
|
|
||||||
|
if [[ $TRAVIS_BRANCH == "master" ]]; then
|
||||||
|
## we build the current master repository (i.e.the last development version)
|
||||||
|
export DEVSTRING="latest"
|
||||||
|
export VERSION="$NEXT_TAG"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
conda build .
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> UPLOADING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2 to <dev> anaconda repository"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
anaconda -t "$CONDA_UPLOAD_TOKEN" upload --force -u $ANACONDA_USER -l dev "$CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $TRAVIS_BRANCH == $TRAVIS_TAG ]]; then
|
||||||
|
## this is a "stable" release
|
||||||
|
export DEVSTRING="stable"
|
||||||
|
export VERSION="$LAST_TAG"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
conda build .
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> UPLOADING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2 to <main> anaconda repository"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
anaconda -t "$CONDA_UPLOAD_TOKEN" upload --force -u $ANACONDA_USER "$CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! $NUMBER ]
|
||||||
|
then
|
||||||
|
NUMBER="0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $TRAVIS_BRANCH == "develop" ]]; then
|
||||||
|
## we build the current develop repository (for testing purpose)
|
||||||
|
export DEVSTRING="test$NUMBER"
|
||||||
|
export VERSION="$NEXT_TAG"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
conda build .
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> UPLOADING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2 to <test> anaconda repository"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
anaconda -t "$CONDA_UPLOAD_TOKEN" upload --force -u $ANACONDA_USER -l test "$CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
## this is a local "dev" release not yet merged with develop (will not be uploaded)
|
||||||
|
export DEVSTRING="test$NUMBER"
|
||||||
|
export VERSION="$NEXT_TAG"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
|
||||||
|
echo "***************************************************************************************************************"
|
||||||
|
conda build .
|
||||||
|
exit $?
|
|
@ -0,0 +1,52 @@
|
||||||
|
{% set name = "brukeropusreader" %}
|
||||||
|
{% set version = environ['VERSION'] %}
|
||||||
|
|
||||||
|
package:
|
||||||
|
name: "{{ name|lower }}"
|
||||||
|
version: "{{ version }}"
|
||||||
|
|
||||||
|
source:
|
||||||
|
path: ../
|
||||||
|
|
||||||
|
build:
|
||||||
|
script_env:
|
||||||
|
- VERSION
|
||||||
|
- CONDA_BLD_PATH
|
||||||
|
string: {{ environ['DEVSTRING'] }}
|
||||||
|
noarch: python
|
||||||
|
script: "{{ PYTHON }} -m pip install . -vv"
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
build:
|
||||||
|
- python
|
||||||
|
host:
|
||||||
|
- python
|
||||||
|
- numpy
|
||||||
|
- pip
|
||||||
|
- scipy
|
||||||
|
run:
|
||||||
|
- python
|
||||||
|
- numpy
|
||||||
|
- scipy
|
||||||
|
test:
|
||||||
|
- python {{ python }}
|
||||||
|
- pytest
|
||||||
|
|
||||||
|
test:
|
||||||
|
script_env:
|
||||||
|
- VERSION
|
||||||
|
- CONDA_BLD_PATH
|
||||||
|
imports:
|
||||||
|
- brukeropusreader
|
||||||
|
|
||||||
|
about:
|
||||||
|
home: "https://github.com/spectrochempy/brukeropusreader"
|
||||||
|
license: GPLv3
|
||||||
|
license_family: GPL3
|
||||||
|
summary: "Bruker OPUS File Reader"
|
||||||
|
doc_url: "https://github.com/spectrochempy/brukeropusreader"
|
||||||
|
dev_url: "https://github.com/spectrochempy/brukeropusreader"
|
||||||
|
|
||||||
|
extra:
|
||||||
|
recipe-maintainers:
|
||||||
|
- fernandezc
|
|
@ -1,3 +0,0 @@
|
||||||
numpy
|
|
||||||
scipy
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#
|
|
||||||
# This file is autogenerated by pip-compile
|
|
||||||
# To update, run:
|
|
||||||
#
|
|
||||||
# pip-compile --output-file=requirements.txt requirements.in
|
|
||||||
#
|
|
||||||
numpy==1.16.1
|
|
||||||
scipy==1.2.1
|
|
7
setup.py
7
setup.py
|
@ -1,14 +1,13 @@
|
||||||
from distutils.core import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="brukeropusreader",
|
name="brukeropusreader",
|
||||||
version="1.3.4",
|
use_scm_version=True,
|
||||||
description="Bruker OPUS File Reader",
|
description="Bruker OPUS File Reader",
|
||||||
author="QED",
|
author="QED",
|
||||||
author_email="brukeropusreader-dev@qed.ai",
|
author_email="brukeropusreader-dev@qed.ai",
|
||||||
packages=["brukeropusreader"],
|
packages=["brukeropusreader"],
|
||||||
install_requires=["numpy>=1.13.3", "scipy>=0.19.1"],
|
# install_requires=["numpy>=1.13.3", "scipy>=0.19.1"],
|
||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
url="https://github.com/qedsoftware/brukeropusreader",
|
url="https://github.com/qedsoftware/brukeropusreader",
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
def test_import():
|
||||||
|
import brukeropusreader as bor
|
||||||
|
l = dir(bor)
|
||||||
|
assert 'opus_reader' in l
|
||||||
|
|
Loading…
Reference in New Issue