diff --git a/HISTORY.rst b/HISTORY.rst
index 8aa7b5b3..a53a3b5c 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -21,6 +21,8 @@ New features and enhancements
 
 Bug fixes
 ~~~~~~~~~
+* Fix `generic.fit` dimension ordering. This caused errors when "time" was not the first dimension in a DataArray.
+
 
 Internal changes
 ~~~~~~~~~~~~~~~~
diff --git a/xclim/indices/generic.py b/xclim/indices/generic.py
index 0d23bc93..3465fc00 100644
--- a/xclim/indices/generic.py
+++ b/xclim/indices/generic.py
@@ -143,9 +143,7 @@ def fit(da: xr.DataArray, dist: str = "norm"):
     coords["dparams"] = dist_params
 
     # Dimensions for the distribution parameters
-    dims = ["dparams"]
-    dims.extend(da.dims)
-    dims.remove("time")
+    dims = [d if d != "time" else "dparams" for d in da.dims]
 
     out = xr.DataArray(data=data, coords=coords, dims=dims)
     out.attrs = da.attrs

generic.fit incorrectly orders dimensions
* xclim version: 0.18.1-beta

### Description
<!--Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.-->
Works as long as time is the first dimension, breaks otherwise (I think). 
For example, 
`xclim.indices.generic.fit(da)`  where `da` has dimensions `(site, time)`.
diff --git a/tests/test_ensembles.py b/tests/test_ensembles.py
index 3a838f34..5efd4902 100644
--- a/tests/test_ensembles.py
+++ b/tests/test_ensembles.py
@@ -340,7 +340,8 @@ class TestEnsembleReduction:
             make_graph=False,
             variable_weights=var_weights,
         )
-        assert ids == [4, 10, 12, 13, 16]
+        # Results here may change according to sklearn version, hence the *isin* intead of ==
+        assert all(np.isin([4, 12, 13, 16], ids))
         assert len(ids) == 5
 
     def test_kmeans_modelweights(self):
diff --git a/tests/test_generic.py b/tests/test_generic.py
index 901380a3..6cc6e272 100644
--- a/tests/test_generic.py
+++ b/tests/test_generic.py
@@ -59,6 +59,11 @@ class TestFA(object):
         out = generic.fit(da, "lognorm").values
         assert np.isnan(out[:, 0, 0]).all()
 
+    def test_dims_order(self):
+        da = self.da.transpose()
+        p = generic.fit(da)
+        assert p.dims[-1] == "dparams"
+
 
 class TestFrequencyAnalysis:
     def test_simple(self, ndq_series):

environment.yml
pip install -e .[dev]
parse_log_pytest
environment.yml
pytest pytest-cov coveralls
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
astroid==2.11.7
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1671632566681/work
bleach==4.1.0
bokeh @ file:///home/conda/feedstock_root/build_artifacts/bokeh_1625756939897/work
boltons @ file:///home/conda/feedstock_root/build_artifacts/boltons_1622121478442/work
Bottleneck @ file:///home/conda/feedstock_root/build_artifacts/bottleneck_1629826550175/work
bump2version==1.0.1
certifi==2021.5.30
cffi==1.15.1
cfgv==3.3.1
cftime @ file:///home/conda/feedstock_root/build_artifacts/cftime_1632539733990/work
charset-normalizer==2.0.12
click==7.1.2
click-plugins==1.1.1
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1633637764473/work
cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1674202310934/work
colorama==0.4.5
contextvars==2.4
coverage==6.2
coveralls==3.3.1
cryptography==40.0.2
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work
cytoolz==0.11.0
dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1614995065708/work
dill==0.3.4
distlib==0.3.9
distributed @ file:///home/conda/feedstock_root/build_artifacts/distributed_1615002625500/work
docopt==0.6.2
docutils==0.18.1
filelock==3.4.1
Fiona==1.8.20
flake8==5.0.4
fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1674184942191/work
GDAL==3.3.0
geojson==2.5.0
geopandas @ file:///home/conda/feedstock_root/build_artifacts/geopandas_1623249625470/work
HeapDict==1.0.1
identify==2.4.4
idna==3.10
immutables @ file:///home/conda/feedstock_root/build_artifacts/immutables_1628601257972/work
importlib-metadata==4.2.0
importlib-resources==5.2.3
iniconfig==1.1.1
isort==5.10.1
jeepney==0.7.1
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1636510082894/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1663332044897/work
keyring==23.4.1
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1610099771815/work
lazy-object-proxy==1.7.1
llvmlite==0.36.0
locket @ file:///home/conda/feedstock_root/build_artifacts/locket_1650660393415/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1673861555770/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1621455668064/work
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1611858699142/work
mccabe==0.7.0
msgpack @ file:///home/conda/feedstock_root/build_artifacts/msgpack-python_1610121702224/work
munch==2.5.0
netCDF4 @ file:///home/conda/feedstock_root/build_artifacts/netcdf4_1624308175279/work
networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1646092782768/work
nodeenv==1.6.0
numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1623568542230/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1626681920064/work
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1602866521163/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work
pandas==1.1.5
partd @ file:///home/conda/feedstock_root/build_artifacts/partd_1617910651905/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1621287993989/work
Pint @ file:///home/conda/feedstock_root/build_artifacts/pint_1630435029884/work
pkginfo==1.10.0
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.17.0
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1610127101219/work
py==1.11.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.14.0
pylint==2.13.9
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1724616129934/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1614934904503/work
pytest==7.0.1
pytest-cov==4.0.0
pytest-runner==5.3.2
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1693930252784/work
PyYAML==5.4.1
readme-renderer==34.0
requests==2.27.1
requests-toolbelt==1.0.0
rfc3986==1.5.0
Rtree @ file:///home/conda/feedstock_root/build_artifacts/rtree_1610147153210/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1630910533947/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1629411471490/work
SecretStorage==3.3.3
Shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1628205367507/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
sortedcontainers @ file:///home/conda/feedstock_root/build_artifacts/sortedcontainers_1621217038088/work
tblib @ file:///home/conda/feedstock_root/build_artifacts/tblib_1616261298899/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1643647933166/work
toml==0.10.2
tomli==1.2.3
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1610094701020/work
tox==3.28.0
tqdm==4.64.1
twine==3.8.0
typed-ast==1.5.5
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1644850595256/work
urllib3==1.26.20
virtualenv==20.16.2
watchdog==2.3.1
webencodings==0.5.1
wrapt==1.16.0
xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1621474818012/work
-e git+https://github.com/Ouranosinc/xclim.git@c3cce368e5ac64b27ecc93157095f55fefd07305#egg=xclim
xdoctest==1.1.6
zict==2.0.0
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1633302054558/work

name: xclim
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.2.0=pyh71513ae_0
  - bokeh=2.3.3=py36h5fab9bb_0
  - boltons=21.0.0=pyhd8ed1ab_0
  - boost-cpp=1.74.0=hc6e9bd1_3
  - bottleneck=1.3.2=py36he33b4a0_4
  - bzip2=1.0.8=h7f98852_4
  - c-ares=1.18.1=h7f98852_0
  - ca-certificates=2025.2.25=h06a4308_0
  - cairo=1.16.0=h6cf1ce9_1008
  - certifi=2021.5.30=py36h06a4308_0
  - cfitsio=3.470=hb418390_7
  - cftime=1.5.1=py36he33b4a0_0
  - click=7.1.2=pyh9f0ad1d_0
  - click-plugins=1.1.1=py_0
  - cligj=0.7.2=pyhd8ed1ab_1
  - cloudpickle=2.2.1=pyhd8ed1ab_0
  - contextvars=2.4=py_0
  - curl=7.79.1=h2574ce0_1
  - cycler=0.11.0=pyhd8ed1ab_0
  - cytoolz=0.11.0=py36h8f6f2f9_3
  - dask=2021.3.0=pyhd8ed1ab_0
  - dask-core=2021.3.0=pyhd8ed1ab_0
  - distributed=2021.3.0=py36h5fab9bb_0
  - expat=2.4.8=h27087fc_0
  - fiona=1.8.20=py36he9df7c8_1
  - fontconfig=2.14.0=h8e229c2_0
  - freetype=2.10.4=h0708190_1
  - freexl=1.0.6=h7f98852_0
  - fsspec=2023.1.0=pyhd8ed1ab_0
  - gdal=3.3.0=py36h5febb71_1
  - geojson=2.5.0=py_0
  - geopandas=0.9.0=pyhd8ed1ab_1
  - geopandas-base=0.9.0=pyhd8ed1ab_1
  - geos=3.9.1=h9c3ff4c_2
  - geotiff=1.6.0=hcf90da6_5
  - gettext=0.19.8.1=h0b5b191_1005
  - giflib=5.2.1=h36c2ea0_2
  - hdf4=4.2.15=h10796ff_3
  - hdf5=1.10.6=nompi_h6a2412b_1114
  - heapdict=1.0.1=py_0
  - icu=68.2=h9c3ff4c_0
  - immutables=0.16=py36h8f6f2f9_0
  - importlib_metadata=4.8.1=hd8ed1ab_1
  - jinja2=3.0.3=pyhd8ed1ab_0
  - joblib=1.2.0=pyhd8ed1ab_0
  - jpeg=9e=h166bdaf_1
  - json-c=0.15=h98cffda_0
  - kealib=1.4.14=hcc255d8_2
  - keyutils=1.6.1=h166bdaf_0
  - kiwisolver=1.3.1=py36h605e78d_1
  - krb5=1.19.3=h3790be6_0
  - lcms2=2.12=hddcbb42_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libblas=3.9.0=16_linux64_openblas
  - libcblas=3.9.0=16_linux64_openblas
  - libcurl=7.79.1=h2574ce0_1
  - libdap4=3.20.6=hd7c4107_2
  - libedit=3.1.20191231=he28a2e2_2
  - libev=4.33=h516909a_1
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgdal=3.3.0=h679344c_1
  - libgfortran-ng=13.2.0=h69a702a_0
  - libgfortran5=13.2.0=ha4646dd_0
  - libglib=2.68.4=h3e27bee_0
  - libgomp=11.2.0=h1234567_1
  - libiconv=1.17=h166bdaf_0
  - libkml=1.3.0=h238a007_1014
  - liblapack=3.9.0=16_linux64_openblas
  - libllvm10=10.0.1=he513fc3_3
  - libnetcdf=4.8.0=nompi_hcd642e3_103
  - libnghttp2=1.43.0=h812cca2_1
  - libnsl=2.0.0=h7f98852_0
  - libopenblas=0.3.21=h043d6bf_0
  - libpng=1.6.37=h21135ba_2
  - libpq=13.3=hd57d9b9_0
  - librttopo=1.1.0=h1185371_6
  - libspatialindex=1.9.3=h9c3ff4c_4
  - libspatialite=5.0.1=h20cb978_4
  - libssh2=1.10.0=ha56f1ee_2
  - libstdcxx-ng=11.2.0=h1234567_1
  - libtiff=4.2.0=hbd63e13_2
  - libuuid=2.32.1=h7f98852_1000
  - libwebp-base=1.2.2=h7f98852_1
  - libxcb=1.13=h7f98852_1004
  - libxml2=2.9.12=h72842e0_0
  - libzip=1.8.0=h4de3113_1
  - llvmlite=0.36.0=py36h05121d2_0
  - locket=1.0.0=pyhd8ed1ab_0
  - lz4-c=1.9.3=h9c3ff4c_1
  - mapclassify=2.5.0=pyhd8ed1ab_1
  - markupsafe=2.0.1=py36h8f6f2f9_0
  - matplotlib-base=3.3.4=py36hd391965_0
  - msgpack-python=1.0.2=py36h605e78d_1
  - munch=2.5.0=py_0
  - ncurses=6.4=h6a678d5_0
  - netcdf4=1.5.7=nompi_py36h3d597d4_100
  - networkx=2.7=pyhd8ed1ab_0
  - numba=0.53.1=py36h1328434_1
  - numpy=1.19.5=py36hfc0c790_2
  - olefile=0.46=pyh9f0ad1d_1
  - openjpeg=2.4.0=hb52868f_1
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd8ed1ab_0
  - pandas=1.1.5=py36h284efc9_0
  - partd=1.2.0=pyhd8ed1ab_0
  - pcre=8.45=h9c3ff4c_0
  - pillow=8.2.0=py36ha6010c0_1
  - pint=0.17=pyhd8ed1ab_1
  - pip=21.2.2=py36h06a4308_0
  - pixman=0.40.0=h36c2ea0_0
  - poppler=21.03.0=h93df280_0
  - poppler-data=0.4.12=hd8ed1ab_0
  - postgresql=13.3=h2510834_0
  - proj=8.0.0=h277dcde_0
  - psutil=5.8.0=py36h8f6f2f9_1
  - pthread-stubs=0.4=h36c2ea0_1001
  - pyparsing=3.1.4=pyhd8ed1ab_0
  - pyproj=3.0.1=py36h6e9aebd_1
  - python=3.6.13=h12debd9_1
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python_abi=3.6=2_cp36m
  - pytz=2023.3.post1=pyhd8ed1ab_0
  - pyyaml=5.4.1=py36h8f6f2f9_1
  - readline=8.2=h5eee18b_0
  - rtree=0.9.7=py36hb415506_1
  - scikit-learn=0.24.2=py36hc89565f_1
  - scipy=1.5.3=py36h81d768a_1
  - setuptools=58.0.4=py36h06a4308_0
  - shapely=1.7.1=py36hff28ebb_5
  - six=1.16.0=pyh6c4a22f_0
  - sortedcontainers=2.4.0=pyhd8ed1ab_0
  - sqlite=3.45.3=h5eee18b_0
  - tblib=1.7.0=pyhd8ed1ab_0
  - threadpoolctl=3.1.0=pyh8a188c0_0
  - tiledb=2.2.9=h91fcb0e_0
  - tk=8.6.14=h39e8969_0
  - toolz=0.12.0=pyhd8ed1ab_0
  - tornado=6.1=py36h8f6f2f9_1
  - typing-extensions=4.1.1=hd8ed1ab_0
  - typing_extensions=4.1.1=pyha770c72_0
  - tzcode=2022a=h166bdaf_0
  - tzdata=2025b=h78e105d_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xarray=0.18.2=pyhd8ed1ab_0
  - xerces-c=3.2.3=h9d8b166_3
  - xorg-kbproto=1.0.7=h7f98852_1002
  - xorg-libice=1.0.10=h7f98852_0
  - xorg-libsm=1.2.3=hd9c2040_1000
  - xorg-libx11=1.7.2=h7f98852_0
  - xorg-libxau=1.0.9=h7f98852_0
  - xorg-libxdmcp=1.1.3=h7f98852_0
  - xorg-libxext=1.3.4=h7f98852_1
  - xorg-libxrender=0.9.10=h7f98852_1003
  - xorg-renderproto=0.11.1=h7f98852_1002
  - xorg-xextproto=7.3.0=h7f98852_1002
  - xorg-xproto=7.0.31=h7f98852_1007
  - xz=5.6.4=h5eee18b_1
  - yaml=0.2.5=h7f98852_2
  - zict=2.0.0=py_0
  - zipp=3.6.0=pyhd8ed1ab_0
  - zlib=1.2.13=h5eee18b_1
  - zstd=1.4.9=ha95c52a_0
  - pip:
      - astroid==2.11.7
      - bleach==4.1.0
      - bump2version==1.0.1
      - cffi==1.15.1
      - cfgv==3.3.1
      - charset-normalizer==2.0.12
      - colorama==0.4.5
      - coverage==6.2
      - coveralls==3.3.1
      - cryptography==40.0.2
      - dill==0.3.4
      - distlib==0.3.9
      - docopt==0.6.2
      - docutils==0.18.1
      - filelock==3.4.1
      - flake8==5.0.4
      - identify==2.4.4
      - idna==3.10
      - importlib-metadata==4.2.0
      - importlib-resources==5.2.3
      - iniconfig==1.1.1
      - isort==5.10.1
      - jeepney==0.7.1
      - keyring==23.4.1
      - lazy-object-proxy==1.7.1
      - mccabe==0.7.0
      - nodeenv==1.6.0
      - pkginfo==1.10.0
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pre-commit==2.17.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.14.0
      - pylint==2.13.9
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-runner==5.3.2
      - readme-renderer==34.0
      - requests==2.27.1
      - requests-toolbelt==1.0.0
      - rfc3986==1.5.0
      - secretstorage==3.3.3
      - toml==0.10.2
      - tomli==1.2.3
      - tox==3.28.0
      - tqdm==4.64.1
      - twine==3.8.0
      - typed-ast==1.5.5
      - urllib3==1.26.20
      - virtualenv==20.16.2
      - watchdog==2.3.1
      - webencodings==0.5.1
      - wrapt==1.16.0
      - xdoctest==1.1.6
prefix: /opt/conda/envs/xclim

tests/test_generic.py::TestFA::test_dims_order
tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_rsqcutoff tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_rsqopt tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_variweights tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_rsqcutoff_with_graphs tests/test_generic.py::TestThresholdCount::test_simple
tests/test_ensembles.py::TestEnsembleStats::test_create_ensemble tests/test_ensembles.py::TestEnsembleStats::test_no_time tests/test_ensembles.py::TestEnsembleStats::test_create_unequal_times tests/test_ensembles.py::TestEnsembleStats::test_create_unaligned_times[cftime_range-calkw0] tests/test_ensembles.py::TestEnsembleStats::test_create_unaligned_times[date_range-calkw1] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc[False] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc[True] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_dask[False] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_dask[True] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_dask[None] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_nans tests/test_ensembles.py::TestEnsembleStats::test_calc_mean_std_min_max tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_nclust tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_sampleweights tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_modelweights tests/test_ensembles.py::TestEnsembleReduction::test_kkz_simple[crit0-5-expected0] tests/test_ensembles.py::TestEnsembleReduction::test_kkz_simple[crit1-4-expected1] tests/test_ensembles.py::TestEnsembleReduction::test_kkz_simple[crit2-8-expected2] tests/test_ensembles.py::TestEnsembleReduction::test_kkz_simple[crit3-4-expected3] tests/test_ensembles.py::TestEnsembleReduction::test_kkz_simple[crit4-1-expected4] tests/test_ensembles.py::TestEnsembleReduction::test_kkz_standardize tests/test_ensembles.py::TestEnsembleReduction::test_kkz_change_metric tests/test_ensembles.py::TestEnsembleReduction::test_standardize_seuclidean tests/test_generic.py::TestFA::test_fit tests/test_generic.py::TestFA::test_fa tests/test_generic.py::TestFA::test_fit_nan tests/test_generic.py::TestFA::test_empty tests/test_generic.py::TestFrequencyAnalysis::test_simple tests/test_generic.py::TestSelectResampleOp::test_month tests/test_generic.py::TestSelectResampleOp::test_season_default tests/test_generic.py::TestSelectResampleOp::test_season tests/test_generic.py::TestDailyDownsampler::test_std_calendar tests/test_generic.py::TestDailyDownsampler::test_365_day tests/test_generic.py::TestDailyDownsampler::test_360_days tests/test_generic.py::test_doyminmax
HISTORY.rst xclim/indices/generic.py
HISTORY.rst xclim/indices/generic.py