# IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

**URL:** <https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294>\
**Category:** General\
**Created:** [December 22, 2022, 11:23pm UTC](https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294 "2022-12-22T23:23:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlu](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@dlu](https://nextstrain.discourse.group/u/dlu)\
**Post date:** [December 22, 2022, 11:23pm UTC](https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294/1 "2022-12-22T23:23:17Z")

</div>

Has anyone seen this error before? I don’t have enough Treetime or Python knowledge to dig it TnT This is a build with randomly selected mpox sequences. I’ve seen the same error in step `refine` instead of `fix_tree` for other sets of randomly selected sequences.

I’m trying to understand on a high level what may be the cause. For example, are the samples too diverse, or have too many mutations, or mutations that don’t agree with each other that led to this error? I’m not trying to understand for this specific set of samples which sample broke the run.

Input data can be downloaded here: [debug\_data/treetime at main · danrlu/debug\_data · GitHub](https://github.com/danrlu/debug_data/tree/main/treetime)

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/nextstrain/original/1X/b6bb6e4da1bc783ef1f689236425ff3ed561e18d.jpeg)

Version:  
treetime 0.9.4  
[monkeypox/fix\_tree.py at 644d07ebe3fa5ded64d27d0964064fb722797c5d · nextstrain/monkeypox · GitHub](https://github.com/nextstrain/monkeypox/blob/644d07ebe3fa5ded64d27d0964064fb722797c5d/scripts/fix_tree.py) (current master branch)

Thanks!

---

<div class="post-metadata">

**Author:** ![corneliusroemer](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/corneliusroemer/32/175_2.png) [@corneliusroemer](https://nextstrain.discourse.group/u/corneliusroemer)\
**Post date:** [December 23, 2022, 5:16pm UTC](https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294/3 "2022-12-23T17:16:26Z")

</div>

This looks like an treetime bug, thanks for reporting @dlu!

I’ve opened an issue on the treetime repo: [tt.optimize\_tree throws `IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed` · Issue #222 · neherlab/treetime · GitHub](https://github.com/neherlab/treetime/issues/222)

---

<div class="post-metadata">

**Author:** ![rneher](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/rneher/32/20_2.png) [@rneher](https://nextstrain.discourse.group/u/rneher)\
**Post date:** [December 23, 2022, 5:24pm UTC](https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294/4 "2022-12-23T17:24:47Z")

</div>

hi @dlu,

there are some samples in your example data that didn’t align properly (these flagged as ‘reverse complemented’). Some of them only have `-` or `N` characters. This throws of treetime (though it shouldn’t). bur removing sequences that don’t have any valid characters should solve the issue.

best,  
richard

---

<div class="post-metadata">

**Author:** ![dlu](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@dlu](https://nextstrain.discourse.group/u/dlu)\
**Post date:** [December 23, 2022, 6:07pm UTC](https://nextstrain.discourse.group/t/indexerror-too-many-indices-for-array-array-is-1-dimensional-but-2-were-indexed/1294/5 "2022-12-23T18:07:46Z")

</div>

You’re totally right. Let me go digging where things went wrong on my end. Thanks very much!
