prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Automate building of docs for new release and dev version.
  Author: @fernandezc (Christian Fernandez )
  Date: 2020-05-28
  Redmine Issue: 74, https://redmine.spectrochempy.fr/issues/74
  
  ---
  
  None
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `spectrochempy/core/readers/readopus.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 #
  3 # ======================================================================================================================
  4 # Copyright (©) 2015-2020 LCS
  5 # Laboratoire Catalyse et Spectrochimie, Caen, France.
  6 # CeCILL-B FREE SOFTWARE LICENSE AGREEMENT
  7 # See full LICENSE agreement in the root directory
  8 # ======================================================================================================================
  9 
  10 """This module to extend NDDataset with the import methods method.
  11 
  12 """
  13 __all__ = ['read_opus']
  14 
  15 __dataset_methods__ = __all__
  16 
  17 # ----------------------------------------------------------------------------------------------------------------------
  18 # standard imports
  19 # ----------------------------------------------------------------------------------------------------------------------
  20 
  21 
  22 from brukeropusreader import read_file
  23 from warnings import warn
  24 from datetime import datetime, timezone, timedelta
  25 
  26 
  27 
  28 
  29 
  30 # ----------------------------------------------------------------------------------------------------------------------
  31 # third party imports
  32 # ----------------------------------------------------------------------------------------------------------------------
  33 # ----------------------------------------------------------------------------------------------------------------------
  34 # local imports
  35 # ----------------------------------------------------------------------------------------------------------------------
  36 from spectrochempy.core import debug_
  37 from spectrochempy.core.dataset.nddataset import NDDataset
  38 from spectrochempy.core.dataset.ndcoord import Coord
  39 from spectrochempy.utils import readfilename
  40 # ======================================================================================================================
  41 # Public functions
  42 # ======================================================================================================================
  43 
  44 # .............................................................................
  45 def read_opus(dataset=None, **kwargs):
  46     """Open Bruker Opus file(s) and group them in a single dataset. Only the spectrum is
  47     extracted ("AB" field). Returns an error if dimensions are incompatibles.
  48 
  49     Parameters
  50     ----------
  51     filename : `None`, `str`, or list of `str`
  52         Filename of the file(s) to load. If `None` : opens a dialog box to select
  53          files. If `str` : a single filename. It list of str :
  54         a list of filenames.
  55     directory : str, optional, default="".
  56         From where to read the specified filename. If not specified, read in
  57         the defaults datadir.
  58 
  59     Returns
  60     -------
  61     dataset : |NDDataset|
  62         A dataset corresponding to the (set of) bruker file(s).
  63 
  64     Examples
  65     --------
  66     >>> A = NDDataset.read_opus('irdata\\spectrum.0001')
  67     >>> print(A)
  68     NDDataset: [float64] a.u. (shape: (y:1, x:2568))
  69     """
  70     debug_("reading bruker opus files")
  71 
  72     # filename will be given by a keyword parameter except if the first parameters is already
  73     # the filename
  74     filename = kwargs.get('filename', None)
  75 
  76     # check if the first parameter is a dataset because we allow not to pass it
  77     if not isinstance(dataset, NDDataset):
  78         # probably did not specify a dataset
  79         # so the first parameters must be the filename
  80         if isinstance(dataset, (str, list)) and dataset != '':
  81             filename = dataset
  82 
  83     # check if directory was specified
  84     directory = kwargs.get("directory", None)
  85     sortbydate = kwargs.get("sortbydate", True)
  86 
  87     # returns a list of files to read
  88     files = readfilename(filename,
  89                          directory=directory,
  90                          filetypes=['Bruker files (*.*)',
  91                                     'all files (*)'],
  92                          dictionary=False)
  93     #todo: see how to use regular expression in Qt filters
  94 
  95     if not files:
  96         # there is no files, return nothing
  97         return None
  98 
  99     xaxis = None
  100     intensities = []
  101     names = []
  102     acquisitiondates = []
  103     timestamps = []
  104     for file in files:
  105         opus_data = read_file(file)
  106         try:
  107             opus_data["AB"]
  108         except KeyError:  # not an absorbance spectrum
  109             warn("opus file {} could not be read".format(file))
  110             continue
  111 
  112         if not xaxis:
  113             xaxis = Coord(opus_data.get_range("AB"), title='Wavenumbers', units='cm^-1')
  114 
  115         elif (opus_data.get_range("AB") != xaxis.data).any():
  116             raise ValueError("spectra have incompatible dimensions (xaxis)")
  117 
  118         intensities.append(opus_data["AB"])
  119         names.append(opus_data["Sample"]['SNM'])
  120         acqdate = opus_data["AB Data Parameter"]["DAT"]
  121         acqtime = opus_data["AB Data Parameter"]["TIM"]
  122         GMT_offset_hour = float(acqtime.split('GMT')[1].split(')')[0])
  123         date_time = datetime.strptime(acqdate + '_' + acqtime.split()[0],
  124                                       '%d/%m/%Y_%H:%M:%S.%f')
  125         UTC_date_time = date_time - timedelta(hours=GMT_offset_hour)
  126         UTC_date_time = UTC_date_time.replace(tzinfo=timezone.utc)
  127         # Transform to timestamp for storage in the Coord object
  128         # use datetime.fromtimestamp(d, timezone.utc)) to transform back to datetime
  129         timestamp = UTC_date_time.timestamp()
  130         acquisitiondates.append(UTC_date_time)
  131         timestamps.append(timestamp)
  132 
  133     # return if none of the files could be read:
  134     if not xaxis:
  135         return
  136 
  137     yaxis = Coord(timestamps,
  138                   title='Acquisition timestamp (GMT)',
  139                   units='s',
  140                   labels=(acquisitiondates, names))
  141 
  142     dataset = NDDataset(intensities)
  143     dataset.set_coords(y=yaxis, x=xaxis)
  144     dataset.units = 'absorbance'
  145     dataset.title = 'Absorbance'
  146 
  147     # Set origin, description and history
  148     dataset.origin = "opus"
  149     dataset.description = ('Dataset from opus files. \n')
  150 
  151     if sortbydate:
  152         dataset.sort(dim='y', inplace=True)
  153 
  154     dataset.history = str(datetime.now()) + ':import from opus files \n'
  155 
  156     # Set the NDDataset date
  157     dataset._date = datetime.now()
  158     dataset._modified = dataset.date
  159     # debug_("end of reading")
  160 
  161     return dataset
  162
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/spectrochempy/core/readers/readopus.py b/spectrochempy/core/readers/readopus.py
  --- a/spectrochempy/core/readers/readopus.py
  +++ b/spectrochempy/core/readers/readopus.py
  @@ -22,10 +22,7 @@
   from brukeropusreader import read_file
   from warnings import warn
   from datetime import datetime, timezone, timedelta
  -
  -
  -
  -
  +from numpy import linspace
   
   # ----------------------------------------------------------------------------------------------------------------------
   # third party imports
  @@ -37,6 +34,8 @@
   from spectrochempy.core.dataset.nddataset import NDDataset
   from spectrochempy.core.dataset.ndcoord import Coord
   from spectrochempy.utils import readfilename
  +
  +
   # ======================================================================================================================
   # Public functions
   # ======================================================================================================================
  @@ -90,7 +89,7 @@
                            filetypes=['Bruker files (*.*)',
                                       'all files (*)'],
                            dictionary=False)
  -    #todo: see how to use regular expression in Qt filters
  +    # todo: see how to use regular expression in Qt filters
   
       if not files:
           # there is no files, return nothing
  @@ -109,13 +108,18 @@
               warn("opus file {} could not be read".format(file))
               continue
   
  +        npt = opus_data['AB Data Parameter']['NPT']
  +        fxv = opus_data['AB Data Parameter']['FXV']
  +        lxv = opus_data['AB Data Parameter']['LXV']
  +        xdata = linspace(fxv, lxv, npt)
  +
           if not xaxis:
  -            xaxis = Coord(opus_data.get_range("AB"), title='Wavenumbers', units='cm^-1')
  +            xaxis = Coord(x=xdata, title='Wavenumbers', units='cm^-1')
   
  -        elif (opus_data.get_range("AB") != xaxis.data).any():
  +        elif (xdata != xaxis.data).any():
               raise ValueError("spectra have incompatible dimensions (xaxis)")
   
  -        intensities.append(opus_data["AB"])
  +        intensities.append(opus_data["AB"][:npt])
           names.append(opus_data["Sample"]['SNM'])
           acqdate = opus_data["AB Data Parameter"]["DAT"]
           acqtime = opus_data["AB Data Parameter"]["TIM"]
  
verification_info: {"golden_diff": "diff --git a/spectrochempy/core/readers/readopus.py b/spectrochempy/core/readers/readopus.py\n--- a/spectrochempy/core/readers/readopus.py\n+++ b/spectrochempy/core/readers/readopus.py\n@@ -22,10 +22,7 @@\n from brukeropusreader import read_file\n from warnings import warn\n from datetime import datetime, timezone, timedelta\n-\n-\n-\n-\n+from numpy import linspace\n \n # ----------------------------------------------------------------------------------------------------------------------\n # third party imports\n@@ -37,6 +34,8 @@\n from spectrochempy.core.dataset.nddataset import NDDataset\n from spectrochempy.core.dataset.ndcoord import Coord\n from spectrochempy.utils import readfilename\n+\n+\n # ======================================================================================================================\n # Public functions\n # ======================================================================================================================\n@@ -90,7 +89,7 @@\n                          filetypes=['Bruker files (*.*)',\n                                     'all files (*)'],\n                          dictionary=False)\n-    #todo: see how to use regular expression in Qt filters\n+    # todo: see how to use regular expression in Qt filters\n \n     if not files:\n         # there is no files, return nothing\n@@ -109,13 +108,18 @@\n             warn(\"opus file {} could not be read\".format(file))\n             continue\n \n+        npt = opus_data['AB Data Parameter']['NPT']\n+        fxv = opus_data['AB Data Parameter']['FXV']\n+        lxv = opus_data['AB Data Parameter']['LXV']\n+        xdata = linspace(fxv, lxv, npt)\n+\n         if not xaxis:\n-            xaxis = Coord(opus_data.get_range(\"AB\"), title='Wavenumbers', units='cm^-1')\n+            xaxis = Coord(x=xdata, title='Wavenumbers', units='cm^-1')\n \n-        elif (opus_data.get_range(\"AB\") != xaxis.data).any():\n+        elif (xdata != xaxis.data).any():\n             raise ValueError(\"spectra have incompatible dimensions (xaxis)\")\n \n-        intensities.append(opus_data[\"AB\"])\n+        intensities.append(opus_data[\"AB\"][:npt])\n         names.append(opus_data[\"Sample\"]['SNM'])\n         acqdate = opus_data[\"AB Data Parameter\"][\"DAT\"]\n         acqtime = opus_data[\"AB Data Parameter\"][\"TIM\"]\n", "issue": "Automate building of docs for new release and dev version.\nAuthor: @fernandezc (Christian Fernandez )\nDate: 2020-05-28\nRedmine Issue: 74, https://redmine.spectrochempy.fr/issues/74\n\n---\n\nNone\n\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# ======================================================================================================================\n# Copyright (\u00a9) 2015-2020 LCS\n# Laboratoire Catalyse et Spectrochimie, Caen, France.\n# CeCILL-B FREE SOFTWARE LICENSE AGREEMENT\n# See full LICENSE agreement in the root directory\n# ======================================================================================================================\n\n\"\"\"This module to extend NDDataset with the import methods method.\n\n\"\"\"\n__all__ = ['read_opus']\n\n__dataset_methods__ = __all__\n\n# ----------------------------------------------------------------------------------------------------------------------\n# standard imports\n# ----------------------------------------------------------------------------------------------------------------------\n\n\nfrom brukeropusreader import read_file\nfrom warnings import warn\nfrom datetime import datetime, timezone, timedelta\n\n\n\n\n\n# ----------------------------------------------------------------------------------------------------------------------\n# third party imports\n# ----------------------------------------------------------------------------------------------------------------------\n# ----------------------------------------------------------------------------------------------------------------------\n# local imports\n# ----------------------------------------------------------------------------------------------------------------------\nfrom spectrochempy.core import debug_\nfrom spectrochempy.core.dataset.nddataset import NDDataset\nfrom spectrochempy.core.dataset.ndcoord import Coord\nfrom spectrochempy.utils import readfilename\n# ======================================================================================================================\n# Public functions\n# ======================================================================================================================\n\n# .............................................................................\ndef read_opus(dataset=None, **kwargs):\n    \"\"\"Open Bruker Opus file(s) and group them in a single dataset. Only the spectrum is\n    extracted (\"AB\" field). Returns an error if dimensions are incompatibles.\n\n    Parameters\n    ----------\n    filename : `None`, `str`, or list of `str`\n        Filename of the file(s) to load. If `None` : opens a dialog box to select\n         files. If `str` : a single filename. It list of str :\n        a list of filenames.\n    directory : str, optional, default=\"\".\n        From where to read the specified filename. If not specified, read in\n        the defaults datadir.\n\n    Returns\n    -------\n    dataset : |NDDataset|\n        A dataset corresponding to the (set of) bruker file(s).\n\n    Examples\n    --------\n    >>> A = NDDataset.read_opus('irdata\\\\spectrum.0001')\n    >>> print(A)\n    NDDataset: [float64] a.u. (shape: (y:1, x:2568))\n    \"\"\"\n    debug_(\"reading bruker opus files\")\n\n    # filename will be given by a keyword parameter except if the first parameters is already\n    # the filename\n    filename = kwargs.get('filename', None)\n\n    # check if the first parameter is a dataset because we allow not to pass it\n    if not isinstance(dataset, NDDataset):\n        # probably did not specify a dataset\n        # so the first parameters must be the filename\n        if isinstance(dataset, (str, list)) and dataset != '':\n            filename = dataset\n\n    # check if directory was specified\n    directory = kwargs.get(\"directory\", None)\n    sortbydate = kwargs.get(\"sortbydate\", True)\n\n    # returns a list of files to read\n    files = readfilename(filename,\n                         directory=directory,\n                         filetypes=['Bruker files (*.*)',\n                                    'all files (*)'],\n                         dictionary=False)\n    #todo: see how to use regular expression in Qt filters\n\n    if not files:\n        # there is no files, return nothing\n        return None\n\n    xaxis = None\n    intensities = []\n    names = []\n    acquisitiondates = []\n    timestamps = []\n    for file in files:\n        opus_data = read_file(file)\n        try:\n            opus_data[\"AB\"]\n        except KeyError:  # not an absorbance spectrum\n            warn(\"opus file {} could not be read\".format(file))\n            continue\n\n        if not xaxis:\n            xaxis = Coord(opus_data.get_range(\"AB\"), title='Wavenumbers', units='cm^-1')\n\n        elif (opus_data.get_range(\"AB\") != xaxis.data).any():\n            raise ValueError(\"spectra have incompatible dimensions (xaxis)\")\n\n        intensities.append(opus_data[\"AB\"])\n        names.append(opus_data[\"Sample\"]['SNM'])\n        acqdate = opus_data[\"AB Data Parameter\"][\"DAT\"]\n        acqtime = opus_data[\"AB Data Parameter\"][\"TIM\"]\n        GMT_offset_hour = float(acqtime.split('GMT')[1].split(')')[0])\n        date_time = datetime.strptime(acqdate + '_' + acqtime.split()[0],\n                                      '%d/%m/%Y_%H:%M:%S.%f')\n        UTC_date_time = date_time - timedelta(hours=GMT_offset_hour)\n        UTC_date_time = UTC_date_time.replace(tzinfo=timezone.utc)\n        # Transform to timestamp for storage in the Coord object\n        # use datetime.fromtimestamp(d, timezone.utc)) to transform back to datetime\n        timestamp = UTC_date_time.timestamp()\n        acquisitiondates.append(UTC_date_time)\n        timestamps.append(timestamp)\n\n    # return if none of the files could be read:\n    if not xaxis:\n        return\n\n    yaxis = Coord(timestamps,\n                  title='Acquisition timestamp (GMT)',\n                  units='s',\n                  labels=(acquisitiondates, names))\n\n    dataset = NDDataset(intensities)\n    dataset.set_coords(y=yaxis, x=xaxis)\n    dataset.units = 'absorbance'\n    dataset.title = 'Absorbance'\n\n    # Set origin, description and history\n    dataset.origin = \"opus\"\n    dataset.description = ('Dataset from opus files. \\n')\n\n    if sortbydate:\n        dataset.sort(dim='y', inplace=True)\n\n    dataset.history = str(datetime.now()) + ':import from opus files \\n'\n\n    # Set the NDDataset date\n    dataset._date = datetime.now()\n    dataset._modified = dataset.date\n    # debug_(\"end of reading\")\n\n    return dataset\n", "path": "spectrochempy/core/readers/readopus.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# ======================================================================================================================\n# Copyright (\u00a9) 2015-2020 LCS\n# Laboratoire Catalyse et Spectrochimie, Caen, France.\n# CeCILL-B FREE SOFTWARE LICENSE AGREEMENT\n# See full LICENSE agreement in the root directory\n# ======================================================================================================================\n\n\"\"\"This module to extend NDDataset with the import methods method.\n\n\"\"\"\n__all__ = ['read_opus']\n\n__dataset_methods__ = __all__\n\n# ----------------------------------------------------------------------------------------------------------------------\n# standard imports\n# ----------------------------------------------------------------------------------------------------------------------\n\n\nfrom brukeropusreader import read_file\nfrom warnings import warn\nfrom datetime import datetime, timezone, timedelta\nfrom numpy import linspace\n\n# ----------------------------------------------------------------------------------------------------------------------\n# third party imports\n# ----------------------------------------------------------------------------------------------------------------------\n# ----------------------------------------------------------------------------------------------------------------------\n# local imports\n# ----------------------------------------------------------------------------------------------------------------------\nfrom spectrochempy.core import debug_\nfrom spectrochempy.core.dataset.nddataset import NDDataset\nfrom spectrochempy.core.dataset.ndcoord import Coord\nfrom spectrochempy.utils import readfilename\n\n\n# ======================================================================================================================\n# Public functions\n# ======================================================================================================================\n\n# .............................................................................\ndef read_opus(dataset=None, **kwargs):\n    \"\"\"Open Bruker Opus file(s) and group them in a single dataset. Only the spectrum is\n    extracted (\"AB\" field). Returns an error if dimensions are incompatibles.\n\n    Parameters\n    ----------\n    filename : `None`, `str`, or list of `str`\n        Filename of the file(s) to load. If `None` : opens a dialog box to select\n         files. If `str` : a single filename. It list of str :\n        a list of filenames.\n    directory : str, optional, default=\"\".\n        From where to read the specified filename. If not specified, read in\n        the defaults datadir.\n\n    Returns\n    -------\n    dataset : |NDDataset|\n        A dataset corresponding to the (set of) bruker file(s).\n\n    Examples\n    --------\n    >>> A = NDDataset.read_opus('irdata\\\\spectrum.0001')\n    >>> print(A)\n    NDDataset: [float64] a.u. (shape: (y:1, x:2568))\n    \"\"\"\n    debug_(\"reading bruker opus files\")\n\n    # filename will be given by a keyword parameter except if the first parameters is already\n    # the filename\n    filename = kwargs.get('filename', None)\n\n    # check if the first parameter is a dataset because we allow not to pass it\n    if not isinstance(dataset, NDDataset):\n        # probably did not specify a dataset\n        # so the first parameters must be the filename\n        if isinstance(dataset, (str, list)) and dataset != '':\n            filename = dataset\n\n    # check if directory was specified\n    directory = kwargs.get(\"directory\", None)\n    sortbydate = kwargs.get(\"sortbydate\", True)\n\n    # returns a list of files to read\n    files = readfilename(filename,\n                         directory=directory,\n                         filetypes=['Bruker files (*.*)',\n                                    'all files (*)'],\n                         dictionary=False)\n    # todo: see how to use regular expression in Qt filters\n\n    if not files:\n        # there is no files, return nothing\n        return None\n\n    xaxis = None\n    intensities = []\n    names = []\n    acquisitiondates = []\n    timestamps = []\n    for file in files:\n        opus_data = read_file(file)\n        try:\n            opus_data[\"AB\"]\n        except KeyError:  # not an absorbance spectrum\n            warn(\"opus file {} could not be read\".format(file))\n            continue\n\n        npt = opus_data['AB Data Parameter']['NPT']\n        fxv = opus_data['AB Data Parameter']['FXV']\n        lxv = opus_data['AB Data Parameter']['LXV']\n        xdata = linspace(fxv, lxv, npt)\n\n        if not xaxis:\n            xaxis = Coord(x=xdata, title='Wavenumbers', units='cm^-1')\n\n        elif (xdata != xaxis.data).any():\n            raise ValueError(\"spectra have incompatible dimensions (xaxis)\")\n\n        intensities.append(opus_data[\"AB\"][:npt])\n        names.append(opus_data[\"Sample\"]['SNM'])\n        acqdate = opus_data[\"AB Data Parameter\"][\"DAT\"]\n        acqtime = opus_data[\"AB Data Parameter\"][\"TIM\"]\n        GMT_offset_hour = float(acqtime.split('GMT')[1].split(')')[0])\n        date_time = datetime.strptime(acqdate + '_' + acqtime.split()[0],\n                                      '%d/%m/%Y_%H:%M:%S.%f')\n        UTC_date_time = date_time - timedelta(hours=GMT_offset_hour)\n        UTC_date_time = UTC_date_time.replace(tzinfo=timezone.utc)\n        # Transform to timestamp for storage in the Coord object\n        # use datetime.fromtimestamp(d, timezone.utc)) to transform back to datetime\n        timestamp = UTC_date_time.timestamp()\n        acquisitiondates.append(UTC_date_time)\n        timestamps.append(timestamp)\n\n    # return if none of the files could be read:\n    if not xaxis:\n        return\n\n    yaxis = Coord(timestamps,\n                  title='Acquisition timestamp (GMT)',\n                  units='s',\n                  labels=(acquisitiondates, names))\n\n    dataset = NDDataset(intensities)\n    dataset.set_coords(y=yaxis, x=xaxis)\n    dataset.units = 'absorbance'\n    dataset.title = 'Absorbance'\n\n    # Set origin, description and history\n    dataset.origin = \"opus\"\n    dataset.description = ('Dataset from opus files. \\n')\n\n    if sortbydate:\n        dataset.sort(dim='y', inplace=True)\n\n    dataset.history = str(datetime.now()) + ':import from opus files \\n'\n\n    # Set the NDDataset date\n    dataset._date = datetime.now()\n    dataset._modified = dataset.date\n    # debug_(\"end of reading\")\n\n    return dataset\n", "path": "spectrochempy/core/readers/readopus.py"}]}